@muonic/muon 0.0.2-experimental-199-2e0610f.0 → 0.0.2-experimental-201-38f9ea8.0

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.
package/CHANGELOG.md CHANGED
@@ -2,6 +2,8 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
4
4
 
5
+ ### [0.0.2-beta.16](https://github.com/centrica-engineering/muon/compare/v0.0.2-beta.15...v0.0.2-beta.16) (2023-05-31)
6
+
5
7
  ### [0.0.2-beta.15](https://github.com/centrica-engineering/muon/compare/v0.0.2-beta.14...v0.0.2-beta.15) (2023-05-24)
6
8
 
7
9
  ### [0.0.2-beta.14](https://github.com/centrica-engineering/muon/compare/v0.0.2-beta.13...v0.0.2-beta.14) (2023-05-23)
@@ -0,0 +1,178 @@
1
+ %label {
2
+ display: inline-block;
3
+ margin-block-start: $INPUTTER_LABEL_MARGIN_BLOCK_START;
4
+ margin-block-end: $INPUTTER_LABEL_MARGIN_BLOCK_END;
5
+ color: $INPUTTER_LABEL_COLOR;
6
+ max-width: $INPUTTER_LABEL_LINE_LENGTH;
7
+ }
8
+
9
+ %placeholder {
10
+ color: $INPUTTER_PLACEHOLDER_COLOR;
11
+ opacity: 1; /* NOTE: This overrides the Firefox user agent style of `opacity: 0.54;` */
12
+ }
13
+
14
+ %input {
15
+ margin: 0; /* NOTE: remove `margin: 2px` Safari user agent */
16
+ padding-block-start: $INPUTTER_FIELD_PADDING_BLOCK_START;
17
+ padding-block-end: $INPUTTER_FIELD_PADDING_BLOCK_END;
18
+ padding-inline-start: $INPUTTER_FIELD_PADDING_INLINE_START;
19
+ padding-inline-end: $INPUTTER_FIELD_PADDING_INLINE_END;
20
+ color: $INPUTTER_FIELD_COLOR;
21
+ line-height: $INPUTTER_FIELD_LINE_HEIGHT;
22
+ background-color: $INPUTTER_FIELD_BACKGROUND_COLOR;
23
+ border-width: $INPUTTER_FIELD_BORDER_WIDTH;
24
+ border-style: $INPUTTER_FIELD_BORDER_STYLE;
25
+ border-color: $INPUTTER_FIELD_BORDER_COLOR;
26
+ border-radius: $INPUTTER_FIELD_BORDER_RADIUS;
27
+ font-family: $INPUTTER_FIELD_FONT_FAMILY;
28
+ font-size: $INPUTTER_FIELD_FONT_SIZE;
29
+ }
30
+
31
+ %input-hover {
32
+ border-color: $INPUTTER_HOVER_BORDER_COLOR;
33
+ color: $INPUTTER_HOVER_COLOR;
34
+ }
35
+
36
+ %input-focus {
37
+ border-color: $INPUTTER_FOCUS_BORDER_COLOR;
38
+ color: $INPUTTER_FOCUS_COLOR;
39
+ outline-color: $INPUTTER_FOCUS_OUTLINE_COLOR;
40
+ outline-offset: $INPUTTER_FOCUS_OUTLINE_OFFSET;
41
+ outline-style: $INPUTTER_FOCUS_OUTLINE_STYLE;
42
+ outline-width: $INPUTTER_FOCUS_OUTLINE_WIDTH;
43
+ }
44
+
45
+ %input-disabled {
46
+ pointer-events: none;
47
+ color: $INPUTTER_DISABLED_COLOR;
48
+ background-color: $INPUTTER_DISABLED_BACKGROUND_COLOR;
49
+ border-color: $INPUTTER_DISABLED_BORDER_COLOR;
50
+ }
51
+
52
+ %input-disabled-placeholder {
53
+ color: $INPUTTER_DISABLED_PLACEHOLDER_COLOR;
54
+ }
55
+
56
+ %label-multiple {
57
+ display: block;
58
+ width: fit-content;
59
+ margin-block-start: revert; /* NOTE: @drew - 2023-05-18 - revert these to use padding instead, could benefit from using a `:not(.multiple)` on line 6 */
60
+ margin-block-end: revert; /* NOTE: @drew - 2023-05-18 - revert these to use padding instead, could benefit from using a `:not(.multiple)` on line 6 */
61
+ padding-inline-start: $INPUTTER_MULTIPLE_LABEL_PADDING_INLINE_START;
62
+ padding-inline-end: $INPUTTER_MULTIPLE_LABEL_PADDING_INLINE_END;
63
+ padding-block-start: $INPUTTER_MULTIPLE_LABEL_PADDING_BLOCK_START;
64
+ padding-block-end: $INPUTTER_MULTIPLE_LABEL_PADDING_BLOCK_END;
65
+ }
66
+
67
+ %label-multiple-hover {
68
+ color: $INPUTTER_HOVER_COLOR;
69
+ }
70
+
71
+ %input-multiple {
72
+ margin: 0; /* NOTE: remove user agent default margin */
73
+ appearance: none; /* NOTE: remove the user agent visual styles for checkbox and radio */
74
+ background-color: $INPUTTER_MULTIPLE_BACKGROUND_COLOR;
75
+ font: inherit; /* NOTE: inheiting font to ensure the use of `em` produces the desired outcome */
76
+ width: $INPUTTER_MULTIPLE_SIZE;
77
+ height: $INPUTTER_MULTIPLE_SIZE;
78
+ border-width: 0.125em; /* NOTE: equal to 2px when font-size is 16px */
79
+ border-style: solid;
80
+ border-color: $INPUTTER_MULTIPLE_BORDER_COLOR;
81
+ display: grid; /* NOTE: setting `display: grid` to position the `::before` */
82
+ place-content: center; /* NOTE: placing the content of grid in the centre */
83
+ }
84
+
85
+ %input-multiple-hover {
86
+ background-color: $INPUTTER_MULTIPLE_HOVER_BACKGROUND_COLOR;
87
+ border-color: $INPUTTER_MULTIPLE_HOVER_BORDER_COLOR;
88
+ }
89
+
90
+ %input-multiple-focus {
91
+ border-color: $INPUTTER_FOCUS_BORDER_COLOR;
92
+ outline-color: $INPUTTER_FOCUS_OUTLINE_COLOR;
93
+ outline-offset: $INPUTTER_FOCUS_OUTLINE_OFFSET;
94
+ outline-style: $INPUTTER_FOCUS_OUTLINE_STYLE;
95
+ outline-width: $INPUTTER_FOCUS_OUTLINE_WIDTH;
96
+ }
97
+
98
+ %input-multiple-disabled {
99
+ pointer-events: none;
100
+ background-color: $INPUTTER_MULTIPLE_DISABLED_BACKGROUND_COLOR;
101
+ border-color: $INPUTTER_MULTIPLE_DISABLED_BORDER_COLOR;
102
+ }
103
+
104
+ %input-checkbox {
105
+ border-radius: $INPUTTER_MULTIPLE_CHECKBOX_BORDER_RADIUS;
106
+ }
107
+
108
+ %input-radio {
109
+ border-radius: 50%;
110
+ }
111
+
112
+ %input-radio-checked-before {
113
+ content: "";
114
+ width: 0;
115
+ height: 0;
116
+ border-width: $INPUTTER_MULTIPLE_RADIO_DOT_SIZE;
117
+ border-style: solid;
118
+ border-color: $INPUTTER_MULTIPLE_RADIO_DOT_COLOR;
119
+ border-radius: 50%;
120
+ }
121
+
122
+ %input-checkbox-checked-before {
123
+ content: "";
124
+ width: $INPUTTER_MULTIPLE_CHECKBOX_CHECK_WIDTH;
125
+ height: $INPUTTER_MULTIPLE_CHECKBOX_CHECK_HEIGHT;
126
+ border-width: $INPUTTER_MULTIPLE_CHECKBOX_CHECK_SIZE;
127
+ border-style: solid;
128
+ border-color: $INPUTTER_MULTIPLE_CHECKBOX_CHECK_COLOR;
129
+ border-top: unset;
130
+ border-right-style: solid;
131
+ border-bottom-style: solid;
132
+ border-left: unset;
133
+ transform: translateY(-10%) rotate(45deg);
134
+ }
135
+
136
+ %input-select {
137
+ appearance: none; /* NOTE: remove the user agent visual styles */
138
+ padding-inline-end: $INPUTTER_FIELD_ICON_SPACER;
139
+ }
140
+
141
+ %input-search {
142
+ padding-inline-start: $INPUTTER_FIELD_ICON_SPACER;
143
+ }
144
+
145
+ %input-textarea {
146
+ display: block; /* NOTE: this is to remove the additional space at the bottom of `textarea` */
147
+ }
148
+
149
+ %input-mask {
150
+ width: calc(
151
+ (var(--maxlength))
152
+ * 1ch
153
+ + $INPUTTER_FIELD_PADDING_INLINE_START
154
+ + $INPUTTER_FIELD_PADDING_INLINE_END
155
+ + $INPUTTER_FIELD_BORDER_WIDTH
156
+ + $INPUTTER_FIELD_BORDER_WIDTH
157
+ );
158
+ font-family: $INPUTTER_MASK_FONT_FAMILY;
159
+ }
160
+
161
+ %input-mask-text {
162
+ font-weight: $INPUTTER_MASK_FONT_WEIGHT;
163
+ }
164
+
165
+ %input-validation {
166
+ display: flex;
167
+ align-items: center;
168
+ column-gap: $INPUTTER_VALIDATION_GAP;
169
+ width: fit-content;
170
+ margin-block-start: $INPUTTER_VALIDATION_MARGIN_BLOCK;
171
+ color: $INPUTTER_VALIDATION_WARNING_COLOR;
172
+ font-size: $INPUTTER_VALIDATION_FONT_SIZE;
173
+
174
+ & .icon {
175
+ width: $INPUTTER_VALIDATION_ICON_SIZE;
176
+ flex-shrink: 0;
177
+ }
178
+ }
@@ -1,19 +1,15 @@
1
1
  @import "@muonic/muon/css/default.css";
