@onereach/styles 0.1.2 → 0.1.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,8 +1,9 @@
1
- @import "../../utils";
1
+ @use "../../utils" as *;
2
+ @use "../../variables/initial";
2
3
 
3
- $radio-group-prefix: base !default;
4
- $radio-group-column-mb: get-spacing(4) !default;
5
- $radio-group-row-mr: get-spacing(4) !default;
4
+ $radio-group-prefix: initial.$base-prefix !default;
5
+ $radio-group-column-mb: var(--s-4) !default;
6
+ $radio-group-row-mr: var(--s-4) !default;
6
7
 
7
8
  .#{$radio-group-prefix}-radio-group {
8
9
  &.is-column {
@@ -1,13 +1,12 @@
1
- @import "../../utils";
1
+ @use "../../utils" as *;
2
+ @use "../../variables/initial";
2
3
 
3
- $radio-prefix: base !default;
4
+ $radio-prefix: initial.$base-prefix !default;
4
5
  $radio-icon-size: px-to-rem(16) !default;
5
6
 
6
7
  $radio-dot-size: $radio-icon-size - px-to-rem(12) !default;
7
8
  $radio-dot-bg: var(--c-white) !default;
8
9
 
9
- $radio-icon-radius: 9999px;
10
-
11
10
  $radio-icon-border-width: px-to-rem(1) !default;
12
11
  $radio-icon-border-color: var(--c-neutral-2) !default;
13
12
  $radio-icon-border-color-hover: var(--c-neutral-2-darken-3) !default;
@@ -18,12 +17,10 @@ $radio-icon-bg-hover: var(--c-white-darken-3) !default;
18
17
  $radio-icon-bg-active: var(--c-white-darken-5) !default;
19
18
  $radio-icon-bg-checked: var(--c-primary) !default;
20
19
 
20
+ $radio-content-spacing: var(--s-3) !default;
21
21
  $radio-content-color: var(--c-neutral-6) !default;
22
22
  $radio-content-color-disabled: var(--c-neutral-4) !default;
23
23
 
24
- $radio-transition-func: get-transition-func() !default;
25
- $radio-transition-time: get-transition-time() !default;
26
-
27
24
  @mixin is-checked() {
28
25
  &.is-checked {
29
26
  .#{$radio-prefix}-radio {
@@ -54,13 +51,12 @@ $radio-transition-time: get-transition-time() !default;
54
51
  min-width: $radio-icon-size;
55
52
  height: $radio-icon-size;
56
53
  min-height: $radio-icon-size;
57
- margin-right: get-spacing(3);
54
+ margin-right: $radio-content-spacing;
58
55
  background-color: $radio-icon-bg;
59
56
  border: $radio-icon-border-width solid $radio-icon-border-color;
60
- border-radius: $radio-icon-radius;
61
- transition-timing-function: $radio-transition-func;
62
- transition-duration: $radio-transition-time;
63
- transition-property: border-color, background-color, opacity;
57
+ border-radius: initial.$round;
58
+
59
+ @include transition(border-color, background-color, opacity);
64
60
 
65
61
  &::after {
66
62
  position: absolute;
@@ -72,18 +68,16 @@ $radio-transition-time: get-transition-time() !default;
72
68
  background-color: $radio-dot-bg;
73
69
  border-radius: inherit;
74
70
  transition-delay: 0.15s;
75
- transition-timing-function: $radio-transition-func;
76
- transition-duration: $radio-transition-time;
77
- transition-property: transform;
78
71
  transform: translate(-50%, -50%) scale(0);
72
+
73
+ @include transition(transform);
79
74
  }
80
75
  }
81
76
 
82
77
  &--content {
83
78
  color: $radio-content-color;
84
- transition-timing-function: $radio-transition-func;
85
- transition-duration: $radio-transition-time;
86
- transition-property: color;
79
+
80
+ @include transition(color);
87
81
  }
88
82
 
89
83
  @include is-checked;
@@ -1,14 +1,12 @@
1
- @import "../../utils";
1
+ @use "../../utils" as *;
2
+ @use "../../variables/initial";
2
3
 
3
4
  // base
4
- $switch-prefix: base !default;
5
- $switch-transition-func: get-transition-func() !default;
6
- $switch-transition-time: get-transition-time() !default;
5
+ $switch-prefix: initial.$base-prefix !default;
7
6
 
8
7
  // layer
9
8
  $switch-layer-width: px-to-rem(34) !default;
10
9
  $switch-layer-height: px-to-rem(14) !default;
11
- $switch-layer-border-radius: 9999px !default;
12
10
 
13
11
  $switch-layer-bg: var(--c-neutral-2) !default;
14
12
  $switch-layer-bg-hover: var(--c-neutral-2-darken-3) !default;
@@ -31,6 +29,10 @@ $switch-knob-border-color: var(--c-neutral-1) !default;
31
29
  $switch-loader-size: calc(#{$switch-knob-size} - #{px-to-rem(5)});
32
30
  $switch-loader-color: var(--c-primary) !default;
33
31
 
32
+ $switch-content-spacing: var(--s-3) !default;
33
+ $switch-content-color: var(--c-neutral-6) !default;
34
+ $switch-content-color-disabled: var(--c-neutral-4) !default;
35
+
34
36
  @mixin is-checked() {
35
37
  &.is-checked {
36
38
  .#{$switch-prefix}-switch {
@@ -62,24 +64,29 @@ $switch-loader-color: var(--c-primary) !default;
62
64
  }
63
65
 
64
66
  .#{$switch-prefix}-switch {
65
- position: relative;
66
67
  display: inline-flex;
68
+ align-items: center;
67
69
  cursor: pointer;
68
70
 
69
71
  &--input {
70
72
  @include visually-hidden;
71
73
  }
72
74
 
75
+ &--switcher {
76
+ position: relative;
77
+ display: inline-flex;
78
+ margin-right: $switch-content-spacing;
79
+ }
80
+
73
81
  &--layer {
74
82
  width: $switch-layer-width;
75
83
  min-width: $switch-layer-width;
76
84
  height: $switch-layer-height;
77
85
  min-height: $switch-layer-height;
78
86
  background-color: $switch-layer-bg;
79
- border-radius: $switch-layer-border-radius;
80
- transition-timing-function: $switch-transition-func;
81
- transition-duration: $switch-transition-time;
82
- transition-property: background-color, opacity;
87
+ border-radius: initial.$round;
88
+
89
+ @include transition(background-color, opacity);
83
90
  }
84
91
 
85
92
  &--knob {
@@ -98,10 +105,15 @@ $switch-loader-color: var(--c-primary) !default;
98
105
  border-width: $switch-knob-border-width solid $switch-knob-border-color;
99
106
  border-radius: 9999px;
100
107
  box-shadow: $switch-knob-box-shadow;
101
- transition-timing-function: $switch-transition-func;
102
- transition-duration: $switch-transition-time;
103
- transition-property: transform, box-shadow;
104
108
  transform: translate(-3px, -50%);
109
+
110
+ @include transition(transform, box-shadow);
111
+ }
112
+
113
+ &--content {
114
+ color: $switch-content-color;
115
+
116
+ @include transition(color);
105
117
  }
106
118
 
107
119
  &--loader {
@@ -138,11 +150,16 @@ $switch-loader-color: var(--c-primary) !default;
138
150
  opacity: 0.5;
139
151
  }
140
152
 
141
- &-knob {
153
+ &--knob {
142
154
  box-shadow: $switch-knob-box-shadow-disabled;
143
155
  }
156
+
157
+ &--content {
158
+ color: $switch-content-color-disabled;
159
+ }
144
160
  }
145
161
  }
146
162
 
147
163
  @include is-checked;
164
+ @include loading;
148
165
  }
@@ -0,0 +1,242 @@
1
+ @use "sass:list";
2
+ @use "../../utils" as *;
3
+ @use "../../variables/initial";
4
+
5
+ $textbox-prefix: initial.$base-prefix !default;
6
+
7
+ $textbox-border-width: 1px !default;
8
+
9
+ $textbox-placeholder-color: var(--c-neutral-4) !default;
10
+
11
+ $textbox-color-error: var(--c-error) !default;
12
+
13
+ $textbox-bg: var(--c-neutral-1) !default;
14
+ $textbox-bg-hover: var(--c-white) !default;
15
+ $textbox-bg-focus: var(--c-white) !default;
16
+ $textbox-bg-disabled: var(--c-neutral-2) !default;
17
+
18
+ $textbox-border-color: var(--c-neutral-2) !default;
19
+ $textbox-border-color-hover: var(--c-neutral-2-darken-3) !default;
20
+ $textbox-border-color-focus: var(--c-primary) !default;
21
+ $textbox-border-color-active: var(--c-neutral-2-darken-5) !default;
22
+ $textbox-border-color-disabled: var(--c-neutral-2) !default;
23
+
24
+ $textbox-border-color-error: var(--c-error) !default;
25
+ $textbox-border-color-error-hover: var(--c-error-darken-3) !default;
26
+ $textbox-border-color-error-focus: var(--c-error-darken-5) !default;
27
+ $textbox-border-color-error-disabled: var(--c-error) !default;
28
+
29
+ $textbox-border-radius: px-to-rem(4) !default;
30
+
31
+ $textbox-height: px-to-rem(36) !default;
32
+ $textbox-min-width: px-to-rem(114) !default;
33
+
34
+ $textbox-padding: px-to-rem(10) !default;
35
+
36
+ $textbox-font-size: var(--fs-1) !default;
37
+
38
+ $textbox-label-margin: 0 0 px-to-rem(4) !default;
39
+ $textbox-label-color: var(--c-neutral-4) !default;
40
+
41
+ .#{$textbox-prefix}-textbox {
42
+ display: flex;
43
+ flex-direction: column;
44
+
45
+ &--content {
46
+ width: 100%;
47
+ }
48
+
49
+ &--label {
50
+ margin: $textbox-label-margin;
51
+ color: $textbox-label-color;
52
+
53
+ .material-icons {
54
+ font-size: var(--fs-1);
55
+ }
56
+ }
57
+
58
+ &--append,
59
+ &--prepend {
60
+ position: relative;
61
+ display: inline-flex;
62
+ align-items: center;
63
+ min-height: $textbox-height;
64
+ }
65
+
66
+ &--append {
67
+ margin-left: px-to-rem(10);
68
+ }
69
+
70
+ &--prepend {
71
+ margin-right: px-to-rem(10);
72
+ }
73
+
74
+ &--input {
75
+ display: block;
76
+ width: 100%;
77
+ min-width: $textbox-min-width;
78
+ height: $textbox-height;
79
+ padding: $textbox-padding;
80
+ font-family: inherit;
81
+ font-size: $textbox-font-size;
82
+ background-color: $textbox-bg;
83
+ border: $textbox-border-width solid $textbox-border-color;
84
+ border-radius: $textbox-border-radius;
85
+ outline: none;
86
+
87
+ @include transition(border-color, background-color);
88
+
89
+ &[type="password"],
90
+ &[type="search"] {
91
+ padding-right: calc(#{$textbox-padding} + #{px-to-rem(26)});
92
+ }
93
+
94
+ &-wr {
95
+ position: relative;
96
+ display: flex;
97
+ width: 100%;
98
+ }
99
+
100
+ &-toggle-btn {
101
+ position: absolute;
102
+ top: 50%;
103
+ right: 0;
104
+ z-index: 1;
105
+ transform: translate(-#{list.nth($textbox-padding, 1)}, -50%);
106
+ }
107
+
108
+ &::placeholder {
109
+ color: $textbox-placeholder-color;
110
+
111
+ @include transition(opacity);
112
+ }
113
+
114
+ @include hover {
115
+ background-color: $textbox-bg-hover;
116
+ border-color: $textbox-border-color-hover;
117
+ }
118
+
119
+ @include active {
120
+ border-color: $textbox-border-color-active;
121
+ }
122
+
123
+ @include focus {
124
+ background-color: $textbox-bg-focus;
125
+ border-color: $textbox-border-color-focus;
126
+
127
+ &::placeholder {
128
+ opacity: 0;
129
+ }
130
+ }
131
+
132
+ @include disabled {
133
+ background-color: $textbox-bg-disabled;
134
+ border-color: $textbox-border-color-disabled;
135
+ }
136
+ }
137
+
138
+ &--textarea {
139
+ @extend .#{$textbox-prefix}-textbox--input;
140
+
141
+ min-height: px-to-rem(79);
142
+ max-height: px-to-rem(142);
143
+ overflow-x: hidden;
144
+ overflow-y: auto;
145
+ resize: none;
146
+ }
147
+
148
+ &--info {
149
+ width: 100%;
150
+ margin: 0;
151
+
152
+ @include transition(height, opacity);
153
+ }
154
+
155
+ &--counter {
156
+ flex-shrink: 0;
157
+ margin-left: auto;
158
+ font-size: var(--fs-0);
159
+ line-height: px-to-rem(14);
160
+ color: var(--c-neutral-4);
161
+ }
162
+
163
+ &--hint,
164
+ &-error {
165
+ flex-shrink: 1;
166
+
167
+ @include transition(height, opacity);
168
+ }
169
+
170
+ &.is-small {
171
+ .#{$textbox-prefix}-textbox {
172
+ &--input {
173
+ padding: px-to-rem(8) px-to-rem(10);
174
+ font-size: var(--fs-0);
175
+
176
+ &[type="password"],
177
+ &[type="search"] {
178
+ padding-right: calc(#{px-to-rem(10)} + #{px-to-rem(12) * 2});
179
+ }
180
+
181
+ &-toggle-btn {
182
+ .material-icons {
183
+ font-size: var(--fs-1);
184
+ }
185
+ }
186
+ }
187
+ }
188
+ }
189
+
190
+ &.has-slot {
191
+ flex-direction: row;
192
+ align-items: flex-end;
193
+ }
194
+
195
+ &.has-counter {
196
+ .#{$textbox-prefix}-textbox {
197
+ &--hint,
198
+ &--error {
199
+ padding-right: px-to-rem(15);
200
+ }
201
+ }
202
+ }
203
+
204
+ &.is-show-info {
205
+ .#{$textbox-prefix}-textbox {
206
+ &--info {
207
+ display: flex;
208
+ align-items: flex-start;
209
+ justify-content: space-between;
210
+ padding-top: px-to-rem(4);
211
+ }
212
+ }
213
+ }
214
+
215
+ @include disabled {
216
+ .#{$textbox-prefix}-textbox {
217
+ &--input-toggle-btn {
218
+ pointer-events: none;
219
+ }
220
+ }
221
+ }
222
+
223
+ @include has-error {
224
+ .#{$textbox-prefix}-textbox {
225
+ &--input {
226
+ border-color: $textbox-border-color-error;
227
+
228
+ @include hover {
229
+ border-color: $textbox-border-color-error-hover;
230
+ }
231
+
232
+ @include focus {
233
+ border-color: $textbox-border-color-error-focus;
234
+ }
235
+
236
+ @include disabled {
237
+ border-color: $textbox-border-color-error-disabled;
238
+ }
239
+ }
240
+ }
241
+ }
242
+ }
@@ -0,0 +1,29 @@
1
+ .d {
2
+ &-inline {
3
+ display: inline;
4
+ }
5
+
6
+ &-inline-block {
7
+ display: inline-block;
8
+ }
9
+
10
+ &-flex {
11
+ display: flex;
12
+ }
13
+
14
+ &-inline-flex {
15
+ display: inline-flex;
16
+ }
17
+
18
+ &-block {
19
+ display: block;
20
+ }
21
+
22
+ &-grid {
23
+ display: grid;
24
+ }
25
+
26
+ &-inline-grid {
27
+ display: inline-grid;
28
+ }
29
+ }
@@ -0,0 +1,79 @@
1
+ .align {
2
+ &-baseline {
3
+ align-items: baseline;
4
+ }
5
+
6
+ &-start {
7
+ align-items: start;
8
+ }
9
+
10
+ &-end {
11
+ align-items: end;
12
+ }
13
+
14
+ &-self-start {
15
+ align-items: self-start;
16
+ }
17
+
18
+ &-self-end {
19
+ align-items: self-end;
20
+ }
21
+
22
+ &-flex-start {
23
+ align-items: flex-start;
24
+ }
25
+
26
+ &-flex-end {
27
+ align-items: flex-end;
28
+ }
29
+
30
+ &-stretch {
31
+ align-items: stretch;
32
+ }
33
+
34
+ &-center {
35
+ align-items: center;
36
+ }
37
+ }
38
+
39
+ .justify {
40
+ &-start {
41
+ justify-content: start;
42
+ }
43
+
44
+ &-end {
45
+ justify-content: end;
46
+ }
47
+
48
+ &-left {
49
+ justify-content: left;
50
+ }
51
+
52
+ &-right {
53
+ justify-content: right;
54
+ }
55
+
56
+ &-flex-start {
57
+ justify-content: flex-start;
58
+ }
59
+
60
+ &-flex-end {
61
+ justify-content: flex-end;
62
+ }
63
+
64
+ &-space-between {
65
+ justify-content: space-between;
66
+ }
67
+
68
+ &-space-around {
69
+ justify-content: space-around;
70
+ }
71
+
72
+ &-sapce-evenly {
73
+ justify-content: space-evenly;
74
+ }
75
+
76
+ &-center {
77
+ justify-content: center;
78
+ }
79
+ }
@@ -0,0 +1,29 @@
1
+ @use "sass:string";
2
+ @use "../variables/initial";
3
+ @use "../utils/functions/px-to-rem" as *;
4
+
5
+ $directions: (top, right, bottom, left);
6
+ $margin-prefix: m !default;
7
+ $padding-prefix: p !default;
8
+
9
+ .#{$margin-prefix}-0 {
10
+ margin: 0;
11
+ }
12
+
13
+ .#{$padding-prefix}-0 {
14
+ padding: 0;
15
+ }
16
+
17
+ @each $value in initial.$spacingsValues {
18
+ $i: index(initial.$spacingsValues, $value) - 1;
19
+
20
+ @each $direction in $directions {
21
+ .#{$margin-prefix + string.slice($direction, 1, 1)}-#{$i} {
22
+ margin-#{$direction}: px-to-rem($value);
23
+ }
24
+
25
+ .#{$padding-prefix + string.slice($direction, 1, 1)}-#{$i} {
26
+ padding-#{$direction}: px-to-rem($value);
27
+ }
28
+ }
29
+ }
@@ -0,0 +1,3 @@
1
+ @forward "display";
2
+ @forward "flexbox";
3
+ @forward "spacings";
package/src/main.scss CHANGED
@@ -1,3 +1,4 @@
1
- @import "variables";
2
- @import "utils";
3
- @import "base";
1
+ @forward "variables";
2
+ @forward "utils";
3
+ @forward "base";
4
+ @forward "layout";
@@ -0,0 +1,6 @@
1
+ @mixin absolute-center() {
2
+ position: absolute;
3
+ top: 50%;
4
+ left: 50%;
5
+ transform: translate(-50%, -50%);
6
+ }
@@ -0,0 +1,5 @@
1
+ @mixin has-error {
2
+ &.has-error {
3
+ @content;
4
+ }
5
+ }
@@ -0,0 +1,7 @@
1
+ @use "../../variables/initial" as *;
2
+
3
+ @mixin transition($transition-props...) {
4
+ transition-timing-function: $transition-function;
5
+ transition-duration: $transition-duration;
6
+ transition-property: $transition-props;
7
+ }
@@ -9,3 +9,6 @@
9
9
  @forward "loading";
