@shortfuse/materialdesignweb 0.4.0 → 0.5.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.
Files changed (184) hide show
  1. package/.browserslistrc +2 -1
  2. package/.eslintrc.json +59 -8
  3. package/.stylelintrc.json +94 -49
  4. package/CHANGELOG.md +12 -0
  5. package/README.md +1 -3
  6. package/adapters/datatable/column.js +27 -54
  7. package/adapters/datatable/index.js +69 -81
  8. package/adapters/dom/index.js +32 -47
  9. package/adapters/search/index.js +107 -133
  10. package/components/appbar/_spec.scss +77 -137
  11. package/components/banner/_spec.scss +28 -63
  12. package/components/bottomnav/_spec.scss +46 -54
  13. package/components/bottomnav/index.js +15 -20
  14. package/components/bottomnav/item.js +4 -5
  15. package/components/button/README.md +1 -1
  16. package/components/button/_spec.scss +43 -42
  17. package/components/button/_theme.scss +27 -50
  18. package/components/card/_spec.scss +61 -69
  19. package/components/chip/_spec.scss +21 -44
  20. package/components/chip/_theme.scss +79 -151
  21. package/components/chip/index.js +6 -4
  22. package/components/datatable/_spec.scss +36 -99
  23. package/components/datatable/_theme.scss +98 -124
  24. package/components/datatable/cell.js +1 -2
  25. package/components/datatable/columnheader.js +1 -2
  26. package/components/datatable/index.js +33 -47
  27. package/components/datatable/row.js +4 -5
  28. package/components/dialog/_spec.scss +53 -63
  29. package/components/dialog/_theme.scss +7 -0
  30. package/components/dialog/index.js +62 -88
  31. package/components/divider/_spec.scss +6 -8
  32. package/components/elevation/_spec.scss +1 -1
  33. package/components/fab/_spec.scss +30 -42
  34. package/components/fab/index.js +4 -8
  35. package/components/grid/_spec.scss +68 -211
  36. package/components/layout/_mixins.scss +0 -22
  37. package/components/layout/_spec.scss +267 -363
  38. package/components/layout/_theme.scss +10 -35
  39. package/components/layout/index.js +40 -50
  40. package/components/list/_spec.scss +57 -91
  41. package/components/list/_theme.scss +75 -84
  42. package/components/list/content.js +9 -13
  43. package/components/list/index.js +34 -38
  44. package/components/list/item.js +8 -11
  45. package/components/list/secondary.js +8 -9
  46. package/components/menu/_spec.scss +134 -167
  47. package/components/menu/index.js +45 -61
  48. package/components/menu/item.js +11 -19
  49. package/components/progress/_spec.scss +43 -34
  50. package/components/selection/_spec.scss +123 -133
  51. package/components/selection/_theme.scss +88 -120
  52. package/components/selection/index.js +9 -15
  53. package/components/selection/input.js +3 -5
  54. package/components/selection/radiogroup.js +8 -15
  55. package/components/slider/_spec.scss +23 -28
  56. package/components/snackbar/_spec.scss +17 -62
  57. package/components/snackbar/index.js +15 -21
  58. package/components/tab/_spec.scss +35 -50
  59. package/components/tab/content.js +33 -28
  60. package/components/tab/index.js +30 -33
  61. package/components/tab/item.js +4 -5
  62. package/components/tab/list.js +22 -36
  63. package/components/textfield/README.md +2 -2
  64. package/components/textfield/_spec.scss +241 -287
  65. package/components/textfield/_theme.scss +197 -232
  66. package/components/textfield/index.js +8 -16
  67. package/components/tooltip/_spec.scss +23 -26
  68. package/components/type/_spec.scss +19 -16
  69. package/core/_breakpoint.scss +33 -33
  70. package/core/_elevation.scss +40 -0
  71. package/core/_length.scss +0 -1
  72. package/core/_platform.scss +0 -22
  73. package/core/_type.scss +7 -6
  74. package/core/aria/button.js +4 -5
  75. package/core/aria/keyboard.js +1 -2
  76. package/core/aria/rovingtabindex.js +14 -17
  77. package/core/aria/tab.js +1 -2
  78. package/core/dom.js +18 -109
  79. package/core/overlay/_spec.scss +5 -8
  80. package/core/overlay/_theme.scss +126 -150
  81. package/core/overlay/index.js +19 -32
  82. package/core/ripple/_spec.scss +16 -17
  83. package/core/ripple/_theme.scss +13 -33
  84. package/core/ripple/index.js +36 -44
  85. package/core/theme/_aliases.scss +15 -0
  86. package/core/theme/_config.scss +8 -2
  87. package/core/theme/_functions.scss +22 -0
  88. package/core/theme/_palettes.scss +0 -1
  89. package/core/{color → theme}/_spec.scss +0 -0
  90. package/core/theme/_theme.scss +268 -0
  91. package/core/theme/index.scss +4 -0
  92. package/core/transition/index.js +73 -76
  93. package/docs/_flex.scss +7 -1
  94. package/docs/_menuoptions.js +2 -2
  95. package/docs/_partials/_appbar.eta +12 -14
  96. package/docs/_partials/_header.eta +41 -44
  97. package/docs/_sample-utils.js +15 -20
  98. package/docs/docs.scss +123 -87
  99. package/docs/framework.scss +26 -0
  100. package/docs/index.eta +2 -6
  101. package/docs/index.js +7 -0
  102. package/docs/pages/appbar.eta +22 -28
  103. package/docs/pages/bottomnav.js +17 -14
  104. package/docs/pages/button.js +10 -10
  105. package/docs/pages/card.js +20 -22
  106. package/docs/pages/chip.js +11 -13
  107. package/docs/pages/color.js +35 -36
  108. package/docs/pages/datatable.js +11 -15
  109. package/docs/pages/dialog.eta +9 -11
  110. package/docs/pages/dialog.js +6 -9
  111. package/docs/pages/dom.js +6 -9
  112. package/docs/pages/elevation.eta +10 -10
  113. package/docs/pages/fab.js +2 -3
  114. package/docs/pages/grid.js +5 -5
  115. package/docs/pages/list.js +1 -2
  116. package/docs/pages/menu.eta +17 -19
  117. package/docs/pages/menu.js +7 -11
  118. package/docs/pages/overlay.js +1 -2
  119. package/docs/pages/progress.eta +2 -2
  120. package/docs/pages/progress.js +1 -1
  121. package/docs/pages/ripple.js +1 -2
  122. package/docs/pages/search.eta +20 -24
  123. package/docs/pages/search.js +24 -41
  124. package/docs/pages/selection.eta +2 -6
  125. package/docs/pages/selection.js +3 -4
  126. package/docs/pages/snackbar.js +3 -4
  127. package/docs/pages/tab.eta +61 -75
  128. package/docs/pages/tab.js +16 -15
  129. package/docs/pages/textfield.eta +9 -8
  130. package/docs/pages/textfield.js +26 -23
  131. package/docs/pages/tooltip.eta +10 -12
  132. package/docs/pages/transition.js +5 -7
  133. package/docs/postrender.js +7 -5
  134. package/docs/pwa/pwa.eta +14 -16
  135. package/docs/pwa/pwa.js +19 -27
  136. package/docs/pwa/pwa.scss +12 -7
  137. package/docs/themes/theme-colored.scss +9 -11
  138. package/docs/themes/theme-default.scss +0 -14
  139. package/index.scss +27 -0
  140. package/jsconfig.json +7 -3
  141. package/package.json +26 -15
  142. package/tsconfig.json +16 -0
  143. package/{webpack.config.cjs → webpack.config.js} +105 -58
  144. package/components/template/_theme.scss +0 -27
  145. package/components/textfield/_mixins.scss +0 -52
  146. package/core/color/_theme.scss +0 -390
  147. package/core/color/index.scss +0 -2
  148. package/core/theme/_mixins.scss +0 -172
  149. package/core/theme/_variables.scss +0 -24
  150. package/docs/_mixins.pug +0 -155
  151. package/docs/pages/appbar.pug +0 -78
  152. package/docs/pages/bottomnav.pug +0 -137
  153. package/docs/pages/button.pug +0 -121
  154. package/docs/pages/card.pug +0 -74
  155. package/docs/pages/chip.pug +0 -91
  156. package/docs/pages/color.pug +0 -121
  157. package/docs/pages/datatable.pug +0 -283
  158. package/docs/pages/dialog.pug +0 -132
  159. package/docs/pages/dom.pug +0 -22
  160. package/docs/pages/elevation.pug +0 -25
  161. package/docs/pages/fab.pug +0 -66
  162. package/docs/pages/grid.pug +0 -95
  163. package/docs/pages/layout.pug +0 -7
  164. package/docs/pages/list.pug +0 -326
  165. package/docs/pages/menu.pug +0 -205
  166. package/docs/pages/overlay.pug +0 -55
  167. package/docs/pages/progress.pug +0 -16
  168. package/docs/pages/ripple.pug +0 -21
  169. package/docs/pages/search.pug +0 -165
  170. package/docs/pages/selection.pug +0 -74
  171. package/docs/pages/slider.pug +0 -17
  172. package/docs/pages/snackbar.pug +0 -60
  173. package/docs/pages/tab.pug +0 -304
  174. package/docs/pages/textfield.pug +0 -360
  175. package/docs/pages/tooltip.pug +0 -78
  176. package/docs/pages/transition.pug +0 -76
  177. package/docs/pages/type.pug +0 -29
  178. package/docs/pwa/_dialogs.pug +0 -96
  179. package/docs/pwa/_menus.pug +0 -11
  180. package/docs/pwa/pwa.pug +0 -325
  181. package/docs/spec.scss +0 -26
  182. package/docs/themes/_component-themes.scss +0 -26
  183. package/docs/themes/theme-colored-fallbacks.scss +0 -17
  184. package/docs/themes/theme-default-fallbacks.scss +0 -17