2
+ @import "./inputter-extends.css";
2
3
 
3
4
  :host {
4
5
  display: block;
5
6
 
6
7
  & ::slotted(label) {
7
- display: inline-block;
8
- margin-block-start: $INPUTTER_LABEL_MARGIN_BLOCK_START;
9
- margin-block-end: $INPUTTER_LABEL_MARGIN_BLOCK_END;
10
- color: $INPUTTER_LABEL_COLOR;
11
- max-width: $INPUTTER_LABEL_LINE_LENGTH;
8
+ @extend %label;
12
9
  }
13
10
 
14
11
  & ::slotted(*)::placeholder {
15
- color: $INPUTTER_PLACEHOLDER_COLOR;
16
- opacity: 1; /* NOTE: This overrides the Firefox user agent style of `opacity: 0.54;` */
12
+ @extend %placeholder;
17
13
  }
18
14
 
19
15
  & ::slotted(:is(
@@ -26,20 +22,7 @@
26
22
  input[type="text"],
27
23
  select,
28
24
  textarea)) {
29
- margin: 0; /* NOTE: remove `margin: 2px` Safari user agent */
30
- padding-block-start: $INPUTTER_FIELD_PADDING_BLOCK_START;
31
- padding-block-end: $INPUTTER_FIELD_PADDING_BLOCK_END;
32
- padding-inline-start: $INPUTTER_FIELD_PADDING_INLINE_START;
33
- padding-inline-end: $INPUTTER_FIELD_PADDING_INLINE_END;
34
- color: $INPUTTER_FIELD_COLOR;
35
- line-height: $INPUTTER_FIELD_LINE_HEIGHT;
36
- background-color: $INPUTTER_FIELD_BACKGROUND_COLOR;
37
- border-width: $INPUTTER_FIELD_BORDER_WIDTH;
38
- border-style: $INPUTTER_FIELD_BORDER_STYLE;
39
- border-color: $INPUTTER_FIELD_BORDER_COLOR;
40
- border-radius: $INPUTTER_FIELD_BORDER_RADIUS;
41
- font-family: $INPUTTER_FIELD_FONT_FAMILY;
42
- font-size: $INPUTTER_FIELD_FONT_SIZE;
25
+ @extend %input;
43
26
  }
44
27
 
45
28
  & ::slotted(:is(
@@ -52,8 +35,7 @@
52
35
  input[type="text"]:hover,
53
36
  select:hover,
54
37
  textarea:hover)) {
55
- border-color: $INPUTTER_HOVER_BORDER_COLOR;
56
- color: $INPUTTER_HOVER_COLOR;
38
+ @extend %input-hover;
57
39
  }
58
40
 
59
41
  & ::slotted(:is(
@@ -66,12 +48,7 @@
66
48
  input[type="text"]:focus,
67
49
  select:focus,
68
50
  textarea:focus)) {
69
- border-color: $INPUTTER_FOCUS_BORDER_COLOR;
70
- color: $INPUTTER_FOCUS_COLOR;
71
- outline-color: $INPUTTER_FOCUS_OUTLINE_COLOR;
72
- outline-offset: $INPUTTER_FOCUS_OUTLINE_OFFSET;
73
- outline-style: $INPUTTER_FOCUS_OUTLINE_STYLE;
74
- outline-width: $INPUTTER_FOCUS_OUTLINE_WIDTH;
51
+ @extend %input-focus;
75
52
  }
76
53
 
77
54
  & .has-disabled {
@@ -85,14 +62,11 @@
85
62
  input[type="text"]:disabled,
86
63
  select:disabled,
87
64
  textarea:disabled)) {
88
- pointer-events: none;
89
- color: $INPUTTER_DISABLED_COLOR;
90
- background-color: $INPUTTER_DISABLED_BACKGROUND_COLOR;
91
- border-color: $INPUTTER_DISABLED_BORDER_COLOR;
65
+ @extend %input-disabled;
92
66
  }