10
10
  @forward "breakpont";
11
11
  @forward "overflow-touch";
12
+ @forward "absolute-center";
13
+ @forward "has-error";
14
+ @forward "transition";
@@ -1,14 +1,25 @@
1
1
  @use 'sass:map';
2
+ @use "../utils/functions/px-to-rem" as *;
3
+ @use "../utils/functions/get-transition-func" as *;
4
+ @use "../utils/functions/get-transition-time" as *;
5
+ @use "initial";
2
6
 
3
- @each $name, $theme in map.get($design-tokens, themes) {
7
+ // generate themes vars
8
+ @each $name, $theme in initial.$themesList {
4
9
  @if ($name == light) {
5
10
  :root,
6
11
  [data-theme=#{quote($name)}] {
7
12
  @each $color-key, $color-value in $theme {
8
- --c-#{$color-key + ""}: #{$color-value};
9
- --c-#{$color-key + ""}-lighten-20: #{lighten($color-value, 20%)};
10
- --c-#{$color-key + ""}-darken-3: #{darken($color-value, 3%)};
11
- --c-#{$color-key + ""}-darken-5: #{darken($color-value, 5%)};
13
+ @if ($color-key == white or $color-key == black or $color-key == body-bg) {
14
+ --c-#{$color-key + ""}: #{$color-value};
15
+ }
16
+
17
+ @else {
18
+ --c-#{quote($color-key)}: #{$color-value};
19
+ --c-#{quote($color-key)}-darken-3: #{darken($color-value, 3%)};
20
+ --c-#{quote($color-key)}-darken-5: #{darken($color-value, 5%)};
21
+ --c-#{quote($color-key)}-lighten-20: #{lighten($color-value, 20%)};
22
+ }
12
23
  }
13
24
  }
14
25
  }
@@ -16,11 +27,51 @@
16
27
  @else {
17
28
  [data-theme=#{quote($name)}] {
18
29
  @each $color-key, $color-value in $theme {
19
- --c-#{$color-key + ""}: #{$color-value};
20
- --c-#{$color-key + ""}-lighten-20: #{lighten($color-value, 20%)};
21
- --c-#{$color-key + ""}-darken-3: #{darken($color-value, 3%)};
22
- --c-#{$color-key + ""}-darken-5: #{darken($color-value, 5%)};
30
+ @if ($color-key == white or $color-key == black) {
31
+ --c-#{$color-key + ""}: #{$color-value};
32
+ }
33
+
34
+ @else {
35
+ --c-#{quote($color-key)}: #{$color-value};
36
+ --c-#{quote($color-key)}-darken-3: #{darken($color-value, 3%)};
37
+ --c-#{quote($color-key)}-darken-5: #{darken($color-value, 5%)};
38
+ --c-#{quote($color-key)}-lighten-20: #{lighten($color-value, 20%)};
39
+ }
23
40
  }
24
41
  }
25
42
  }
26
43
  }
44
+
45
+ :root {
46
+ // spacings
47
+ @each $value in initial.$spacingsValues {
48
+
49
+ $i: index(initial.$spacingsValues, $value) - 1;
50
+
51
+ --s-#{$i}: #{px-to-rem($value)};
52
+ }
53
+
54
+ --t-func: #{get-transition-func()};
55
+ --t-duration: #{get-transition-time()};
56
+
57
+ // font-sizes
58
+ @each $value in initial.$fontSizeValues {
59
+ $i: index(initial.$fontSizeValues, $value) - 1;
60
+
61
+ --fs-#{$i}: #{px-to-rem($value)};
62
+ }
63
+
64
+ // font-weights
65
+ @each $value in initial.$fontWeightValues {
66
+ $i: index(initial.$fontWeightValues, $value) - 1;
67
+
68
+ --fw-#{$i}: #{$value};
69
+ }
70
+
71
+ // line-heights
72
+ @each $value in initial.$lineHeightValues {
73
+ $i: index(initial.$lineHeightValues, $value) - 1;
74
+
75
+ --lh-#{$i}: #{px-to-rem($value)};
76
+ }
77
+ }