@shortfuse/materialdesignweb 0.3.0 → 0.4.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 (398) hide show
  1. package/.eslintrc.json +136 -30
  2. package/.stylelintrc.json +6 -40
  3. package/.vscode/launch.json +20 -5
  4. package/CHANGELOG.md +24 -0
  5. package/README.md +12 -9
  6. package/adapters/datatable/column.js +82 -74
  7. package/adapters/datatable/index.js +173 -131
  8. package/adapters/dom/index.js +529 -75
  9. package/adapters/list/index.js +25 -12
  10. package/adapters/search/index.js +13 -13
  11. package/components/appbar/_spec.scss +87 -64
  12. package/components/appbar/index.scss +2 -2
  13. package/components/banner/_spec.scss +8 -8
  14. package/components/banner/index.scss +2 -2
  15. package/components/bottomnav/_spec.scss +22 -17
  16. package/components/bottomnav/index.js +61 -52
  17. package/components/bottomnav/index.scss +2 -2
  18. package/components/bottomnav/item.js +44 -25
  19. package/components/button/README.md +14 -14
  20. package/components/button/_spec.scss +23 -22
  21. package/components/button/_theme.scss +37 -21
  22. package/components/button/index.eta +32 -0
  23. package/components/button/index.js +12 -12
  24. package/components/button/index.scss +2 -2
  25. package/components/card/_spec.scss +40 -36
  26. package/components/card/index.scss +2 -2
  27. package/components/chip/_spec.scss +7 -8
  28. package/components/chip/_theme.scss +31 -31
  29. package/components/chip/index.js +3 -2
  30. package/components/chip/index.scss +2 -2
  31. package/components/chip/item.js +1 -16
  32. package/components/datatable/_spec.scss +71 -85
  33. package/components/datatable/_theme.scss +61 -156
  34. package/components/datatable/cell.js +45 -0
  35. package/components/datatable/columnheader.js +47 -0
  36. package/components/datatable/index.js +279 -366
  37. package/components/datatable/index.scss +2 -2
  38. package/components/datatable/row.js +49 -0
  39. package/components/datatable/rowheader.js +18 -0
  40. package/components/dialog/_spec.scss +61 -41
  41. package/components/dialog/index.js +325 -297
  42. package/components/dialog/index.scss +2 -2
  43. package/components/divider/_spec.scss +8 -6
  44. package/components/divider/index.scss +2 -2
  45. package/components/elevation/_spec.scss +2 -2
  46. package/components/elevation/index.scss +2 -2
  47. package/components/fab/_spec.scss +23 -24
  48. package/components/fab/index.js +50 -50
  49. package/components/fab/index.scss +2 -2
  50. package/components/grid/_spec.scss +33 -31
  51. package/components/grid/index.scss +2 -2
  52. package/components/layout/_mixins.scss +5 -5
  53. package/components/layout/_spec.scss +206 -176
  54. package/components/layout/_theme.scss +14 -16
  55. package/components/layout/index.js +181 -153
  56. package/components/layout/index.scss +2 -2
  57. package/components/list/_spec.scss +117 -104
  58. package/components/list/_theme.scss +31 -34
  59. package/components/list/content.js +68 -52
  60. package/components/list/index.js +194 -61
  61. package/components/list/index.scss +2 -2
  62. package/components/list/item.js +136 -12
  63. package/components/list/secondary.js +46 -0
  64. package/components/menu/_spec.scss +32 -19
  65. package/components/menu/index.js +242 -229
  66. package/components/menu/index.scss +2 -2
  67. package/components/menu/item.js +95 -110
  68. package/components/progress/_spec.scss +35 -27
  69. package/components/progress/index.js +21 -0
  70. package/components/progress/index.scss +2 -1
  71. package/components/selection/_spec.scss +242 -224
  72. package/components/selection/_theme.scss +100 -95
  73. package/components/selection/index.eta +60 -0
  74. package/components/selection/index.js +76 -0
  75. package/components/selection/index.pug +15 -8
  76. package/components/selection/index.scss +2 -2
  77. package/components/selection/input.js +56 -0
  78. package/components/selection/radiogroup.js +47 -0
  79. package/components/slider/_spec.scss +10 -8
  80. package/components/slider/index.scss +2 -2
  81. package/components/snackbar/_spec.scss +22 -21
  82. package/components/snackbar/index.js +102 -111
  83. package/components/snackbar/index.scss +2 -2
  84. package/components/tab/_spec.scss +20 -19
  85. package/components/tab/content.js +41 -40
  86. package/components/tab/index.js +192 -99
  87. package/components/tab/index.scss +2 -2
  88. package/components/tab/item.js +38 -55
  89. package/components/tab/list.js +96 -72
  90. package/components/tab/panel.js +12 -13
  91. package/components/template/_theme.scss +11 -11
  92. package/components/textfield/_mixins.scss +52 -0
  93. package/components/textfield/_spec.scss +215 -266
  94. package/components/textfield/_theme.scss +95 -72
  95. package/components/textfield/index.eta +74 -0
  96. package/components/textfield/index.js +63 -57
  97. package/components/textfield/index.scss +2 -2
  98. package/components/tooltip/_spec.scss +27 -25
  99. package/components/tooltip/index.scss +2 -2
  100. package/components/type/_spec.scss +51 -38
  101. package/components/type/index.scss +2 -2
  102. package/core/_breakpoint.scss +75 -91
  103. package/core/_elevation.scss +10 -10
  104. package/core/_length.scss +9 -0
  105. package/core/_motion.scss +14 -14
  106. package/core/_platform.scss +9 -15
  107. package/core/_type.scss +33 -32
  108. package/core/aria/attributes.js +125 -25
  109. package/core/aria/button.js +23 -23
  110. package/core/aria/keyboard.js +93 -0
  111. package/core/aria/rovingtabindex.js +69 -154
  112. package/core/aria/tab.js +31 -28
  113. package/core/color/_theme.scss +240 -280
  114. package/core/color/index.scss +2 -2
  115. package/core/document/index.js +39 -0
  116. package/core/dom.js +12 -12
  117. package/core/overlay/_spec.scss +0 -3
  118. package/core/overlay/_theme.scss +56 -74
  119. package/core/overlay/index.js +49 -18
  120. package/core/overlay/index.scss +2 -2
  121. package/core/ripple/_spec.scss +22 -39
  122. package/core/ripple/_theme.scss +13 -13
  123. package/core/ripple/index.js +137 -134
  124. package/core/ripple/index.scss +2 -2
  125. package/core/theme/_config.scss +2 -0
  126. package/core/theme/_mixins.scss +172 -0
  127. package/core/theme/_palettes.scss +155 -135
  128. package/core/theme/_variables.scss +24 -15
  129. package/core/theme/index.js +50 -0
  130. package/core/throttler.js +1 -1
  131. package/core/transition/index.js +36 -20
  132. package/{docs-src → docs}/_flex.scss +0 -0
  133. package/{docs-src → docs}/_menuoptions.js +21 -34
  134. package/{docs-src → docs}/_mixins.pug +39 -26
  135. package/docs/_partials/_androidnavbar.eta +5 -0
  136. package/docs/_partials/_androidstatusbar.eta +13 -0
  137. package/docs/_partials/_appbar.eta +29 -0
  138. package/docs/_partials/_buttontest.eta +31 -0
  139. package/docs/_partials/_header.eta +149 -0
  140. package/docs/_partials/_navlistitem.eta +16 -0
  141. package/docs/_partials/_target.eta +1 -0
  142. package/{docs-src → docs}/_sample-utils.js +8 -6
  143. package/{docs-src → docs}/_storage.js +0 -0
  144. package/{docs-src → docs}/docs.scss +5 -2
  145. package/docs/index.eta +16 -0
  146. package/{docs-src → docs}/index.js +0 -0
  147. package/docs/pages/appbar.eta +114 -0
  148. package/{docs-src/components → docs/pages}/appbar.js +0 -0
  149. package/{docs-src/components → docs/pages}/appbar.pug +15 -18
  150. package/docs/pages/bottomnav.eta +188 -0
  151. package/{docs-src/components → docs/pages}/bottomnav.js +23 -24
  152. package/{docs-src/components → docs/pages}/bottomnav.pug +4 -4
  153. package/docs/pages/button.eta +124 -0
  154. package/{docs-src/components → docs/pages}/button.js +19 -19
  155. package/{docs-src/components → docs/pages}/button.pug +15 -15
  156. package/docs/pages/card.eta +90 -0
  157. package/{docs-src/components → docs/pages}/card.js +3 -3
  158. package/{docs-src/components → docs/pages}/card.pug +7 -7
  159. package/docs/pages/chip.eta +122 -0
  160. package/{docs-src/components → docs/pages}/chip.js +3 -6
  161. package/{docs-src/components → docs/pages}/chip.pug +2 -2
  162. package/docs/pages/color.eta +143 -0
  163. package/{docs-src/core → docs/pages}/color.js +95 -20
  164. package/docs/pages/color.pug +121 -0
  165. package/docs/pages/datatable.eta +323 -0
  166. package/{docs-src/components → docs/pages}/datatable.js +26 -13
  167. package/docs/pages/datatable.pug +283 -0
  168. package/docs/pages/dialog.eta +186 -0
  169. package/{docs-src/components → docs/pages}/dialog.js +26 -13
  170. package/{docs-src/components → docs/pages}/dialog.pug +46 -28
  171. package/docs/pages/dom.eta +26 -0
  172. package/docs/pages/dom.js +143 -0
  173. package/docs/pages/dom.pug +22 -0
  174. package/docs/pages/elevation.eta +35 -0
  175. package/{docs-src/components → docs/pages}/elevation.js +0 -0
  176. package/{docs-src/components → docs/pages}/elevation.pug +0 -0
  177. package/docs/pages/fab.eta +99 -0
  178. package/{docs-src/components → docs/pages}/fab.js +3 -3
  179. package/{docs-src/components → docs/pages}/fab.pug +2 -2
  180. package/docs/pages/grid.eta +135 -0
  181. package/{docs-src/components → docs/pages}/grid.js +1 -1
  182. package/{docs-src/components → docs/pages}/grid.pug +3 -3
  183. package/docs/pages/layout.eta +8 -0
  184. package/{docs-src/components → docs/pages}/layout.js +0 -0
  185. package/{docs-src/components → docs/pages}/layout.pug +0 -0
  186. package/docs/pages/list.eta +465 -0
  187. package/{docs-src/components → docs/pages}/list.js +2 -2
  188. package/{docs-src/components → docs/pages}/list.pug +7 -14
  189. package/docs/pages/menu.eta +276 -0
  190. package/{docs-src/components → docs/pages}/menu.js +14 -10
  191. package/{docs-src/components → docs/pages}/menu.pug +0 -0
  192. package/docs/pages/overlay.eta +69 -0
  193. package/docs/pages/overlay.js +4 -0
  194. package/{docs-src/core → docs/pages}/overlay.pug +14 -11
  195. package/docs/pages/progress.eta +23 -0
  196. package/{docs-src/components → docs/pages}/progress.js +1 -1
  197. package/{docs-src/components → docs/pages}/progress.pug +1 -1
  198. package/docs/pages/ripple.eta +27 -0
  199. package/docs/pages/ripple.js +4 -0
  200. package/{docs-src/core → docs/pages}/ripple.pug +4 -4
  201. package/docs/pages/search.eta +246 -0
  202. package/{docs-src/components → docs/pages}/search.js +59 -42
  203. package/{docs-src/components → docs/pages}/search.pug +50 -51
  204. package/docs/pages/selection.eta +111 -0
  205. package/docs/pages/selection.js +13 -0
  206. package/docs/pages/selection.pug +74 -0
  207. package/docs/pages/slider.eta +23 -0
  208. package/{docs-src/components → docs/pages}/slider.js +0 -0
  209. package/{docs-src/components → docs/pages}/slider.pug +0 -0
  210. package/docs/pages/snackbar.eta +83 -0
  211. package/{docs-src/components → docs/pages}/snackbar.js +3 -3
  212. package/{docs-src/components → docs/pages}/snackbar.pug +0 -0
  213. package/docs/pages/tab.eta +421 -0
  214. package/{docs-src/components → docs/pages}/tab.js +18 -35
  215. package/{docs-src/components → docs/pages}/tab.pug +4 -4
  216. package/docs/pages/textfield.eta +486 -0
  217. package/{docs-src/components → docs/pages}/textfield.js +3 -4
  218. package/{docs-src/components → docs/pages}/textfield.pug +87 -35
  219. package/docs/pages/tooltip.eta +94 -0
  220. package/{docs-src/components → docs/pages}/tooltip.js +0 -0
  221. package/{docs-src/components → docs/pages}/tooltip.pug +0 -1
  222. package/docs/pages/transition.eta +117 -0
  223. package/{docs-src/core → docs/pages}/transition.js +7 -8
  224. package/{docs-src/core → docs/pages}/transition.pug +0 -0
  225. package/docs/pages/type.eta +31 -0
  226. package/{docs-src/components → docs/pages}/type.js +0 -0
  227. package/{docs-src/components → docs/pages}/type.pug +0 -1
  228. package/docs/postrender.js +39 -0
  229. package/{docs-src → docs}/prerender.js +3 -9
  230. package/docs/pwa/_dialogs.eta +143 -0
  231. package/docs/pwa/_dialogs.pug +96 -0
  232. package/docs/pwa/_menus.eta +16 -0
  233. package/{docs-src → docs}/pwa/_menus.pug +0 -0
  234. package/docs/pwa/pwa-prerender.js +3 -0
  235. package/docs/pwa/pwa.eta +480 -0
  236. package/docs/pwa/pwa.js +306 -0
  237. package/{docs-src → docs}/pwa/pwa.pug +166 -263
  238. package/docs/pwa/pwa.scss +26 -0
  239. package/docs/spec.scss +26 -0
  240. package/docs/themes/_component-themes.scss +26 -0
  241. package/docs/themes/theme-colored-fallbacks.scss +17 -0
  242. package/docs/themes/theme-colored.scss +17 -0
  243. package/docs/themes/theme-default-fallbacks.scss +17 -0
  244. package/docs/themes/theme-default.scss +17 -0
  245. package/jsconfig.json +4 -2
  246. package/package.json +40 -27
  247. package/scripts/deploy-docs.sh +9 -0
  248. package/templates/index.eta +2 -0
  249. package/utils/function.js +3 -0
  250. package/webpack.config.cjs +257 -0
  251. package/_spec.scss +0 -27
  252. package/_theme.scss +0 -27
  253. package/components/list/expander.js +0 -142
  254. package/components/list/itemgroup.js +0 -22
  255. package/core/theme/_builder.scss +0 -116
  256. package/core/theme/index.scss +0 -68
  257. package/docs/appbar.html +0 -1
  258. package/docs/appbar.min.js +0 -2
  259. package/docs/appbar.min.js.map +0 -1
  260. package/docs/bottomnav.html +0 -1
  261. package/docs/bottomnav.min.js +0 -2
  262. package/docs/bottomnav.min.js.map +0 -1
  263. package/docs/button.html +0 -1
  264. package/docs/button.min.js +0 -2
  265. package/docs/button.min.js.map +0 -1
  266. package/docs/card.html +0 -1
  267. package/docs/card.min.js +0 -2
  268. package/docs/card.min.js.map +0 -1
  269. package/docs/chip.html +0 -1
  270. package/docs/chip.min.js +0 -2
  271. package/docs/chip.min.js.map +0 -1
  272. package/docs/color.html +0 -1
  273. package/docs/color.min.js +0 -2
  274. package/docs/color.min.js.map +0 -1
  275. package/docs/datatable.html +0 -1
  276. package/docs/datatable.min.js +0 -2
  277. package/docs/datatable.min.js.map +0 -1
  278. package/docs/default.common.min.js +0 -2
  279. package/docs/default.common.min.js.map +0 -1
  280. package/docs/dialog.html +0 -1
  281. package/docs/dialog.min.js +0 -2
  282. package/docs/dialog.min.js.map +0 -1
  283. package/docs/docs.min.css +0 -1
  284. package/docs/docs.min.js +0 -2
  285. package/docs/docs.min.js.map +0 -1
  286. package/docs/elevation.html +0 -1
  287. package/docs/elevation.min.js +0 -2
  288. package/docs/elevation.min.js.map +0 -1
  289. package/docs/fab.html +0 -1
  290. package/docs/fab.min.js +0 -2
  291. package/docs/fab.min.js.map +0 -1
  292. package/docs/grid.html +0 -1
  293. package/docs/grid.min.js +0 -2
  294. package/docs/grid.min.js.map +0 -1
  295. package/docs/index.html +0 -1
  296. package/docs/index.min.js +0 -2
  297. package/docs/index.min.js.map +0 -1
  298. package/docs/ink.html +0 -1
  299. package/docs/ink.min.js +0 -2
  300. package/docs/ink.min.js.map +0 -1
  301. package/docs/layout.html +0 -1
  302. package/docs/layout.min.js +0 -2
  303. package/docs/layout.min.js.map +0 -1
  304. package/docs/list.html +0 -1
  305. package/docs/list.min.js +0 -2
  306. package/docs/list.min.js.map +0 -1
  307. package/docs/menu.html +0 -1
  308. package/docs/menu.min.js +0 -2
  309. package/docs/menu.min.js.map +0 -1
  310. package/docs/overlay.html +0 -1
  311. package/docs/overlay.min.js +0 -2
  312. package/docs/overlay.min.js.map +0 -1
  313. package/docs/prerender.common.min.js +0 -2
  314. package/docs/prerender.common.min.js.map +0 -1
  315. package/docs/prerender.min.js +0 -2
  316. package/docs/prerender.min.js.map +0 -1
  317. package/docs/progress.html +0 -1
  318. package/docs/progress.min.js +0 -2
  319. package/docs/progress.min.js.map +0 -1
  320. package/docs/pwa-prerender.min.js +0 -2
  321. package/docs/pwa-prerender.min.js.map +0 -1
  322. package/docs/pwa.html +0 -11
  323. package/docs/pwa.min.css +0 -1
  324. package/docs/pwa.min.js +0 -2
  325. package/docs/pwa.min.js.map +0 -1
  326. package/docs/ripple.html +0 -1
  327. package/docs/ripple.min.js +0 -2
  328. package/docs/ripple.min.js.map +0 -1
  329. package/docs/search.html +0 -1
  330. package/docs/search.min.js +0 -2
  331. package/docs/search.min.js.map +0 -1
  332. package/docs/selection.html +0 -1
  333. package/docs/selection.min.js +0 -2
  334. package/docs/selection.min.js.map +0 -1
  335. package/docs/slider.html +0 -1
  336. package/docs/slider.min.js +0 -2
  337. package/docs/slider.min.js.map +0 -1
  338. package/docs/snackbar.html +0 -1
  339. package/docs/snackbar.min.js +0 -2
  340. package/docs/snackbar.min.js.map +0 -1
  341. package/docs/spec.min.css +0 -1
  342. package/docs/spec.min.js +0 -2
  343. package/docs/spec.min.js.map +0 -1
  344. package/docs/surface.html +0 -1
  345. package/docs/surface.min.js +0 -2
  346. package/docs/surface.min.js.map +0 -1
  347. package/docs/tab.html +0 -1
  348. package/docs/tab.min.js +0 -2
  349. package/docs/tab.min.js.map +0 -1
  350. package/docs/textfield.html +0 -2
  351. package/docs/textfield.min.js +0 -2
  352. package/docs/textfield.min.js.map +0 -1
  353. package/docs/theme-colored-fallbacks.min.css +0 -1
  354. package/docs/theme-colored-fallbacks.min.js +0 -2
  355. package/docs/theme-colored-fallbacks.min.js.map +0 -1
  356. package/docs/theme-colored.min.css +0 -1
  357. package/docs/theme-colored.min.js +0 -2
  358. package/docs/theme-colored.min.js.map +0 -1
  359. package/docs/theme-default-fallbacks.min.css +0 -1
  360. package/docs/theme-default-fallbacks.min.js +0 -2
  361. package/docs/theme-default-fallbacks.min.js.map +0 -1
  362. package/docs/theme-default.min.css +0 -1
  363. package/docs/theme-default.min.js +0 -2
  364. package/docs/theme-default.min.js.map +0 -1
  365. package/docs/themes-fallbacks.min.css +0 -1
  366. package/docs/themes-fallbacks.min.js +0 -2
  367. package/docs/themes-fallbacks.min.js.map +0 -1
  368. package/docs/themes.min.css +0 -1
  369. package/docs/themes.min.js +0 -2
  370. package/docs/themes.min.js.map +0 -1
  371. package/docs/tooltip.html +0 -1
  372. package/docs/tooltip.min.js +0 -2
  373. package/docs/tooltip.min.js.map +0 -1
  374. package/docs/transition.html +0 -1
  375. package/docs/transition.min.js +0 -2
  376. package/docs/transition.min.js.map +0 -1
  377. package/docs/type.html +0 -1
  378. package/docs/type.min.js +0 -2
  379. package/docs/type.min.js.map +0 -1
  380. package/docs-src/components/datatable.pug +0 -327
  381. package/docs-src/components/selection.js +0 -9
  382. package/docs-src/components/selection.pug +0 -77
  383. package/docs-src/core/color.pug +0 -201
  384. package/docs-src/core/overlay.js +0 -4
  385. package/docs-src/core/ripple.js +0 -4
  386. package/docs-src/index.pug +0 -9
  387. package/docs-src/pwa/_dialogs.pug +0 -15
  388. package/docs-src/pwa/pwa-prerender.js +0 -3
  389. package/docs-src/pwa/pwa.js +0 -182
  390. package/docs-src/pwa/pwa.scss +0 -25
  391. package/docs-src/spec.scss +0 -1
  392. package/docs-src/themes/theme-colored-fallbacks.scss +0 -14
  393. package/docs-src/themes/theme-colored.scss +0 -14
  394. package/docs-src/themes/theme-default-fallbacks.scss +0 -14
  395. package/docs-src/themes/theme-default.scss +0 -14
  396. package/index.js +0 -51
  397. package/index.scss +0 -2
  398. package/webpack.config.js +0 -187
