diff options
-rw-r--r-- | src/_general.scss | 30 | ||||
-rw-r--r-- | src/_vars.scss | 38 | ||||
-rw-r--r-- | src/index.scss | 12 | ||||
-rw-r--r-- | src/objects/_icon.scss | 40 | ||||
-rw-r--r-- | src/objects/_rule.scss | 2 | ||||
-rw-r--r-- | src/objects/_text-field.scss | 169 | ||||
-rw-r--r-- | tpl/index.pug | 32 | ||||
-rw-r--r-- | tpl/objects/icon.pug | 7 | ||||
-rw-r--r-- | tpl/objects/text-field.pug | 13 |
9 files changed, 310 insertions, 33 deletions
diff --git a/src/_general.scss b/src/_general.scss index 82b9467..e03d0b3 100644 --- a/src/_general.scss +++ b/src/_general.scss | |||
@@ -52,18 +52,24 @@ ol { | |||
52 | text-decoration: none; | 52 | text-decoration: none; |
53 | } | 53 | } |
54 | 54 | ||
55 | button { | 55 | |
56 | box-sizing: content-box; | 56 | button, |
57 | margin: 0; | 57 | input, |
58 | padding: 0; | 58 | textarea { |
59 | border: 0; | 59 | box-sizing: content-box; |
60 | background-color: transparent; | 60 | margin: 0; |
61 | color: currentColor; | 61 | padding: 0; |
62 | font: inherit; | 62 | border: 0; |
63 | letter-spacing: inherit; | 63 | background: none; |
64 | text-align: left; | 64 | color: currentColor; |
65 | text-transform: inherit; | 65 | font-family: inherit; |
66 | appearance: none; | 66 | font-size: 1em; |
67 | font-style: inherit; | ||
68 | font-weight: inherit; | ||
69 | line-height: inherit; | ||
70 | text-align: inherit; | ||
71 | text-transform: inherit; | ||
72 | appearance: none; | ||
67 | 73 | ||
68 | &::-moz-focus-inner { | 74 | &::-moz-focus-inner { |
69 | border: 0; | 75 | border: 0; |
diff --git a/src/_vars.scss b/src/_vars.scss index d2bdf38..c315438 100644 --- a/src/_vars.scss +++ b/src/_vars.scss | |||
@@ -90,18 +90,6 @@ $line-height: map-get($font--main, line-height); | |||
90 | ), | 90 | ), |
91 | 91 | ||
92 | --colors: ( | 92 | --colors: ( |
93 | --gray1: hsl(210, 0%, 100%), // 1.11 | ||
94 | --gray2: hsl(210, 0%, 98%), // 1.07 | ||
95 | --gray3: hsl(210, 0%, 95%), // 1 | ||
96 | --gray4: hsl(210, 0%, 90%), // 1.11 | ||
97 | --gray5: hsl(210, 0%, 87%), // 1.2 | ||
98 | --gray6: hsl(210, 0%, 78%), // 1.51 | ||
99 | --gray7: hsl(210, 0%, 69%), // 1.93 | ||
100 | --gray8: hsl(210, 0%, 55%), // 3 | ||
101 | --gray9: hsl(210, 0%, 38%), // 5.53 | ||
102 | --gray10: hsl(210, 0%, 19%), // 11.78 | ||
103 | --gray11: hsl(210, 0%, 0%), // 18.75 | ||
104 | |||
105 | --bg-hi2: iro.props-get(--colors --gray1, null), // Lightest background | 93 | --bg-hi2: iro.props-get(--colors --gray1, null), // Lightest background |
106 | --bg-hi: iro.props-get(--colors --gray2, null), // Lighter background | 94 | --bg-hi: iro.props-get(--colors --gray2, null), // Lighter background |
107 | --bg: iro.props-get(--colors --gray3, null), // Background | 95 | --bg: iro.props-get(--colors --gray3, null), // Background |
@@ -169,6 +157,22 @@ $line-height: map-get($font--main, line-height); | |||
169 | 157 | ||
170 | @include iro.props-store(( | 158 | @include iro.props-store(( |
171 | --colors: ( | 159 | --colors: ( |
160 | --gray1: hsl(210, 0%, 100%), // 1.11 | ||
161 | --gray2: hsl(210, 0%, 98%), // 1.07 | ||
162 | --gray3: hsl(210, 0%, 95%), // 1 | ||
163 | --gray4: hsl(210, 0%, 90%), // 1.11 | ||
164 | --gray5: hsl(210, 0%, 87%), // 1.2 | ||
165 | --gray6: hsl(210, 0%, 78%), // 1.51 | ||
166 | --gray7: hsl(210, 0%, 69%), // 1.93 | ||
167 | --gray8: hsl(210, 0%, 55%), // 3 | ||
168 | --gray9: hsl(210, 0%, 38%), // 5.53 | ||
169 | --gray10: hsl(210, 0%, 19%), // 11.78 | ||
170 | --gray11: hsl(210, 0%, 0%), // 18.75 | ||
171 | ) | ||
172 | ), 'light-palette'); | ||
173 | |||
174 | @include iro.props-store(( | ||
175 | --colors: ( | ||
172 | --gray1: hsl(210, 0%, 100%), // 1 | 176 | --gray1: hsl(210, 0%, 100%), // 1 |
173 | --gray2: hsl(210, 0%, 100%), // 1 | 177 | --gray2: hsl(210, 0%, 100%), // 1 |
174 | --gray3: hsl(210, 0%, 100%), // 1 | 178 | --gray3: hsl(210, 0%, 100%), // 1 |
@@ -181,7 +185,7 @@ $line-height: map-get($font--main, line-height); | |||
181 | --gray10: hsl(210, 0%, 22%), // 11.72 | 185 | --gray10: hsl(210, 0%, 22%), // 11.72 |
182 | --gray11: hsl(210, 0%, 0%), // 21 | 186 | --gray11: hsl(210, 0%, 0%), // 21 |
183 | ) | 187 | ) |
184 | ), 'light-raised'); | 188 | ), 'light-raised-palette'); |
185 | } | 189 | } |
186 | 190 | ||
187 | // | 191 | // |
@@ -192,11 +196,17 @@ $line-height: map-get($font--main, line-height); | |||
192 | --colors: () | 196 | --colors: () |
193 | ), 'dark'); | 197 | ), 'dark'); |
194 | } | 198 | } |
199 | |||
200 | @include iro.fn-execute { | ||
201 | @include iro.props-store(( | ||
202 | --colors: () | ||
203 | ), 'dark-palette'); | ||
204 | } | ||
195 | 205 | ||
196 | @include iro.fn-execute { | 206 | @include iro.fn-execute { |
197 | @include iro.props-store(( | 207 | @include iro.props-store(( |
198 | --colors: () | 208 | --colors: () |
199 | ), 'dark-raised'); | 209 | ), 'dark-raised-palette'); |
200 | } | 210 | } |
201 | } | 211 | } |
202 | 212 | ||
diff --git a/src/index.scss b/src/index.scss index 1d21d45..5a6a94c 100644 --- a/src/index.scss +++ b/src/index.scss | |||
@@ -6,12 +6,15 @@ | |||
6 | 6 | ||
7 | @import 'layouts/container'; | 7 | @import 'layouts/container'; |
8 | 8 | ||
9 | @import 'objects/icon'; | ||
9 | @import 'objects/heading'; | 10 | @import 'objects/heading'; |
10 | @import 'objects/rule'; | 11 | @import 'objects/rule'; |
11 | @import 'objects/button'; | 12 | @import 'objects/button'; |
13 | @import 'objects/text-field'; | ||
12 | 14 | ||
13 | :root { | 15 | :root { |
14 | @include iro.props-assign; | 16 | @include iro.props-assign; |
17 | @include iro.props-assign('light-palette'); | ||
15 | 18 | ||
16 | @each $breakpoint in map-keys(media.$breakpoints) { | 19 | @each $breakpoint in map-keys(media.$breakpoints) { |
17 | @include media.media('<=#{$breakpoint}') { | 20 | @include media.media('<=#{$breakpoint}') { |
@@ -25,8 +28,8 @@ | |||
25 | } | 28 | } |
26 | 29 | ||
27 | @include iro.bem-theme('raised') { | 30 | @include iro.bem-theme('raised') { |
28 | @include iro.props-assign($root: --colors, $prefix: --colors); | 31 | @include iro.props-assign('light-raised-palette'); |
29 | @include iro.props-assign('light-raised'); | 32 | @include iro.props-assign; |
30 | 33 | ||
31 | @include iro.bem-multi('at-theme' 'grayscale', 'theme' 'grayscale') { | 34 | @include iro.bem-multi('at-theme' 'grayscale', 'theme' 'grayscale') { |
32 | @include iro.props-assign($root: --colors --grayscale-accent, $prefix: --colors --accent); | 35 | @include iro.props-assign($root: --colors --grayscale-accent, $prefix: --colors --accent); |
@@ -35,14 +38,15 @@ | |||
35 | 38 | ||
36 | /*@media (prefers-color-scheme: dark) { | 39 | /*@media (prefers-color-scheme: dark) { |
37 | @include iro.props-assign('dark'); | 40 | @include iro.props-assign('dark'); |
41 | @include iro.props-assign('dark-palette'); | ||
38 | 42 | ||
39 | @include iro.bem-theme('grayscale') { | 43 | @include iro.bem-theme('grayscale') { |
40 | @include iro.props-assign('dark', $root: --colors --grayscale-accent, $prefix: --colors --accent); | 44 | @include iro.props-assign('dark', $root: --colors --grayscale-accent, $prefix: --colors --accent); |
41 | } | 45 | } |
42 | 46 | ||
43 | @include iro.bem-theme('raised') { | 47 | @include iro.bem-theme('raised') { |
44 | @include iro.props-assign('dark', $root: --colors, $prefix: --colors); | 48 | @include iro.props-assign('dark-raised-palette'); |
45 | @include iro.props-assign('dark-raised'); | 49 | @include iro.props-assign('dark'); |
46 | 50 | ||
47 | @include iro.bem-multi('at-theme' 'grayscale', 'theme' 'grayscale') { | 51 | @include iro.bem-multi('at-theme' 'grayscale', 'theme' 'grayscale') { |
48 | @include iro.props-assign('dark', $root: --colors --grayscale-accent, $prefix: --colors --accent); | 52 | @include iro.props-assign('dark', $root: --colors --grayscale-accent, $prefix: --colors --accent); |
diff --git a/src/objects/_icon.scss b/src/objects/_icon.scss new file mode 100644 index 0000000..b9e3c0d --- /dev/null +++ b/src/objects/_icon.scss | |||
@@ -0,0 +1,40 @@ | |||
1 | @use 'iro-sass/src/index' as iro; | ||
2 | |||
3 | @include iro.props-namespace('icon') { | ||
4 | @include iro.bem-object(iro.props-namespace()) { | ||
5 | display: inline-block; | ||
6 | width: 1em; | ||
7 | height: 1em; | ||
8 | stroke-width: var(--icon-stroke-width, 1.5px); | ||
9 | stroke-linecap: round; | ||
10 | stroke-linejoin: round; | ||
11 | vertical-align: -.1em; | ||
12 | |||
13 | @include iro.bem-modifier('block') { | ||
14 | display: block; | ||
15 | } | ||
16 | } | ||
17 | |||
18 | @keyframes rotate { | ||
19 | 100% { | ||
20 | transform: rotate(360deg); | ||
21 | } | ||
22 | } | ||
23 | |||
24 | @keyframes dash { | ||
25 | 0% { | ||
26 | stroke-dasharray: 1, 200; | ||
27 | stroke-dashoffset: 0; | ||
28 | } | ||
29 | |||
30 | 50% { | ||
31 | stroke-dasharray: 89, 200; | ||
32 | stroke-dashoffset: -35px; | ||
33 | } | ||
34 | |||
35 | 100% { | ||
36 | stroke-dasharray: 89, 200; | ||
37 | stroke-dashoffset: -124px; | ||
38 | } | ||
39 | } | ||
40 | } | ||
diff --git a/src/objects/_rule.scss b/src/objects/_rule.scss index 74987da..bfd1240 100644 --- a/src/objects/_rule.scss +++ b/src/objects/_rule.scss | |||
@@ -1,6 +1,4 @@ | |||
1 | @use 'iro-sass/src/index' as iro; | 1 | @use 'iro-sass/src/index' as iro; |
2 | @use '../vars'; | ||
3 | @use '../mixins/typography'; | ||
4 | 2 | ||
5 | @include iro.props-namespace('rule') { | 3 | @include iro.props-namespace('rule') { |
6 | @include iro.props-store(( | 4 | @include iro.props-store(( |
diff --git a/src/objects/_text-field.scss b/src/objects/_text-field.scss new file mode 100644 index 0000000..f2c3678 --- /dev/null +++ b/src/objects/_text-field.scss | |||
@@ -0,0 +1,169 @@ | |||
1 | @use 'iro-sass/src/index' as iro; | ||
2 | @use '../vars'; | ||
3 | @use '../mixins/typography'; | ||
4 | |||
5 | @include iro.props-namespace('text-field') { | ||
6 | @include iro.props-store(( | ||
7 | --dims: ( | ||
8 | --padding-x: .6rem, | ||
9 | --padding-y: .5rem, | ||
10 | --border-width: iro.props-get(--dims --border-width --thin, $global: true), | ||
11 | --border-radius: 2px, | ||
12 | |||
13 | --focus: ( | ||
14 | --border-width: iro.props-get(--dims --border-width --medium, $global: true), | ||
15 | ) | ||
16 | ), | ||
17 | --colors: ( | ||
18 | --bg: iro.props-get(--colors --bg-hi2, $global: true), | ||
19 | --placeholder: iro.props-get(--colors --fg-hi2, $global: true), | ||
20 | --text: iro.props-get(--colors --fg, $global: true), | ||
21 | --border: iro.props-get(--colors --obj-lo, $global: true), | ||
22 | --shadow: 0 0 0 0 transparent, | ||
23 | |||
24 | --hover: ( | ||
25 | --border: iro.props-get(--colors --fg-hi2, $global: true), | ||
26 | --shadow: 0 0 0 0 transparent, | ||
27 | ), | ||
28 | --focus: ( | ||
29 | --border: iro.props-get(--colors --accent --primary, $global: true), | ||
30 | --shadow: 0 0 0 0 transparent, | ||
31 | ), | ||
32 | --key-focus: ( | ||
33 | --border: iro.props-get(--colors --focus --fill, $global: true), | ||
34 | --shadow: iro.props-get(--colors --focus --shadow, $global: true), | ||
35 | ), | ||
36 | --error: ( | ||
37 | --border: iro.props-get(--colors --accent --error-hi, $global: true), | ||
38 | --shadow: 0 0 0 0 transparent, | ||
39 | |||
40 | --hover: ( | ||
41 | --border: iro.props-get(--colors --accent --error, $global: true), | ||
42 | --shadow: iro.props-get(--colors --text-input --error --shadow, null), | ||
43 | ), | ||
44 | --focus: ( | ||
45 | --border: iro.props-get(--colors --accent --error, $global: true), | ||
46 | --shadow: iro.props-get(--colors --text-input --error --shadow, null), | ||
47 | ), | ||
48 | ), | ||
49 | --disabled: ( | ||
50 | --bg: iro.props-get(--colors --obj-hi, $global: true), | ||
51 | --placeholder: iro.props-get(--colors --fg-hi3, $global: true), | ||
52 | --text: iro.props-get(--colors --fg-hi3, $global: true), | ||
53 | --border: iro.props-get(--colors --obj-hi, $global: true), | ||
54 | --shadow: 0 0 0 0 transparent, | ||
55 | ), | ||
56 | ), | ||
57 | )); | ||
58 | |||
59 | @include iro.bem-object(iro.props-namespace()) { | ||
60 | position: relative; | ||
61 | min-width: 0; | ||
62 | padding: iro.props-get(--dims --padding-y) iro.props-get(--dims --padding-x); | ||
63 | background-color: iro.props-get(--colors --bg); | ||
64 | |||
65 | @include iro.bem-elem('bg') { | ||
66 | display: block; | ||
67 | position: absolute; | ||
68 | top: 0; | ||
69 | right: 0; | ||
70 | bottom: 0; | ||
71 | left: 0; | ||
72 | border: iro.props-get(--dims --border-width) solid iro.props-get(--colors --border); | ||
73 | border-radius: iro.props-get(--dims --border-radius); | ||
74 | box-shadow: iro.props-get(--colors --shadow); | ||
75 | pointer-events: none; | ||
76 | } | ||
77 | |||
78 | @include iro.bem-elem('input') { | ||
79 | @include typography.set-font(vars.$font--main, (size: 1em, line-height: vars.$line-height)); | ||
80 | |||
81 | display: block; | ||
82 | color: iro.props-get(--colors --text); | ||
83 | resize: none; | ||
84 | |||
85 | &::placeholder { | ||
86 | opacity: 1; | ||
87 | color: iro.props-get(--colors --placeholder); | ||
88 | font-style: italic; | ||
89 | } | ||
90 | |||
91 | &:hover { | ||
92 | @include iro.bem-sibling-elem('bg') { | ||
93 | border-color: iro.props-get(--colors --hover --border); | ||
94 | box-shadow: iro.props-get(--colors --hover --shadow); | ||
95 | } | ||
96 | } | ||
97 | |||
98 | &:focus { | ||
99 | outline: 0; | ||
100 | |||
101 | @include iro.bem-sibling-elem('bg') { | ||
102 | $offset: calc(iro.props-get(--dims --border-width) - iro.props-get(--dims --focus --border-width)); | ||
103 | |||
104 | top: $offset; | ||
105 | right: $offset; | ||
106 | bottom: $offset; | ||
107 | left: $offset; | ||
108 | border: iro.props-get(--dims --focus --border-width) solid iro.props-get(--colors --focus --border); | ||
109 | border-radius: calc(iro.props-get(--dims --border-radius) - $offset); | ||
110 | box-shadow: iro.props-get(--colors --focus --shadow); | ||
111 | } | ||
112 | } | ||
113 | |||
114 | &:invalid { | ||
115 | @include iro.bem-sibling-elem('bg') { | ||
116 | border-color: iro.props-get(--colors --error --border); | ||
117 | box-shadow: iro.props-get(--colors --error --shadow); | ||
118 | } | ||
119 | |||
120 | &:hover { | ||
121 | @include iro.bem-sibling-elem('bg') { | ||
122 | border-color: iro.props-get(--colors --error --hover --border); | ||
123 | box-shadow: iro.props-get(--colors --error --hover --shadow); | ||
124 | } | ||
125 | } | ||
126 | |||
127 | &:focus { | ||
128 | @include iro.bem-sibling-elem('bg') { | ||
129 | border-color: iro.props-get(--colors --error --focus --border); | ||
130 | box-shadow: iro.props-get(--colors --error --focus --shadow); | ||
131 | } | ||
132 | } | ||
133 | } | ||
134 | |||
135 | @include iro.bem-at-theme('keyboard') { | ||
136 | &:focus { | ||
137 | @include iro.bem-sibling-elem('bg') { | ||
138 | border-color: iro.props-get(--colors --key-focus --border); | ||
139 | box-shadow: iro.props-get(--colors --key-focus --shadow); | ||
140 | } | ||
141 | } | ||
142 | } | ||
143 | } | ||
144 | |||
145 | @include iro.bem-modifier('fill') { | ||
146 | padding: 0; | ||
147 | |||
148 | @include iro.bem-elem('input') { | ||
149 | padding: iro.props-get(--dims --padding-y) iro.props-get(--dims --padding-x); | ||
150 | } | ||
151 | } | ||
152 | |||
153 | @include iro.bem-is('disabled') { | ||
154 | background-color: iro.props-get(--colors --disabled --bg); | ||
155 | |||
156 | @include iro.bem-elem('input') { | ||
157 | color: iro.props-get(--colors --disabled --text); | ||
158 | |||
159 | &::placeholder { | ||
160 | color: iro.props-get(--colors --disabled --placeholder); | ||
161 | } | ||
162 | } | ||
163 | |||
164 | @include iro.bem-elem('bg') { | ||
165 | border-color: iro.props-get(--colors --disabled --border); | ||
166 | } | ||
167 | } | ||
168 | } | ||
169 | } | ||
diff --git a/tpl/index.pug b/tpl/index.pug index 47dbc55..7dab86f 100644 --- a/tpl/index.pug +++ b/tpl/index.pug | |||
@@ -6,6 +6,7 @@ include layouts/container.pug | |||
6 | include objects/heading.pug | 6 | include objects/heading.pug |
7 | include objects/rule.pug | 7 | include objects/rule.pug |
8 | include objects/button.pug | 8 | include objects/button.pug |
9 | include objects/text-field.pug | ||
9 | 10 | ||
10 | mixin box | 11 | mixin box |
11 | +container(padX=true padY=true inPage=true theme="raised") | 12 | +container(padX=true padY=true inPage=true theme="raised") |
@@ -21,7 +22,7 @@ html | |||
21 | link(rel="stylesheet" href="style.css") | 22 | link(rel="stylesheet" href="style.css") |
22 | script(src="script.js") | 23 | script(src="script.js") |
23 | 24 | ||
24 | body(class='t-lighter') | 25 | body |
25 | +container(padX=true padY=true narrow=true) | 26 | +container(padX=true padY=true narrow=true) |
26 | 27 | ||
27 | +h1-heading(level='xl')= 'Heading' | 28 | +h1-heading(level='xl')= 'Heading' |
@@ -91,3 +92,32 @@ html | |||
91 | +a-button(variant='secondary' outline=true)= 'Button' | 92 | +a-button(variant='secondary' outline=true)= 'Button' |
92 | = ' ' | 93 | = ' ' |
93 | +a-button(variant='secondary' outline=true disabled=true)= 'Button' | 94 | +a-button(variant='secondary' outline=true disabled=true)= 'Button' |
95 | |||
96 | //----------------------------------------- | ||
97 | |||
98 | +h1-heading(level='xl')= 'Text field' | ||
99 | +rule(level='medium') | ||
100 | |||
101 | +box | ||
102 | +text-field(placeholder='Placeholder') | ||
103 | br | ||
104 | br | ||
105 | +text-field(value='Just landed in L.A.') | ||
106 | br | ||
107 | br | ||
108 | +text-field(value='Readonly' readonly=true) | ||
109 | br | ||
110 | br | ||
111 | +text-field(value='Incorrect input' pattern='a+' required=true) | ||
112 | br | ||
113 | br | ||
114 | +text-field(placeholder='Placeholder' disabled=true) | ||
115 | br | ||
116 | br | ||
117 | +text-field(value='Just landed in L.A.' disabled=true) | ||
118 | br | ||
119 | br | ||
120 | +text-field(value='Readonly' readonly=true disabled=true) | ||
121 | br | ||
122 | br | ||
123 | +text-field(value='Incorrect input' pattern='a+' required=true disabled=true) | ||
diff --git a/tpl/objects/icon.pug b/tpl/objects/icon.pug new file mode 100644 index 0000000..a77a3ed --- /dev/null +++ b/tpl/objects/icon.pug | |||
@@ -0,0 +1,7 @@ | |||
1 | mixin icon(id) | ||
2 | - | ||
3 | let href = '../node_modules/iro-icons/src/icons/' + id + '.svg' | ||
4 | let classes = attributes.class ? attributes.class : '' | ||
5 | |||
6 | svg(class=['o-icon', 'o-icon--iro', 'o-icon--iro-' + id, classes] width='1em' height='1em') | ||
7 | use(xlink:href=href) | ||
diff --git a/tpl/objects/text-field.pug b/tpl/objects/text-field.pug new file mode 100644 index 0000000..9bbe0a1 --- /dev/null +++ b/tpl/objects/text-field.pug | |||
@@ -0,0 +1,13 @@ | |||
1 | include icon.pug | ||
2 | |||
3 | mixin text-field | ||
4 | - | ||
5 | let classes = { | ||
6 | 'o-text-field': true, | ||
7 | 'is-invalid': attributes.invalid, | ||
8 | 'is-disabled': attributes.disabled, | ||
9 | } | ||
10 | |||
11 | div(class=classes) | ||
12 | input(class='o-text-field__input')&attributes(attributes) | ||
13 | .o-text-field__bg | ||