93
67
 
94
68
  & ::slotted(*:disabled)::placeholder {
95
- color: $INPUTTER_DISABLED_PLACEHOLDER_COLOR;
69
+ @extend %placeholder-disabled;
96
70
  }
97
71
  }
98
72
 
@@ -112,91 +86,51 @@
112
86
  & ::slotted(:is(
113
87
  input[type="checkbox"],
114
88
  input[type="radio"])) {
115
- margin: 0; /* NOTE: remove user agent default margin */
116
- appearance: none; /* NOTE: remove the user agent visual styles for checkbox and radio */
117
- background-color: $INPUTTER_MULTIPLE_BACKGROUND_COLOR;
118
- font: inherit; /* NOTE: inheiting font to ensure the use of `em` produces the desired outcome */
119
- width: $INPUTTER_MULTIPLE_SIZE;
120
- height: $INPUTTER_MULTIPLE_SIZE;
121
- border-width: 0.125em; /* NOTE: equal to 2px when font-size is 16px */
122
- border-style: solid;
123
- border-color: $INPUTTER_MULTIPLE_BORDER_COLOR;
124
- display: grid; /* NOTE: setting `display: grid` to position the `::before` */
125
- place-content: center; /* NOTE: placing the content of grid in the centre */
89
+ @extend %input-multiple;
126
90
  }