@@ -59,15 +59,13 @@ $touchUpAcceleration: 3400 !default;
59
59
 
60
60
  .mdw-ripple__container {
61
61
  position: absolute;
62
- top: 0;
63
- right: 0;
64
- bottom: 0;
65
- left: 0;
62
+ inset: 0;
66
63
  overflow: hidden;
67
-
64
+
68
65
  box-sizing: border-box;
69
66
 
70
67
  pointer-events: none;
68
+
71
69
  z-index: 1;
72
70
 
73
71
  border-radius: inherit;
@@ -77,6 +75,8 @@ $touchUpAcceleration: 3400 !default;
77
75
  display: block;
78
76
  position: absolute;
79
77
 
78
+ pointer-events: none;
79
+
80
80
  animation-name: none;
81
81
  animation-duration: motion.$expandDuration;
82
82
  animation-timing-function: linear;
@@ -88,11 +88,10 @@ $touchUpAcceleration: 3400 !default;
88
88
  transition-timing-function: motion.$standardEasing;
89
89
 
90
90
  opacity: 0.16;
91
- pointer-events: none;
92
91
  transform: scale(0);
93
-
92
+
94
93
  background-color: currentColor;
95
-
94
+
96
95
  border-radius: 50%;
97
96
  }
98
97
 