@@ -1,14 +1,6 @@
1
- @function mdwElevation($dp, $filter:false) {
2
- @if ($filter == true) {
3
- @return unquote(map-get($mdw-elevation__filter-values, $dp));
4
- } @else {
5
- @return unquote(map-get($mdw-elevation__box-shadow-values, $dp));
6
- }
7
- }
8
-
9
1
 
10
2
  // https://material.io/archive/guidelines/resources/shadows.html#shadows-sketch
11
- $mdw-elevation__box-shadow-values: (
3
+ $shadowValues: (
12
4
  0: "none",
13
5
  1: "0 00px 02px 0px rgba(0,0,0,0.14), 0 02px 02px 0px rgba(0,0,0,0.12), 0 01px 03px 0 rgba(0,0,0,0.20)",
14
6
  2: "0 00px 04px 0px rgba(0,0,0,0.14), 0 03px 04px 0px rgba(0,0,0,0.12), 0 01px 05px 0 rgba(0,0,0,0.20)",
@@ -23,7 +15,7 @@ $mdw-elevation__box-shadow-values: (
23
15
  ) !default;
24
16
 
25
17
  // https://material.io/archive/guidelines/resources/shadows.html#shadows-illustrator
26
- $mdw-elevation__filter-values: (
18
+ $filterValues: (
27
19
  0: "none",
28
20
  1: "drop-shadow(0 00.92px 00.5px rgba(0,0,0,0.26)) drop-shadow(0 0 00.67px rgba(0,0,0,0.08))",
29
21
  2: "drop-shadow(0 01.83px 01.0px rgba(0,0,0,0.26)) drop-shadow(0 0 01.33px rgba(0,0,0,0.08))",
@@ -36,3 +28,11 @@ $mdw-elevation__filter-values: (
36
28
  16: "drop-shadow(0 14.67px 08.0px rgba(0,0,0,0.26)) drop-shadow(0 0 10.67px rgba(0,0,0,0.08))",
37
29
  24: "drop-shadow(0 22.12px 12.0px rgba(0,0,0,0.26)) drop-shadow(0 0 16.00px rgba(0,0,0,0.08))",
38
30
  ) !default;
31
+
32
+ @function boxShadow($dp) {
33
+ @return unquote(map-get($shadowValues, $dp));
34
+ }
35
+
36
+ @function filter($dp) {
37
+ @return unquote(map-get($filterValues, $dp));
38
+ }
@@ -0,0 +1,9 @@
1
+ @use "sass:math";
2
+
3
+ @function dp($multiplier) {
4
+ @return $multiplier * 1px;
5
+ }
6
+
7
+ @function sp($multiplier) {
8
+ @return math.div($multiplier,16.0) * 1rem;
9
+ }
package/core/_motion.scss CHANGED
@@ -1,31 +1,31 @@
1
1
  // Motion Durations
2
2
  // https://material.io/guidelines/motion/duration-easing.html#duration-easing-dynamic-durations
3
3
 
4
- $mdw-motion__simple-duration: 100ms !default;
5
- $mdw-motion__fade-in-duration: 150ms !default;
6
- $mdw-motion__fade-out-duration: 75ms !default;
4
+ $simpleDuration: 100ms !default;
5
+ $fadeInDuration: 150ms !default;
6
+ $fadeOutDuration: 75ms !default;
7
7
 
8
- $mdw-motion__shape-change-duration: 200ms !default;
9
- $mdw-motion__icon-duration: 500ms !default;
8
+ $shapeChangeDuration: 200ms !default;
9
+ $iconDuration: 500ms !default;
10
10
 
11
- $mdw-motion__expand-duration: 250ms !default;
12
- $mdw-motion__collapse-duration: 200ms !default;
11
+ $expandDuration: 250ms !default;
12
+ $collapseDuration: 200ms !default;
13
13
 
14
- $mdw-motion__expand-duration__full: 300ms !default;
15
- $mdw-motion__collapse-duration__full: 250ms !default;
14
+ $expandDurationFull: 300ms !default;
15
+ $collapseDurationFull: 250ms !default;
16
16
 
17
17
  // Motion Easing Curves
18
18
  // https://material.io/guidelines/motion/duration-easing.html#duration-easing-natural-easing-curves
19
19
 
20
20
  // FastOutSlowInInterpolator
21
- $mdw-motion__standard-easing: cubic-bezier(0.4, 0.0, 0.2, 1) !default;
22
- $mdw-motion__standard-peak-velocity: 0.30 !default;
21
+ $standardEasing: cubic-bezier(0.4, 0.0, 0.2, 1) !default;
22
+ $standardPeakVelocity: 0.30 !default;
23
23
 
24
24
  // LinearOutSlowInInterpolator
25
- $mdw-motion__decelerate-easing: cubic-bezier(0.0, 0.0, 0.2, 1) !default;
25
+ $decelerateEasing: cubic-bezier(0.0, 0.0, 0.2, 1) !default;
26
26
 
27
27
  // FastOutLinearInInterpolator
28
- $mdw-motion__accelerate-easing: cubic-bezier(0.4, 0.0, 1, 1) !default;
28
+ $accelerateEasing: cubic-bezier(0.4, 0.0, 1, 1) !default;
29
29
 
30
30
  // FastOutLinearInInterpolator
31
- $mdw-motion__sharp-easing: cubic-bezier(0.4, 0.0, 0.6, 1) !default;
31
+ $sharpEasing: cubic-bezier(0.4, 0.0, 0.6, 1) !default;
@@ -1,40 +1,34 @@
1
- /* stylelint-disable-next-line scss/at-function-pattern */
2
- @function dp($multiplier) {
3
- @return $multiplier * 1px;
4
- }
5
-
6
- @mixin mdw-platform__has-touch-support {
1
+ // Touch support based mixins
2
+ @mixin ifHasTouch {
7
3
  @media (any-pointer: coarse) {
8
4
  @content;
9
5
  }
10
6
  }
11
7
 
12
- @mixin mdw-platform__no-touch-support {
8
+ @mixin ifNoTouch {
13
9
  @media not all and (any-pointer: coarse) {
14
10
  @content;
15
11
  }
16
12
  }
17
13
 
18
14
  // Browser specific mixins
19
- @mixin mdw-platform__ie {
20
- @media screen and (-ms-high-contrast: active), (-ms-high-contrast: none) {
15
+ @mixin ifIE {
16
+ @media all\0 {
21
17
  @content;
22
18
  }
23
19
  }
24
20
 
25
- // Touch support based mixins
26
-
27
- @mixin mdw-platform__edge {
21
+ @mixin ifEdge {
28
22
  @supports (-ms-ime-align:auto) {
29
23
  @content;
30
24
  }
31
25
  }
32
26
 
33
- @mixin mdw-platform__ms {
34
- @include mdw-platform__ie {
27
+ @mixin ifMS {
28
+ @include ifIE {
35
29
  @content;
36
30
  }
37
- @include mdw-platform__edge {
31
+ @include ifEdge {
38
32
  @content;
39
33
  }
40
34
  }
package/core/_type.scss CHANGED
@@ -1,125 +1,126 @@
1
- @import './platform.scss';
1
+ @use './_length.scss' as *;
2
2
 
3
- $font-weight-thin: 100;
4
- $font-weight-light: 300;
5
- $font-weight-regular: 400; // normal
6
- $font-weight-medium: 500;
7
- $font-weight-bold: 700;
8
- $font-weight-black: 900;
3
+ $weightThin: 100 !default;
4
+ $weightLight: 300 !default;
5
+ $weightRegular: 400 !default;
6
+ $weightMedium: 500 !default;
7
+ $weightBold: 700 !default;
8
+ $weightBlack: 900 !default;
9
9
 
10
- @function sp($multiplier) {
11
- @return ($multiplier/16.0) * 1rem;
12
- }
13
-
14
- $mdw-types: (
10
+ $types: (
15
11
  h1: (
16
- font-weight: $font-weight-light,
12
+ font-weight: $weightLight,
17
13
  letter-spacing: sp(-1.5),
18
14
  font-size: sp(96),
19
15
  line-height: sp(112),
20
16
  ),
21
17
  h2: (
22
- font-weight: $font-weight-light,
18
+ font-weight: $weightLight,
23
19
  letter-spacing: sp(-0.5),
24
20
  font-size: sp(60),
25
21
  line-height: sp(72),
26
22
  ),
27
23
  h3: (
28
- font-weight: $font-weight-regular,
24
+ font-weight: $weightRegular,
29
25
  letter-spacing: 0,
30
26
  font-size: sp(48),
31
27
  line-height: sp(56),
32
28
  ),
33
29
  h4: (
34
- font-weight: $font-weight-regular,
30
+ font-weight: $weightRegular,
35
31
  letter-spacing: sp(0.25),
36
32
  font-size: sp(34),
37
33
  line-height: sp(40),
38
34
  ),
39
35
  h5: (
40
- font-weight: $font-weight-regular,
36
+ font-weight: $weightRegular,
41
37
  letter-spacing: 0,
42
38
  font-size: sp(24),
43
39
  line-height: sp(28),
44
40
  ),
45
41
  h6: (
46
- font-weight: $font-weight-medium,
42
+ font-weight: $weightMedium,
47
43
  letter-spacing: sp(0.15),
48
44
  font-size: sp(20),
49
45
  line-height: sp(24),
50
46
  ),
51
47
  subtitle: (
52
- font-weight: $font-weight-regular,
48
+ font-weight: $weightRegular,
53
49
  letter-spacing: sp(0.15),
54
50
  font-size: sp(16),
55
51
  line-height: sp(20),
56
52
  ),
57
53
  subtitle-2: (
58
- font-weight: $font-weight-medium,
54
+ font-weight: $weightMedium,
59
55
  letter-spacing: sp(0.1),
60
56
  font-size: sp(14),
61
57
  line-height: sp(16),
62
58
  ),
63
59
  body: (
64
- font-weight: $font-weight-regular,
60
+ font-weight: $weightRegular,
65
61
  letter-spacing: sp(0.5),
66
62
  font-size: sp(16),
67
63
  line-height: sp(24),
68
64
  ),
69
65
  body-2: (
70
- font-weight: $font-weight-regular,
66
+ font-weight: $weightRegular,
71
67
  letter-spacing: sp(0.25),
72
68
  font-size: sp(14),
73
69
  line-height: sp(20),
74
70
  ),
75
71
  button: (
76
- font-weight: $font-weight-medium,
72
+ font-weight: $weightMedium,
77
73
  text-transform: uppercase,
78
74
  letter-spacing: sp(1.25),
79
75
  font-size: sp(14),
80
76
  line-height: sp(16),
81
77
  ),
82
78
  caption: (
83
- font-weight: $font-weight-regular,
79
+ font-weight: $weightRegular,
84
80
  letter-spacing: sp(0.4),
85
81
  font-size: sp(12),
86
82
  line-height: sp(16),
87
83
  ),
88
84
  overline: (
89
- font-weight: $font-weight-regular,
85
+ font-weight: $weightRegular,
90
86
  letter-spacing: sp(1.5),
91
87
  font-size: sp(10),
92
88
  line-height: sp(12),
93
89
  ),
94
- );
90
+ ) !default;
95
91
 
96
- @mixin type-rules($type) {
97
- $rules: map-get($mdw-types, $type);
92
+ @mixin addRules($type) {
93
+ $rules: map-get($types, $type);
98
94
  @each $key in map-keys($rules) {
99
95
  #{$key}: map-get($rules, $key);
100
96
  }
101
97
  }
102
98
 
103
- @mixin baseline-top($dp) {
99
+ @mixin baselineToTop($dp) {
104
100
  &::before {
105
101
  content: '';
102
+
106
103
  display: inline-block;
104
+
107
105
  height: dp($dp);
108
106
  }
109
107
  }
110
108
 
111
- @mixin baseline-bottom($dp) {
109
+ @mixin baselineToBottom($dp) {
112
110
  &::after {
113
111
  content: '';
112
+
114
113
  display: inline-block;
115
114
  vertical-align: dp(-$dp);
116
115
  }
117
116
  }
118
117
 
119
- @mixin texttop-to-top($dp) {
118
+ @mixin textTopToTop($dp) {
120
119
  &::before {
121
- content: '';
120
+ content: "\200B";
121
+
122
122
  display: inline-block;
123
+
123
124
  height: 1em;
124
125
  margin-top: dp($dp);
125
126
  }
@@ -1,41 +1,141 @@
1
- import { dispatchDomEvent } from '../dom';
2
-
3
- export const SELECTED_CHANGED_EVENT = 'mdw:aria-selectedchanged';
1
+ import { dispatchDomEvent } from '../dom.js';
4
2
 
5
3
  /**
6
- * @param {Element} element
7
- * @param {'false'|'true'} value
8
- * @param {boolean} [dispatchEvent=true]
9
- * @return {boolean} changed
4
+ * @param {string} name Attribute Name
5
+ * @param {Element} element Element
6
+ * @param {string|boolean} value Boolean Attribute Value
7
+ * @param {string} [dispatchEventName] OnChangeEvent
8
+ * @param {boolean} [explicit=true]
9
+ * @param {string} [emptyValue=false] Default empty value
10
+ * @return {boolean} successful
10
11
  */
11
- export function setSelected(element, value, dispatchEvent = true) {
12
- const originalAttr = element.getAttribute('aria-selected');
13
- if (value === 'true') {
14
- if (originalAttr === 'true') {
15
- return false;
16
- }
17
- element.setAttribute('aria-selected', 'true');
12
+ function setAttribute(name, element, value, dispatchEventName, explicit = true, emptyValue = 'false') {
13
+ const attr = element.getAttribute(name);
14
+ let stringValue;
15
+ if (typeof value === 'string') {
16
+ stringValue = value;
18
17
  } else {
19
- if (originalAttr === 'false') {
20
- return false;
18
+ stringValue = (value ? 'true' : 'false');
19
+ }
20
+ if (attr === stringValue) {
21
+ // Nothing to change
22
+ return true;
23
+ }
24
+ if (stringValue === emptyValue) {
25
+ // Set default empty value
26
+ if (attr == null) {
27
+ // No attribute set
28
+ if (explicit) {
29
+ // Explicitly set attribute
30
+ element.setAttribute(name, stringValue);
31
+ }
32
+ return true;
21
33
  }
22
- if (!originalAttr || originalAttr !== 'false') {
23
- element.setAttribute('aria-selected', 'false');
24
- return false;
34
+ if (!explicit) {
35
+ element.removeAttribute(name);
36
+ } else {
37
+ element.setAttribute(name, stringValue);
25
38
  }
26
- element.setAttribute('aria-selected', 'false');
39
+ } else {
40
+ // Non default value;
41
+ element.setAttribute(name, stringValue);
27
42
  }
28
- if (!dispatchEvent) {
43
+ if (!dispatchEventName) {
29
44
  return true;
30
45
  }
31
- if (!dispatchDomEvent(element, SELECTED_CHANGED_EVENT)) {
46
+ // Alert change
47
+ if (!dispatchDomEvent(element, dispatchEventName, { value: stringValue })) {
32
48
  // Revert
33
- if (originalAttr == null) {
34
- element.removeAttribute('aria-selected');
49
+ if (attr == null) {
50
+ element.removeAttribute(name);
35
51
  } else {
36
- element.setAttribute('aria-selected', originalAttr);
52
+ element.setAttribute(name, attr);
37
53
  }
38
54
  return false;
39
55
  }
40
56
  return true;
41
57
  }
58
+
59
+ /**
60
+ * @param {Element} element
61
+ * @param {string|boolean} value
62
+ * @param {string} [dispatchEventName]
63
+ * @return {boolean} successful
64
+ */
65
+ export function setCurrent(element, value, dispatchEventName) {
66
+ // Some browsers incorrectly style [aria-current="false"]
67
+ // Attribute will be removed when false|"false"
68
+ return setAttribute('aria-current', element, value, dispatchEventName, false);
69
+ }
70
+
71
+ /**
72
+ * @param {Element} element
73
+ * @param {string|boolean} value
74
+ * @param {string} [dispatchEventName]
75
+ * @return {boolean} successful
76
+ */
77
+ export function setSelected(element, value, dispatchEventName) {
78
+ return setAttribute('aria-selected', element, value, dispatchEventName);
79
+ }
80
+
81
+ /**
82
+ * @param {Element} element
83
+ * @return {boolean}
84
+ */
85
+ export function isChecked(element) {
86
+ return element.getAttribute('aria-checked') === 'true';
87
+ }
88
+
89
+ /**
90
+ * @param {Element} element
91
+ * @param {string|boolean} value
92
+ * @param {string} [dispatchEventName]
93
+ * @return {boolean} successful
94
+ */
95
+ export function setChecked(element, value, dispatchEventName) {
96
+ return setAttribute('aria-checked', element, value, dispatchEventName);
97
+ }
98
+
99
+ /**
100
+ * @param {Element} element
101
+ * @return {boolean}
102
+ */
103
+ export function isDisabled(element) {
104
+ return element.getAttribute('aria-disabled') === 'true';
105
+ }
106
+
107
+ /**
108
+ * @param {Element} element
109
+ * @param {string|boolean} value
110
+ * @param {string} [dispatchEventName]
111
+ * @return {boolean} successful
112
+ */
113
+ export function setDisabled(element, value, dispatchEventName) {
114
+ return setAttribute('aria-disabled', element, value, dispatchEventName);
115
+ }
116
+
117
+ /**
118
+ * @param {Element} element
119
+ * @return {boolean}
120
+ */
121
+ export function isExpanded(element) {
122
+ return element.getAttribute('aria-expanded') === 'true';
123
+ }
124
+
125
+ /**
126
+ * @param {Element} element
127
+ * @param {string|boolean} value
128
+ * @param {string} [dispatchEventName]
129
+ * @return {boolean} successful
130
+ */
131
+ export function setExpanded(element, value, dispatchEventName) {
132
+ return setAttribute('aria-expanded', element, value, dispatchEventName);
133
+ }
134
+
135
+ /**
136
+ * @param {Element} element
137
+ * @return {boolean}
138
+ */
139
+ export function isReadonly(element) {
140
+ return element.getAttribute('aria-readonly') === 'true';
141
+ }
@@ -1,5 +1,28 @@
1
1
  // https://www.w3.org/TR/wai-aria-practices/#button
2
2
 
3
+ /**
4
+ * @param {KeyboardEvent} event
5
+ * @return {void}
6
+ */
7
+ function onKeyDown(event) {
8
+ if (event.key !== 'Enter' && event.key !== 'Spacebar' && event.key !== ' ') {
9
+ return;
10
+ }
11
+ /** @type {HTMLElement} */
12
+ const buttonElement = (event.currentTarget);
13
+ if (!buttonElement) {
14
+ return;
15
+ }
16
+ if (buttonElement.getAttribute('aria-disabled') === 'true') {
17
+ return;
18
+ }
19
+ event.stopPropagation();
20
+ event.preventDefault();
21
+ const newEvent = document.createEvent('Event');
22
+ newEvent.initEvent('click', true, true);
23
+ buttonElement.dispatchEvent(newEvent);
24
+ }
25
+
3
26
  /**
4
27
  * @param {Element} element
5
28
  * @return {void}
@@ -25,26 +48,3 @@ export function detach(element) {
25
48
  element.removeEventListener('keydown', onKeyDown);
26
49
  element.removeAttribute('mdw-aria-button-js');
27
50
  }
28
-
29
- /**
30
- * @param {KeyboardEvent} event
31
- * @return {void}
32
- */
33
- function onKeyDown(event) {
34
- if (event.key !== 'Enter' && event.key !== 'Spacebar' && event.key !== ' ') {
35
- return;
36
- }
37
- /** @type {HTMLElement} */
38
- const buttonElement = (event.currentTarget);
39
- if (!buttonElement) {
40
- return;
41
- }
42
- if (buttonElement.getAttribute('aria-disabled') === 'true') {
43
- return;
44
- }
45
- event.stopPropagation();
46
- event.preventDefault();
47
- const newEvent = document.createEvent('Event');
48
- newEvent.initEvent('click', true, true);
49
- buttonElement.dispatchEvent(newEvent);
50
- }
@@ -0,0 +1,93 @@
1
+ // Keyboard Navigation
2
+
3
+ import { dispatchDomEvent, isRtl } from '../dom.js';
4
+
5
+ export const FORWARD_ARROW_KEY = 'mdw:keyboard-forwardarrowkey';
6
+ export const BACK_ARROW_KEY = 'mdw:keyboard-backarrowkey';
7
+ export const UP_ARROW_KEY = 'mdw:keyboard-uparrowkey';
8
+ export const DOWN_ARROW_KEY = 'mdw:keyboard-downarrowkey';
9
+ export const HOME_KEY = 'mdw:keyboard-homekey';
10
+ export const END_KEY = 'mdw:keyboard-endkey';
11
+ export const PAGEUP_KEY = 'mdw:keyboard-pageupkey';
12
+ export const PAGEDOWN_KEY = 'mdw:keyboard-pagedownkey';
13
+ export const SPACEBAR_KEY = 'mdw:keyboard-spacebarkey';
14
+ export const ENTER_KEY = 'mdw:keyboard-enterkey';
15
+
16
+ /**
17
+ * @param {KeyboardEvent} event
18
+ * @return {void}
19
+ */
20
+ function onKeyDownHandler(event) {
21
+ /** @type {Element} */
22
+ const element = (event.currentTarget);
23
+ const detail = {
24
+ ctrlKey: event.ctrlKey,
25
+ shiftKey: event.shiftKey,
26
+ altKey: event.altKey,
27
+ metaKey: event.metaKey,
28
+ repeat: event.repeat,
29
+ };
30
+
31
+ let type;
32
+ switch (event.key) {
33
+ case 'Enter':
34
+ type = ENTER_KEY;
35
+ break;
36
+ case ' ':
37
+ case 'Spacebar':
38
+ type = SPACEBAR_KEY;
39
+ break;
40
+ case 'ArrowDown':
41
+ case 'Down':
42
+ type = DOWN_ARROW_KEY;
43
+ break;
44
+ case 'ArrowUp':
45
+ case 'Up':
46
+ type = UP_ARROW_KEY;
47
+ break;
48
+ case 'ArrowLeft':
49
+ case 'Left':
50
+ type = isRtl() ? FORWARD_ARROW_KEY : BACK_ARROW_KEY;
51
+ break;
52
+ case 'ArrowRight':
53
+ case 'Right':
54
+ type = isRtl() ? BACK_ARROW_KEY : FORWARD_ARROW_KEY;
55
+ break;
56
+ case 'Home':
57
+ type = HOME_KEY;
58
+ break;
59
+ case 'End':
60
+ type = END_KEY;
61
+ break;
62
+ case 'PageUp':
63
+ type = PAGEUP_KEY;
64
+ break;
65
+ case 'PageDown':
66
+ type = PAGEDOWN_KEY;
67
+ break;
68
+ default:
69
+ return;
70
+ }
71
+
72
+ if (!dispatchDomEvent(element, type, detail)) {
73
+ // preventDefault called
74
+ event.stopPropagation();
75
+ event.preventDefault();
76
+ }
77
+ }
78
+
79
+ /**
80
+ * @param {Element} element
81
+ * @return {void}
82
+ */
83
+ export function attach(element) {
84
+ element.addEventListener('keydown', onKeyDownHandler);
85
+ }
86
+
87
+ /**
88
+ * @param {Element} element
89
+ * @return {void}
90
+ */
91
+ export function detach(element) {
92
+ element.removeEventListener('keydown', onKeyDownHandler);
93
+ }