127
91
 
128
92
  & ::slotted(:is(
129
93
  input[type="checkbox"]:hover,
130
94
  input[type="radio"]:hover)) {
131
- background-color: $INPUTTER_MULTIPLE_HOVER_BACKGROUND_COLOR;
132
- border-color: $INPUTTER_MULTIPLE_HOVER_BORDER_COLOR;
95
+ @extend %input-multiple-hover;
133
96
  }
134
97
 
135
98
  & ::slotted(:is(
136
99
  input[type="checkbox"]:focus-visible,
137
100
  input[type="radio"]:focus-visible)) {
138
- border-color: $INPUTTER_FOCUS_BORDER_COLOR;
139
- outline-color: $INPUTTER_FOCUS_OUTLINE_COLOR;
140
- outline-offset: $INPUTTER_FOCUS_OUTLINE_OFFSET;
141
- outline-style: $INPUTTER_FOCUS_OUTLINE_STYLE;
142
- outline-width: $INPUTTER_FOCUS_OUTLINE_WIDTH;
101
+ @extend %input-multiple-focus;
143
102
  }
144
103
 
145
104
  &.has-disabled {
146
105
  & ::slotted(:is(
147
106
  input[type="checkbox"]:disabled,
148
107
  input[type="radio"]:disabled)) {
149
- pointer-events: none;
150
- background-color: $INPUTTER_DISABLED_BACKGROUND_COLOR;
151
- border-color: $INPUTTER_DISABLED_BORDER_COLOR;
108
+ @extend %input-multiple-disabled;
152
109
  }
153
110
  }