@@ -111,7 +110,6 @@ $touchUpAcceleration: 3400 !default;
111
110
  animation-timing-function: motion.$decelerateEasing;
112
111
  }
113
112
 
114
-
115
113
  @keyframes ripple-fade-in {
116
114
  from {
117
115
  transform: scale(0);
@@ -144,33 +142,35 @@ $touchUpAcceleration: 3400 !default;
144
142
  }
145
143
 
146
144
  .mdw-ripple::after {
145
+ content: '';
146
+
147
147
  display: table; // See above
148
148
  position: absolute;
149
- top: 50%;
150
- left: 50%;
149
+ inset-block-start: 50%;
150
+ inset-inline-start: 50%;
151
151
 
152
- height: 0;
153
- width: 0;
152
+ block-size: 0;
153
+ inline-size: 0;
154
154
  padding: 50%;
155
+
156
+ pointer-events: none;
155
157
  // z-index: -1; // Safari has a negative z-index scrolling bug (hides elements)
156
158
  -moz-user-select: none;
157
159
  -ms-user-select: none;
158
160
  -webkit-user-select: none;
159
161
  user-select: none;
160
162
 
161
- transition:
163
+ transition:
162
164
  transform #{motion.$expandDuration + $fadeOutDuration} linear $enterDelay,
163
165
  background-color $fadeOutDuration motion.$decelerateEasing #{$enterDelay + motion.$expandDuration};
164
166
  will-change: transform, background-color;
165
167
 
166
168
  opacity: 0.16;
167
- pointer-events: none;
168
169
  transform: translateX(-50%) translateY(-50%) scale(2);
169
170
 
170
171
  background-color: transparent;
171
172
  border-radius: 50%;
172
173
  color: inherit;
173
- content: '';
174
174
  }
175
175
 
176
176
  // On active, pop up initial state
@@ -194,4 +194,3 @@ $touchUpAcceleration: 3400 !default;
194
194
  visibility: hidden;
195
195
  }
196
196
  }
197
-
@@ -1,40 +1,20 @@
1
- // https://material.io/design/interaction/states.html
2
- // https://material.io/design/components/buttons.html
3
- // https://material.io/design/iconography/system-icons.html#color
1
+ /* https://material.io/design/interaction/states.html */
2
+ /* https://material.io/design/components/buttons.html */
3
+ /* https://material.io/design/iconography/system-icons.html#color */
4
4
 