154
111
 
155
112
  & ::slotted(input[type="checkbox"]) {
156
- border-radius: $INPUTTER_MULTIPLE_CHECKBOX_BORDER_RADIUS;
113
+ @extend %input-checkbox;
157
114
  }
158
115
 
159
116
  & ::slotted(input[type="radio"]) {
160
- border-radius: 50%;
117
+ @extend %input-radio;
161
118
  }
162
119
 
163
120
  & ::slotted(input[type="radio"]:checked)::before {
164
- content: "";
165
- width: 0;
166
- height: 0;
167
- border-width: $INPUTTER_MULTIPLE_RADIO_DOT_SIZE;
168
- border-style: solid;
169
- border-color: $INPUTTER_MULTIPLE_RADIO_DOT_COLOR;
170
- border-radius: 50%;
121
+ @extend %input-radio-checked-before;
171
122
  }
172
123
 
173
124
  & ::slotted(input[type="checkbox"]:checked)::before {
174
- content: "";
175
- width: $INPUTTER_MULTIPLE_CHECKBOX_CHECK_WIDTH;
176
- height: $INPUTTER_MULTIPLE_CHECKBOX_CHECK_HEIGHT;
177
- border-width: $INPUTTER_MULTIPLE_CHECKBOX_CHECK_SIZE;
178
- border-style: solid;
179
- border-color: $INPUTTER_MULTIPLE_CHECKBOX_CHECK_COLOR;
180
- border-top: unset;
181
- border-right-style: solid;
182
- border-bottom-style: solid;
183
- border-left: unset;
184
- transform: translateY(-10%) rotate(45deg);
125
+ @extend %input-checkbox-checked-before;
185
126
  }
186
127
 
187
128
  & ::slotted(label) {
188
- display: block;
189
- width: fit-content;
190
- margin-block-start: revert; /* NOTE: @drew - 2023-05-18 - revert these to use padding instead, could benefit from using a `:not(.multiple)` on line 6 */
191
- margin-block-end: revert; /* NOTE: @drew - 2023-05-18 - revert these to use padding instead, could benefit from using a `:not(.multiple)` on line 6 */
192
- padding-inline-start: $INPUTTER_MULTIPLE_LABEL_PADDING_INLINE_START;
193
- padding-inline-end: $INPUTTER_MULTIPLE_LABEL_PADDING_INLINE_END;
194
- padding-block-start: $INPUTTER_MULTIPLE_LABEL_PADDING_BLOCK_START;
195
- padding-block-end: $INPUTTER_MULTIPLE_LABEL_PADDING_BLOCK_END;
129
+ @extend %label-multiple;
196
130
  }
197
131
 
198
132
  & ::slotted(label:hover) {
199
- color: $INPUTTER_HOVER_COLOR;
133
+ @extend %label-multiple-hover;
200
134
  }
201
135
  }
202
136
 
@@ -204,16 +138,15 @@
204
138
  & ::slotted(:is(
205
139
  select,
206
140
  input[type="date"])) {
207
- appearance: none; /* NOTE: remove the user agent visual styles */
208
- padding-inline-end: $INPUTTER_FIELD_ICON_SPACER;
141
+ @extend %input-select;
209
142
  }
210
143
 
211
144
  & ::slotted(input[type="search"]) {
212
- padding-inline-start: $INPUTTER_FIELD_ICON_SPACER;
145
+ @extend %input-search;
213
146
  }
214
147
 
215
148
  & ::slotted(textarea) {
216
- display: block; /* NOTE: this is to remove the additional space at the bottom of `textarea` */
149
+ @extend %input-textarea;
217
150
  }
218
151
  /* stylelint-enable no-descending-specificity */
219
152
 
@@ -261,15 +194,7 @@
261
194
  input[type="search"],
262
195
  input[type="tel"],
263
196
  input[type="text"])) {
264
- width: calc(
265
- (var(--maxlength))
266
- * 1ch
267
- + $INPUTTER_FIELD_PADDING_INLINE_START
268
- + $INPUTTER_FIELD_PADDING_INLINE_END
269
- + $INPUTTER_FIELD_BORDER_WIDTH
270
- + $INPUTTER_FIELD_BORDER_WIDTH
271
- );
272
- font-family: $INPUTTER_MASK_FONT_FAMILY;
197
+ @extend %input-mask;
273
198
  }