5
- @use '../theme/_mixins.scss' as theme;
6
-
7
- $themeValues: (
8
- overlay-color: (('foreground-light', 1.00), ('foreground-dark', 1.00)),
9
- pressed-opacity: (0.16, 0.32),
10
- ) !default;
11
-
12
- @function getThemeValue($key, $type) {
13
- @return theme.getThemeValue('ripple', $themeValues, $key, $type);
5
+ .mdw-theme[mdw-light] {
6
+ --mdw-ripple__pressed-opacity: 0.16;
14
7
  }
15
8
 
16
- @mixin addThemeRules($type: 'var') {
17
- .mdw-ripple {
18
- & > .mdw-ripple__container > .mdw-ripple__inner,
19
- &::after {
20
- opacity: getThemeValue("pressed-opacity", $type);
21
- color: inherit;
22
- @if ($type == 'var') {
23
- // Fallback handed by previous inherit rule
24
- color: RGB(var(--mdw-ink));
25
- }
26
- }
27
- }
9
+ .mdw-theme[mdw-dark] {
10
+ --mdw-ripple__pressed-opacity: 0.32;
28
11
  }
29
12
 
13
+ .mdw-ripple {
14
+ & > .mdw-ripple__container > .mdw-ripple__inner,
15
+ &::after {
16
+ opacity: var(--mdw-ripple__pressed-opacity);
30
17
 
31
- @include theme.addComponentFallbackRules('light') {
32
- @include addThemeRules('light');
33
- }
34
- @include theme.addComponentFallbackRules('dark') {
35
- @include addThemeRules('dark');
36
- }
37
-
38
- @include theme.addComponentCSSVariableRules('ripple', $themeValues) {
39
- @include addThemeRules();
18
+ color: RGB(var(--mdw-ink));
19
+ }
40
20
  }
@@ -1,6 +1,4 @@
1
- import {
2
- getChildElementByClass, getPassiveEventListenerOption, iterateArrayLike, nextTick,
3
- } from '../dom.js';
1
+ import { getChildElementByClass } from '../dom.js';
4
2
 
5
3
  /**
6
4
  * @param {Element} element
@@ -28,24 +26,29 @@ export function updateRipplePosition(rippleInner, x, y) {
28
26
  let height;
29
27
  let xPos = x;
30
28
  let yPos = y;
29
+ const {
30
+ clientWidth: parentWidth,
31
+ clientHeight: parentHeight,
32
+ } = /** @type {HTMLElement} */ (rippleInner.parentElement);
33
+
31
34
  if (x == null) {
32
- xPos = rippleInner.parentElement.clientWidth / 2;
35
+ xPos = parentWidth / 2;
33
36
  width = xPos;
34
- } else if (x >= rippleInner.parentElement.clientWidth / 2) {
37
+ } else if (x >= parentWidth / 2) {
35
38
  width = x;
36
39
  // furthest horizontal side is left
37
40
  } else {
38
- width = rippleInner.parentElement.clientWidth - x;
41
+ width = parentWidth - x;
39
42
  // furthest horizontal side is right
40
43
  }
41
44
  if (y == null) {
42
- yPos = rippleInner.parentElement.clientHeight / 2;
45
+ yPos = parentHeight / 2;
43
46
  height = yPos;
44
- } else if (y >= rippleInner.parentElement.clientHeight / 2) {
47
+ } else if (y >= parentHeight / 2) {
45
48
  height = y;
46
49
  // furthest vertical side is bottom
47
50
  } else {
48
- height = rippleInner.parentElement.clientHeight - y;
51
+ height = parentHeight - y;
49
52
  // furthest vertical side is top
50
53
  }
51
54
  const hypotenuse = Math.sqrt((width * width) + (height * height));
@@ -82,8 +85,7 @@ export function drawRipple(rippleInner, initiator) {
82
85
  * @return {void}
83
86
  */
84
87
  export function onAnimationEnd(event) {
85
- /** @type {HTMLElement} */
86
- const rippleInner = (event.currentTarget);
88
+ const rippleInner = /** @type {HTMLElement} */ (event.currentTarget);
87
89
  if (event.animationName === 'ripple-fade-in' || event.animationName === 'ripple-fade-in-repeat') {
88
90
  rippleInner.setAttribute('mdw-fade-in-complete', '');
89
91
  return;
@@ -121,15 +123,12 @@ export function clearRipple(rippleInner) {
121
123
  * @return {void}
122
124
  */
123
125
  export function onMouseDown(event) {
124
- /** @type {HTMLElement} */
125
- const element = (event.currentTarget);
126
- /** @type {HTMLElement} */
127
- const rippleContainer = (getChildElementByClass(element, 'mdw-ripple__container'));
126
+ const element = /** @type {HTMLElement} */ (event.currentTarget);
127
+ const rippleContainer = /** @type {HTMLElement} */ (getChildElementByClass(element, 'mdw-ripple__container'));
128
128
  if (!rippleContainer) {
129
129
  return;
130
130
  }
131
- /** @type {HTMLElement} */
132
- const rippleInner = (getChildElementByClass(rippleContainer, 'mdw-ripple__inner'));
131
+ const rippleInner = /** @type {HTMLElement} */ (getChildElementByClass(rippleContainer, 'mdw-ripple__inner'));
133
132
  if (!rippleInner) {
134
133
  return;
135
134
  }
@@ -149,15 +148,12 @@ export function onMouseDown(event) {
149
148
  * @return {void}
150
149
  */
151
150
  export function onTouchStart(event) {
152
- /** @type {HTMLElement} */
153
- const element = (event.currentTarget);
154
- /** @type {HTMLElement} */
155
- const rippleContainer = (getChildElementByClass(element, 'mdw-ripple__container'));
151
+ const element = /** @type {HTMLElement} */ (event.currentTarget);
152
+ const rippleContainer = /** @type {HTMLElement} */ (getChildElementByClass(element, 'mdw-ripple__container'));
156
153
  if (!rippleContainer) {
157
154
  return;
158
155
  }
159
- /** @type {HTMLElement} */
160
- const rippleInner = (getChildElementByClass(rippleContainer, 'mdw-ripple__inner'));
156
+ const rippleInner = /** @type {HTMLElement} */ (getChildElementByClass(rippleContainer, 'mdw-ripple__inner'));
161
157
  if (!rippleInner) {
162
158
  return;
163
159
  }
@@ -177,15 +173,12 @@ export function onTouchStart(event) {
177
173
  * @return {void}
178
174
  */
179
175
  export function onClick(event) {
180
- /** @type {HTMLElement} */
181
- const element = (event.currentTarget);
182
- /** @type {HTMLElement} */
183
- const rippleContainer = (getChildElementByClass(element, 'mdw-ripple__container'));
176
+ const element = /** @type {HTMLElement} */ (event.currentTarget);
177
+ const rippleContainer = /** @type {HTMLElement} */ (getChildElementByClass(element, 'mdw-ripple__container'));
184
178
  if (!rippleContainer) {
185
179
  return;
186
180
  }
187
- /** @type {HTMLElement} */
188
- const rippleInner = (getChildElementByClass(rippleContainer, 'mdw-ripple__inner'));
181
+ const rippleInner = /** @type {HTMLElement} */ (getChildElementByClass(rippleContainer, 'mdw-ripple__inner'));
189
182
  if (!rippleInner) {
190
183
  return;
191
184
  }
@@ -199,7 +192,7 @@ export function onClick(event) {
199
192
  }
200
193
  updateRipplePosition(rippleInner);
201
194
  drawRipple(rippleInner, 'key');
202
- nextTick(() => {
195
+ requestAnimationFrame(() => {
203
196
  clearRipple(rippleInner);
204
197
  });
205
198
  }
@@ -209,20 +202,17 @@ export function onClick(event) {
209
202
  * @return {void}
210
203
  */
211
204
  export function onKeyDown(event) {
212
- /** @type {HTMLElement} */
213
- const element = (event.currentTarget);
214
- /** @type {HTMLElement} */
215
- const rippleContainer = (getChildElementByClass(element, 'mdw-ripple__container'));
205
+ const element = /** @type {HTMLElement} */ (event.currentTarget);
206
+ const rippleContainer = /** @type {HTMLElement} */ (getChildElementByClass(element, 'mdw-ripple__container'));
216
207
  if (!rippleContainer) {
217
208
  return;
218
209
  }
219
- /** @type {HTMLElement} */
220
- const rippleInner = (getChildElementByClass(rippleContainer, 'mdw-ripple__inner'));
210
+ const rippleInner = /** @type {HTMLElement} */ (getChildElementByClass(rippleContainer, 'mdw-ripple__inner'));
221
211
  if (!rippleInner) {
222
212
  return;
223
213
  }
224
214
 
225
- nextTick(() => {
215
+ requestAnimationFrame(() => {
226
216
  if (isActive(rippleContainer.parentElement)) {
227
217
  if (rippleInner.getAttribute('mdw-fade-in') === 'key') {
228
218
  return;
@@ -244,7 +234,7 @@ export function attach(element) {
244
234
  rippleContainer.classList.add('mdw-ripple__container');
245
235
  rippleContainer.setAttribute('role', 'presentation');
246
236
  if (element.firstChild) {
247
- element.insertBefore(rippleContainer, element.firstChild);
237
+ element.prepend(rippleContainer);
248
238
  } else {
249
239
  element.appendChild(rippleContainer);
250
240
  }
@@ -262,11 +252,11 @@ export function attach(element) {
262
252
  rippleInner.removeAttribute('mdw-fade-in-complete');
263
253
  rippleInner.removeAttribute('mdw-fade-out');
264
254
  element.setAttribute('mdw-ripple-js', '');
265
- element.addEventListener('click', onClick, getPassiveEventListenerOption());
266
- element.addEventListener('mousedown', onMouseDown, getPassiveEventListenerOption());
267
- element.addEventListener('touchstart', onTouchStart, getPassiveEventListenerOption());
268
- element.addEventListener('keydown', onKeyDown, getPassiveEventListenerOption());
269
- rippleInner.addEventListener('animationend', onAnimationEnd, getPassiveEventListenerOption());
255
+ element.addEventListener('click', onClick, { passive: true });
256
+ element.addEventListener('mousedown', onMouseDown, { passive: true });
257
+ element.addEventListener('touchstart', onTouchStart, { passive: true });
258
+ element.addEventListener('keydown', onKeyDown, { passive: true });
259
+ rippleInner.addEventListener('animationend', onAnimationEnd, { passive: true });
270
260
  }
271
261
 
272
262
  /**
@@ -274,7 +264,9 @@ export function attach(element) {
274
264
  * @return {void}
275
265
  */
276
266
  export function attachAll(root = document) {
277
- iterateArrayLike(root.getElementsByClassName('mdw-ripple'), attach);
267
+ for (const el of root.getElementsByClassName('mdw-ripple')) {
268
+ attach(el);
269
+ }
278
270
  }
279
271
 
280
272
  /**
@@ -0,0 +1,15 @@
1
+ @use 'sass:map';
2
+ @use './_config.scss' as *;
3
+ @use './_palettes.scss' as *;
4
+ @use './_functions.scss' as *;
5
+
6
+ :root {
7
+ @each $aliasKey in map.keys($alias) {
8
+ $paletteKey: map.get($alias, $aliasKey);
9
+ $palette: map.get($palettes, $paletteKey);
10
+ @each $toneKey in getAllTones() {
11
+ $tone: map.get($palette, $toneKey);
12
+ --mdw-alias-#{$aliasKey}-#{$toneKey}: var(--mdw-palette-#{$paletteKey}-#{$toneKey});
13
+ }
14
+ }
15
+ }
@@ -1,2 +1,8 @@
1
- @forward './_variables.scss';
2
- @forward './_palettes.scss';
1
+ $alias: (
2
+ 'primary': 'blue',
3
+ 'secondary': 'pink',
4
+ 'warn': 'red',
5
+ 'background': 'gray'
6
+ ) !default;
7
+ $ink-tones: ("A100", "A200", "A400", "A700") !default;
8
+ $surface-tones: ("50", "100", "200", "300", "400", "500", "600", "700", "800", "900") !default;
@@ -0,0 +1,22 @@
1
+ @use 'sass:map';
2
+ @use './_config.scss' as *;
3
+ @use './_palettes.scss' as *;
4
+
5
+ @function getRGB($item) {
6
+ @return red($item),green($item),blue($item);
7
+ }
8
+
9
+ @function getAllTones() {
10
+ $result: ();
11
+ @each $toneKey in $ink-tones {
12
+ @if (index($result, $toneKey) == null) {
13
+ $result: append($result, $toneKey);
14
+ }
15
+ }
16
+ @each $toneKey in $surface-tones {
17
+ @if (index($result, $toneKey) == null) {
18
+ $result: append($result, $toneKey);
19
+ }
20
+ }
21
+ @return $result;
22
+ }
@@ -1,6 +1,5 @@
1
1
  // https://material.io/guidelines/style/color.html#color-color-tool
2
2
 
3
-
4
3
  $bluePalette: (
5
4
  "50": #E3F2FD,
6
5
  "100": #BBDEFB,
File without changes
@@ -0,0 +1,268 @@
1
+ @use 'sass:map';
2
+ @use 'sass:list';
3
+ @use './_config.scss' as *;
4
+ @use './_palettes.scss' as *;
5
+ @use './_functions.scss' as *;
6
+
7
+ :root {
8
+ --mdw-ink-default-light: 0,0,0;
9
+ --mdw-high-opacity-light: 0.87;
10
+ --mdw-medium-opacity-light: 0.60;
11
+ --mdw-inactive-opacity-light: 0.38;
12
+ --mdw-divider-opacity-light: 0.12;
13
+ --mdw-ink-default-dark: 255,255,255;
14
+ --mdw-high-opacity-dark: 1.00;
15
+ --mdw-medium-opacity-dark: 0.70;
16
+ --mdw-inactive-opacity-dark: 0.50;
17
+ --mdw-divider-opacity-dark: 0.24;
18
+ --mdw-surface-binary-light: 255,255,255;
19
+ --mdw-surface-binary-dark: 0,0,0;
20
+ --mdw-surface-card-light: 255,255,255;
21
+ --mdw-surface-card-dark: 18,18,18;
22
+
23
+ @each $paletteKey in map.keys($palettes) {
24
+ $palette: map.get($palettes, $paletteKey);
25
+ @each $toneKey in getAllTones() {
26
+ $tone: map.get($palette, $toneKey);
27
+ --mdw-palette-#{$paletteKey}-#{$toneKey}: #{getRGB($tone)};
28
+ }
29
+ }
30
+ }
31
+
32
+ .mdw-theme {
33
+ --mdw-text-color: RGBA(var(--mdw-ink-default), var(--mdw-high-opacity));
34
+ --mdw-medium-color: RGBA(var(--mdw-ink-default), var(--mdw-medium-opacity));
35
+ --mdw-inactive-color: RGBA(var(--mdw-ink-default), var(--mdw-inactive-opacity));
36
+ --mdw-divider-color: RGBA(var(--mdw-ink-default), var(--mdw-divider-opacity));
37
+ }
38
+
39
+ .mdw-theme[mdw-light] {
40
+ --mdw-ink-default: var(--mdw-ink-default-light);
41
+ --mdw-high-opacity: var(--mdw-high-opacity-light);
42
+ --mdw-medium-opacity: var(--mdw-medium-opacity-light);
43
+ --mdw-inactive-opacity: var(--mdw-inactive-opacity-light);
44
+ --mdw-divider-opacity: var(--mdw-divider-opacity-light);
45
+ --mdw-surface-binary: var(--mdw-surface-binary-light);
46
+ --mdw-surface-card: var(--mdw-surface-card-light);
47
+ @each $paletteKey in map.keys($palettes) {
48
+ $palette: map.get($palettes, $paletteKey);
49
+ --mdw-palette-#{$paletteKey}-surface-default: var(--mdw-palette-#{$paletteKey}-50);
50
+ --mdw-palette-#{$paletteKey}-surface-alt: var(--mdw-palette-#{$paletteKey}-100);
51
+ --mdw-palette-#{$paletteKey}-surface-alt2: var(--mdw-palette-#{$paletteKey}-200);
52
+ --mdw-palette-#{$paletteKey}-ink-default: var(--mdw-palette-#{$paletteKey}-A700);
53
+ --mdw-palette-#{$paletteKey}-ink-contrast: var(--mdw-palette-#{$paletteKey}-A700);
54
+ --mdw-palette-#{$paletteKey}-ink-light: var(--mdw-palette-#{$paletteKey}-A400);
55
+ }
56
+
57
+ @each $aliasKey in map.keys($alias) {
58
+ $paletteKey: map.get($alias, $aliasKey);
59
+ --mdw-alias-#{$aliasKey}-surface-default: var(--mdw-alias-#{$aliasKey}-50);
60
+ --mdw-alias-#{$aliasKey}-surface-alt: var(--mdw-alias-#{$aliasKey}-100);
61
+ --mdw-alias-#{$aliasKey}-surface-alt2: var(--mdw-alias-#{$aliasKey}-200);
62
+ --mdw-alias-#{$aliasKey}-ink-default: var(--mdw-alias-#{$aliasKey}-A700);
63
+ --mdw-alias-#{$aliasKey}-ink-contrast: var(--mdw-alias-#{$aliasKey}-A700);
64
+ --mdw-alias-#{$aliasKey}-ink-light: var(--mdw-alias-#{$aliasKey}-A400);
65
+ }
66
+ }
67
+
68
+ .mdw-theme[mdw-dark] {
69
+ --mdw-ink-default: var(--mdw-ink-default-dark);
70
+ --mdw-high-opacity: var(--mdw-high-opacity-dark);
71
+ --mdw-medium-opacity: var(--mdw-medium-opacity-dark);
72
+ --mdw-inactive-opacity: var(--mdw-inactive-opacity-dark);
73
+ --mdw-divider-opacity: var(--mdw-divider-opacity-dark);
74
+ --mdw-surface-binary: var(--mdw-surface-binary-dark);
75
+ --mdw-surface-card: var(--mdw-surface-card-dark);
76
+ @each $paletteKey in map.keys($palettes) {
77
+ $palette: map.get($palettes, $paletteKey);
78
+ --mdw-palette-#{$paletteKey}-surface-default: var(--mdw-palette-#{$paletteKey}-900);
79
+ --mdw-palette-#{$paletteKey}-surface-alt: var(--mdw-palette-#{$paletteKey}-800);
80
+ --mdw-palette-#{$paletteKey}-surface-alt2: var(--mdw-palette-#{$paletteKey}-700);
81
+ --mdw-palette-#{$paletteKey}-ink-default: var(--mdw-palette-#{$paletteKey}-A200);
82
+ --mdw-palette-#{$paletteKey}-ink-contrast: var(--mdw-palette-#{$paletteKey}-A100);
83
+ --mdw-palette-#{$paletteKey}-ink-light: var(--mdw-palette-#{$paletteKey}-A100);
84
+ }
85
+
86
+ @each $aliasKey in map.keys($alias) {
87
+ $paletteKey: map.get($alias, $aliasKey);
88
+ --mdw-alias-#{$aliasKey}-surface-default: var(--mdw-alias-#{$aliasKey}-900);
89
+ --mdw-alias-#{$aliasKey}-surface-alt: var(--mdw-alias-#{$aliasKey}-800);
90
+ --mdw-alias-#{$aliasKey}-surface-alt2: var(--mdw-alias-#{$aliasKey}-700);
91
+ --mdw-alias-#{$aliasKey}-ink-default: var(--mdw-alias-#{$aliasKey}-A200);
92
+ --mdw-alias-#{$aliasKey}-ink-contrast: var(--mdw-alias-#{$aliasKey}-A100);
93
+ --mdw-alias-#{$aliasKey}-ink-light: var(--mdw-alias-#{$aliasKey}-A100);
94
+ }
95
+ }
96
+
97
+ /** Surface Colors */
98
+
99
+ .mdw-theme[mdw-surface] {
100
+ background-color: RGB(var(--mdw-surface));
101
+ }
102
+
103
+ svg.mdw-theme[mdw-surface] {
104
+ background-color: transparent;
105
+
106
+ fill: RGB(var(--mdw-surface));
107
+ }
108
+
109
+ .mdw-theme {
110
+ &[mdw-surface]:not([mdw-ink]) {
111
+ --mdw-ink: var(--mdw-ink-default);
112
+ --mdw-ink-opacity: var(--mdw-high-opacity);
113
+ color: RGBA(var(--mdw-ink), var(--mdw-ink-opacity));
114
+ }
115
+
116
+ &[mdw-surface="white"] {
117
+ --mdw-surface: 255,255,255;
118
+ }
119
+
120
+ &[mdw-surface="black"] {
121
+ --mdw-surface: 0,0,0;
122
+ }
123
+
124
+ &[mdw-surface="binary"] {
125
+ --mdw-surface: var(--mdw-surface-binary);
126
+ }
127
+
128
+ &[mdw-surface="card"] {
129
+ --mdw-surface: var(--mdw-surface-card);
130
+ }
131
+
132
+ @each $paletteKey in map.keys($palettes) {
133
+ $palette: map.get($palettes, $paletteKey);
134
+ &[mdw-surface~="#{$paletteKey}"] {
135
+ --mdw-surface: var(--mdw-palette-#{$paletteKey}-surface-default);
136
+ @each $toneKey in $surface-tones {
137
+ --mdw-surface-#{$toneKey}: var(--mdw-palette-#{$paletteKey}-#{$toneKey});
138
+ }
139
+ }
140
+ &[mdw-surface="#{$paletteKey} alt"] {
141
+ --mdw-surface: var(--mdw-palette-#{$paletteKey}-surface-alt);
142
+ }
143
+ &[mdw-surface="#{$paletteKey} alt2"] {
144
+ --mdw-surface: var(--mdw-palette-#{$paletteKey}-surface-alt2);
145
+ }
146
+ }
147
+
148
+ @each $aliasKey in map.keys($alias) {
149
+ &[mdw-surface~="#{$aliasKey}"] {
150
+ --mdw-surface: var(--mdw-alias-#{$aliasKey}-surface-default);
151
+ @each $toneKey in $surface-tones {
152
+ --mdw-surface-#{$toneKey}: var(--mdw-alias-#{$aliasKey}-#{$toneKey});
153
+ }
154
+ }
155
+ &[mdw-surface="#{$aliasKey} alt"] {
156
+ --mdw-surface: var(--mdw-alias-#{$aliasKey}-surface-alt);
157
+ }
158
+ &[mdw-surface="#{$aliasKey} alt2"] {
159
+ --mdw-surface: var(--mdw-alias-#{$aliasKey}-surface-alt2);
160
+ }
161
+ }
162
+
163
+ @each $tone in $surface-tones {
164
+ &[mdw-surface~="#{$tone}"] {
165
+ --mdw-surface: var(--mdw-surface-#{$tone});
166
+ }
167
+ }
168
+ }
169
+
170
+ /** Ink Color **/
171
+
172
+ .mdw-theme {
173
+ &[mdw-ink] {
174
+ --mdw-ink: var(--mdw-ink-default);
175
+ --mdw-ink-opacity: 1;
176
+ color: RGBA(var(--mdw-ink), var(--mdw-ink-opacity));
177
+ }
178
+
179
+ &[mdw-ink=""],
180
+ &[mdw-ink~="default"] {
181
+ --mdw-ink: var(--mdw--ink-default);
182
+ --mdw-ink-opacity: var(--mdw-high-opacity);
183
+ }
184
+
185
+ &[mdw-ink~="white"] {
186
+ --mdw-ink: 255,255,255;
187
+ }
188
+
189
+ &[mdw-ink~="black"] {
190
+ --mdw-ink: 0,0,0;
191
+ }
192
+
193
+ @each $paletteKey in map.keys($palettes) {
194
+ $palette: map.get($palettes, $paletteKey);
195
+ &[mdw-ink~="#{$paletteKey}"] {
196
+ --mdw-ink: var(--mdw-palette-#{$paletteKey}-ink-default);
197
+ @each $toneKey in $ink-tones {
198
+ --mdw-ink-#{$toneKey}: var(--mdw-palette-#{$paletteKey}-#{$toneKey});
199
+ }
200
+ }
201
+ &[mdw-ink^="#{$paletteKey} contrast"] {
202
+ --mdw-ink: var(--mdw-palette-#{$paletteKey}-ink-contrast);
203
+ }
204
+ &[mdw-ink^="#{$paletteKey} light"] {
205
+ --mdw-ink: var(--mdw-palette-#{$paletteKey}-ink-light);
206
+ }
207
+ }
208
+
209
+ @each $aliasKey in map.keys($alias) {
210
+ &[mdw-ink~="#{$aliasKey}"] {
211
+ --mdw-ink: var(--mdw-alias-#{$aliasKey}-ink-default);
212
+ @each $toneKey in $ink-tones {
213
+ --mdw-ink-#{$toneKey}: var(--mdw-alias-#{$aliasKey}-#{$toneKey});
214
+ }
215
+ }
216
+ &[mdw-ink^="#{$aliasKey} contrast"] {
217
+ --mdw-ink: var(--mdw-alias-#{$aliasKey}-ink-contrast);
218
+ }
219
+ &[mdw-ink^="#{$aliasKey} light"] {
220
+ --mdw-ink: var(--mdw-palette-#{$aliasKey}-ink-light);
221
+ }
222
+ }
223
+
224
+ @each $tone in $ink-tones {
225
+ &[mdw-ink~="#{$tone}"] {
226
+ --mdw-ink: var(--mdw-ink-#{$tone});
227
+ }
228
+ }
229
+ }
230
+
231
+ /** Ink Opacity **/
232
+ .mdw-theme {
233
+ &[mdw-ink~="solid"] {
234
+ --mdw-ink-opacity: 1;
235
+ }
236
+
237
+ &[mdw-ink~="high"] {
238
+ --mdw-ink-opacity: var(--mdw-high-opacity);
239
+ }
240
+
241
+ &[mdw-ink~="medium"] {
242
+ --mdw-ink-opacity: var(--mdw-medium-opacity);
243
+ }
244
+
245
+ &[mdw-ink~="inactive"] {
246
+ --mdw-ink-opacity: var(--mdw-inactive-opacity);
247
+ }
248
+
249
+ &[mdw-ink~="divider"] {
250
+ --mdw-ink-opacity: var(--mdw-divider-opacity);
251
+ }
252
+ }
253
+
254
+ /** Border Ink **/
255
+
256
+ .mdw-theme {
257
+ &[mdw-border-ink] {
258
+ border-color: RGBA(var(--mdw-ink), var(--mdw-divider-opacity));
259
+ }
260
+
261
+ &[mdw-border-ink="default"] {
262
+ border-color: RGBA(var(--mdw-ink-default), var(--mdw-divider-opacity));
263
+ }
264
+
265
+ &[mdw-border-ink="none"] {
266
+ border-color: transparent;
267
+ }
268
+ }
@@ -0,0 +1,4 @@
1
+ @forward './_config.scss';
2
+ @forward './_spec.scss';
3
+ @forward './_theme.scss';
4
+ @forward './_aliases.scss';