274
199
 
275
200
  & .input-mask {
@@ -294,23 +219,12 @@
294
219
  }
295
220
 
296
221
  & ::slotted(input[type="text"]) {
297
- font-weight: $INPUTTER_MASK_FONT_WEIGHT;
222
+ @extend %input-mask-text;
298
223
  }
299
224
  }
300
225
 
301
226
  & .validation {
302
- display: flex;
303
- align-items: center;
304
- column-gap: $INPUTTER_VALIDATION_GAP;
305
- width: fit-content;
306
- margin-block-start: $INPUTTER_VALIDATION_MARGIN_BLOCK;
307
- color: $INPUTTER_VALIDATION_WARNING_COLOR;
308
- font-size: $INPUTTER_VALIDATION_FONT_SIZE;
309
-
310
- & .icon {
311
- width: $INPUTTER_VALIDATION_ICON_SIZE;
312
- flex-shrink: 0;
313
- }
227
+ @extend %input-validation;
314
228
  }
315
229
 
316
230
  & .helper {
@@ -1,4 +1,6 @@
1
- :host {
1
+ @import "./inputter-extends.css";
2
+
3
+ light-dom {
2
4
  /* NOTE: targeting Safari only */
3
5
  @media not all and (min-resolution: 0.001dpcm) { /* stylelint-disable-line media-feature-range-notation */
4
6
  /*
@@ -61,4 +63,154 @@
61
63
  width: 2rem;
62
64
  }
63
65
  }
66
+
67
+ & label {
68
+ @extend %label;
69
+ }
70
+
71
+ & *::placeholder {
72
+ @extend %placeholder;
73
+ }
74
+
75
+ & :is(
76
+ input[type="date"],
77
+ input[type="email"],
78
+ input[type="number"],
79
+ input[type="password"],
80
+ input[type="search"],
81
+ input[type="tel"],
82
+ input[type="text"],
83
+ select,
84
+ textarea) {
85
+ @extend %input;
86
+ }
87
+
88
+ & :is(
89
+ input[type="date"]:hover,
90
+ input[type="email"]:hover,
91
+ input[type="number"]:hover,
92
+ input[type="password"]:hover,
93
+ input[type="search"]:hover,
94
+ input[type="tel"]:hover,
95
+ input[type="text"]:hover,
96
+ select:hover,
97
+ textarea:hover) {
98
+ @extend %input-hover;
99
+ }
100
+
101
+ & :is(
102
+ input[type="date"]:focus,
103
+ input[type="email"]:focus,
104
+ input[type="number"]:focus,
105
+ input[type="password"]:focus,
106
+ input[type="search"]:focus,
107
+ input[type="tel"]:focus,
108
+ input[type="text"]:focus,
109
+ select:focus,
110
+ textarea:focus) {
111
+ @extend %input-focus;
112
+ }
113
+
114
+ /* @TODO: configure how to remove if disable off */
115
+ & :is(
116
+ input[type="date"]:disabled,
117
+ input[type="email"]:disabled,
118
+ input[type="number"]:disabled,
119
+ input[type="password"]:disabled,
120
+ input[type="search"]:disabled,
121
+ input[type="tel"]:disabled,
122
+ input[type="text"]:disabled,
123
+ select:disabled,
124
+ textarea:disabled
125
+ ) {
126
+ @extend %input-disabled;
127
+ }
128
+
129
+ & *:disabled::placeholder {
130
+ @extend %placeholder-disabled;
131
+ }
132
+
133
+ & :is(
134
+ input[type="checkbox"],
135
+ input[type="radio"]
136
+ ) {
137
+ @extend %input-multiple;
138
+ }
139
+
140
+ & :is(
141
+ input[type="checkbox"]:hover,
142
+ input[type="radio"]:hover
143
+ ) {
144
+ @extend %input-multiple-hover;
145
+ }
146
+
147
+ & :is(
148
+ input[type="checkbox"]:focus-visible,
149
+ input[type="radio"]:focus-visible
150
+ ) {
151
+ @extend %input-multiple-focus;
152
+ }
153
+
154
+ /* @TODO: configure how to remove if disable off */
155
+ & :is(
156
+ input[type="checkbox"]:disabled,
157
+ input[type="radio"]:disabled
158
+ ) {
159
+ @extend %input-multiple-disabled;
160
+ }
161
+
162
+ & input[type="checkbox"] {
163
+ @extend %input-checkbox;
164
+ }
165
+
166
+ & input[type="radio"] {
167
+ @extend %input-radio;
168
+ }
169
+
170
+ & input[type="radio"]:checked::before {
171
+ @extend %input-radio-checked-before;
172
+ }
173
+
174
+ & input[type="checkbox"]:checked::before {
175
+ @extend %input-checkbox-checked-before;
176
+ }
177
+
178
+ & :is(input[type="checkbox"], input[type="radio"]) + label {
179
+ @extend %label-multiple;
180
+ }
181
+
182
+ & :is(input[type="checkbox"], input[type="radio"]) + label:hover {
183
+ @extend %label-multiple-hover;
184
+ }
185
+
186
+ & :is(
187
+ select,
188
+ input[type="date"]
189
+ ) {
190
+ @extend %input-select;
191
+ }
192
+
193
+ & input[type="search"] {
194
+ @extend %input-search;
195
+ }
196
+
197
+ & textarea {
198
+ @extend %input-textarea;
199
+ }
200
+
201
+ &[mask] {
202
+ & :is(
203
+ input[type="email"],
204
+ input[type="number"],
205
+ input[type="search"],
206
+ input[type="tel"],
207
+ input[type="text"]
208
+ ) {
209
+ @extend %input-mask;
210
+ }
211
+
212
+ & input[type="text"] {
213
+ @extend %input-mask-text;
214
+ }
215
+ }
64
216
  }
@@ -47,45 +47,54 @@ export const MuonElementMixin = (superClass) => class extends superClass {
47
47
  return undefined;
48
48
  }
49
49
 
50
- const clonedCSS = Object.assign({}, css);
51
- const nodeName = this.nodeName.toLowerCase();
52
- const parentNode = this.getRootNode();
53
- const parentNodeType = parentNode.nodeName;
54
- const styleName = `${nodeName}-styles`;
55
-
56
- // First need to replace `light-dom` with the component name
57
- clonedCSS.cssText = clonedCSS.cssText.replace(/light-dom/g, nodeName);
58
-
59
- // How we add the styles depends on where it is being added, HTMLDocument or another ShadowDom.
60
- // If the Document we don't want to add multiple times
61
- if (parentNodeType === '#document-fragment') {
62
- // If it is within a shadowDom
63
- let stylesAdded;
64
-
65
- if (supportsAdoptingStyleSheets) {
66
- const stylesheet = new CSSStyleSheet();
67
-
68
- stylesheet.replaceSync(clonedCSS.cssText);
69
- stylesAdded = [...parentNode.adoptedStyleSheets, stylesheet];
70
- } else {
71
- stylesAdded = [clonedCSS];
72
- }
73
-
74
- adoptStyles(parentNode, stylesAdded);
75
- } else if (parentNodeType === '#document') {
76
- // If it is in the parent DOM
77
- const styleSheets = parentNode.styleSheets;
78
-
79
- if (!Array.from(checkSheets(styleSheets, styleName)).length > 0) {
80
- const style = document.createElement('style');
81
- style.innerHTML = String.raw`${clonedCSS.cssText}`;
82
- style.title = styleName;
83
- document.head.appendChild(style);
50
+ const addStyles = (css, key = 0) => {
51
+ const clonedCSS = Object.assign({}, css);
52
+ const nodeName = this.nodeName.toLowerCase();
53
+ const parentNode = this.getRootNode();
54
+ const parentNodeType = parentNode.nodeName;
55
+ const styleName = key > 0 ? `${nodeName}-styles-${key}` : `${nodeName}-styles`;
56
+
57
+ // First need to replace `light-dom` with the component name
58
+ clonedCSS.cssText = clonedCSS.cssText.replace(/light-dom/g, nodeName);
59
+
60
+ // How we add the styles depends on where it is being added, HTMLDocument or another ShadowDom.
61
+ // If the Document we don't want to add multiple times
62
+ if (parentNodeType === '#document-fragment') {
63
+ // If it is within a shadowDom
64
+ let stylesAdded;
65
+
66
+ if (supportsAdoptingStyleSheets) {
67
+ const stylesheet = new CSSStyleSheet();
68
+
69
+ stylesheet.replaceSync(clonedCSS.cssText);
70
+ stylesAdded = [...parentNode.adoptedStyleSheets, stylesheet];
71
+ } else {
72
+ stylesAdded = [clonedCSS];
73
+ }
74
+
75
+ adoptStyles(parentNode, stylesAdded);
76
+ } else if (parentNodeType === '#document') {
77
+ // If it is in the parent DOM
78
+ const styleSheets = parentNode.styleSheets;
79
+
80
+ if (!Array.from(checkSheets(styleSheets, styleName)).length > 0) {
81
+ const style = document.createElement('style');
82
+ style.innerHTML = String.raw`${clonedCSS.cssText}`;
83
+ style.title = styleName;
84
+ document.head.appendChild(style);
85
+ }
84
86
  }
87
+ };
88
+
89
+ if (Array.isArray(css)) {
90
+ css.forEach((style, key) => {
91
+ addStyles(style, key);
92
+ });
93
+ } else {
94
+ addStyles(css);
85
95
  }
86
96
 
87
- return clonedCSS;
88
-
97
+ return true;
89
98
  });
90
99
  return undefined;
91
100
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@muonic/muon",
3
- "version": "0.0.2-experimental-199-2e0610f.0",
3
+ "version": "0.0.2-experimental-201-38f9ea8.0",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -4,7 +4,7 @@ export const snapshots = {};
4
4
  snapshots["icon implements standard self"] =
5
5
  `<div
6
6
  aria-hidden="true"
7
- class="icon standard"
7
+ class="arrow-right icon"
8
8
  >
9
9
  </div>
10
10
  `;
@@ -13,7 +13,7 @@ snapshots["icon implements standard self"] =
13
13
  snapshots["icon no anonymous slot"] =
14
14
  `<div
15
15
  aria-hidden="true"
16
- class="icon standard"
16
+ class="arrow-right icon"
17
17
  >
18
18
  </div>
19
19
  `;
@@ -32,7 +32,7 @@ snapshots["icon implements icon size"] =
32
32
  snapshots["icon select icon name"] =
33
33
  `<div
34
34
  aria-hidden="true"
35
- class="icon standard"
35
+ class="arrow-left icon"
36
36
  >
37
37
  </div>
38
38
  `;
@@ -51,7 +51,7 @@ snapshots["icon fails gracefully when using non existent type"] =
51
51
  snapshots["icon fails gracefully when using non existent name"] =
52
52
  `<div
53
53
  aria-hidden="true"
54
- class="icon standard"
54
+ class="icon this-does-not-exist-as-an-icon-sad-face"
55
55
  >
56
56
  </div>
57
57
  `;
@@ -71,7 +71,7 @@ snapshots["icon adds aria-label when describe used"] =
71
71
  snapshots["icon adds attributes for when describe used"] =
72
72
  `<div
73
73
  aria-label="foobar"
74
- class="icon standard"
74
+ class="arrow-right icon"
75
75
  role="img"
76
76
  >
77
77
  </div>
@@ -81,7 +81,7 @@ snapshots["icon adds attributes for when describe used"] =
81
81
  snapshots["icon caches not available"] =
82
82
  `<div
83
83
  aria-hidden="true"
84
- class="icon standard"
84
+ class="arrow-right icon"
85
85
  >
86
86
  </div>
87
87
  `;
@@ -32,7 +32,7 @@ describe('icon', () => {
32
32
  expect(elementSVG).to.not.be.null; // eslint-disable-line no-unused-expressions
33
33
  expect(el.type).to.equal('standard', '`type` property has default value `standard`');
34
34
  expect(el.name).to.equal('arrow-right', '`name` property has default value `arrow-right`');
35
- expect(Array.from(icon.classList)).to.deep.equal(['icon', 'standard'], 'class list for parent div');
35
+ expect(Array.from(icon.classList)).to.deep.equal(['icon', 'arrow-right'], 'class list for parent div');
36
36
  expect(icon.getAttribute('aria-hidden')).to.equal('true', '`aria-hidden` attribute added to not be seen by screen readers');
37
37
  expect(icon.getAttribute('aria-label')).to.equal(null, '`aria-label` not added');
38
38
  expect(icon.getAttribute('role')).to.equal(null, 'no `role` attribute added');