@shortfuse/materialdesignweb 0.2.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 (416) hide show
  1. package/.browserslistrc +2 -1
  2. package/.eslintrc.json +188 -30
  3. package/.stylelintrc.json +643 -2
  4. package/.vscode/launch.json +20 -5
  5. package/.vscode/settings.json +3 -0
  6. package/CHANGELOG.md +36 -0
  7. package/README.md +82 -2
  8. package/adapters/datatable/column.js +176 -0
  9. package/adapters/datatable/index.js +253 -437
  10. package/adapters/dom/index.js +586 -0
  11. package/adapters/list/index.js +36 -113
  12. package/adapters/search/index.js +153 -180
  13. package/components/appbar/_spec.scss +165 -0
  14. package/components/appbar/_theme.scss +0 -0
  15. package/components/appbar/index.scss +2 -0
  16. package/components/banner/_spec.scss +83 -0
  17. package/components/banner/_theme.scss +0 -0
  18. package/components/banner/index.scss +2 -0
  19. package/components/bottomnav/README.md +4 -4
  20. package/components/bottomnav/_spec.scss +149 -0
  21. package/components/bottomnav/_theme.scss +0 -0
  22. package/components/bottomnav/index.js +100 -120
  23. package/components/bottomnav/index.scss +2 -0
  24. package/components/bottomnav/item.js +88 -0
  25. package/components/button/README.md +16 -22
  26. package/components/button/_spec.scss +162 -0
  27. package/components/button/_theme.scss +42 -0
  28. package/components/button/index.eta +32 -0
  29. package/components/button/index.js +37 -48
  30. package/components/button/index.pug +18 -0
  31. package/components/button/index.scss +2 -0
  32. package/components/card/_spec.scss +241 -0
  33. package/components/card/_theme.scss +0 -0
  34. package/components/card/index.scss +2 -0
  35. package/components/chip/_spec.scss +111 -0
  36. package/components/chip/_theme.scss +105 -0
  37. package/components/chip/index.js +23 -0
  38. package/components/chip/index.scss +2 -0
  39. package/components/chip/item.js +20 -0
  40. package/components/datatable/_spec.scss +225 -0
  41. package/components/datatable/_theme.scss +128 -0
  42. package/components/datatable/cell.js +44 -0
  43. package/components/datatable/columnheader.js +46 -0
  44. package/components/datatable/index.js +339 -443
  45. package/components/datatable/index.scss +2 -0
  46. package/components/datatable/row.js +48 -0
  47. package/components/datatable/rowheader.js +18 -0
  48. package/components/dialog/_spec.scss +203 -0
  49. package/components/dialog/_theme.scss +7 -0
  50. package/components/dialog/index.js +512 -437
  51. package/components/dialog/index.scss +2 -0
  52. package/components/divider/_spec.scss +11 -0
  53. package/components/divider/_theme.scss +0 -0
  54. package/components/divider/index.scss +2 -0
  55. package/components/elevation/_spec.scss +9 -0
  56. package/components/elevation/_theme.scss +0 -0
  57. package/components/elevation/index.scss +2 -0
  58. package/components/fab/{style.scss → _spec.scss} +104 -79
  59. package/components/fab/_theme.scss +0 -0
  60. package/components/fab/index.js +85 -79
  61. package/components/fab/index.scss +2 -0
  62. package/components/grid/_spec.scss +169 -0
  63. package/components/grid/_theme.scss +0 -0
  64. package/components/grid/index.scss +2 -0
  65. package/components/layout/_mixins.scss +11 -0
  66. package/components/layout/_spec.scss +916 -0
  67. package/components/layout/_theme.scss +19 -0
  68. package/components/layout/index.js +454 -0
  69. package/components/layout/index.scss +2 -0
  70. package/components/list/_spec.scss +363 -0
  71. package/components/list/_theme.scss +102 -0
  72. package/components/list/content.js +106 -0
  73. package/components/list/index.js +234 -79
  74. package/components/list/index.scss +2 -0
  75. package/components/list/item.js +167 -0
  76. package/components/list/secondary.js +45 -0
  77. package/components/menu/_spec.scss +329 -0
  78. package/components/menu/_theme.scss +0 -0
  79. package/components/menu/index.js +636 -651
  80. package/components/menu/index.scss +2 -0
  81. package/components/menu/item.js +231 -0
  82. package/components/progress/_spec.scss +156 -0
  83. package/components/progress/_theme.scss +0 -0
  84. package/components/progress/index.js +29 -13
  85. package/components/progress/index.scss +2 -0
  86. package/components/selection/_spec.scss +376 -0
  87. package/components/selection/_theme.scss +134 -0
  88. package/components/selection/index.eta +60 -0
  89. package/components/selection/index.js +70 -0
  90. package/components/selection/index.pug +30 -0
  91. package/components/selection/index.scss +2 -0
  92. package/components/selection/input.js +54 -0
  93. package/components/selection/radiogroup.js +40 -0
  94. package/components/slider/{style.scss → _spec.scss} +31 -34
  95. package/components/slider/_theme.scss +0 -0
  96. package/components/slider/index.scss +2 -0
  97. package/components/snackbar/_spec.scss +150 -0
  98. package/components/snackbar/_theme.scss +0 -0
  99. package/components/snackbar/index.js +293 -206
  100. package/components/snackbar/index.scss +2 -0
  101. package/components/tab/_spec.scss +220 -0
  102. package/components/tab/_theme.scss +0 -0
  103. package/components/tab/content.js +210 -0
  104. package/components/tab/index.js +229 -213
  105. package/components/tab/index.scss +2 -0
  106. package/components/tab/item.js +88 -0
  107. package/components/tab/list.js +196 -0
  108. package/components/tab/panel.js +54 -0
  109. package/components/textfield/README.md +4 -4
  110. package/components/textfield/_spec.scss +763 -0
  111. package/components/textfield/_theme.scss +264 -0
  112. package/components/textfield/index.eta +74 -0
  113. package/components/textfield/index.js +132 -138
  114. package/components/textfield/index.pug +30 -0
  115. package/components/textfield/index.scss +2 -0
  116. package/components/tooltip/_spec.scss +185 -0
  117. package/components/tooltip/_theme.scss +0 -0
  118. package/components/tooltip/index.scss +2 -0
  119. package/components/type/_spec.scss +227 -0
  120. package/components/type/_theme.scss +0 -0
  121. package/components/type/index.scss +2 -0
  122. package/core/_breakpoint.scss +189 -0
  123. package/core/_elevation.scss +78 -0
  124. package/core/_length.scss +8 -0
  125. package/core/_motion.scss +31 -0
  126. package/core/_platform.scss +12 -0
  127. package/core/_type.scss +128 -0
  128. package/core/aria/attributes.js +141 -0
  129. package/core/aria/button.js +49 -0
  130. package/core/aria/keyboard.js +92 -0
  131. package/core/aria/rovingtabindex.js +175 -0
  132. package/core/aria/tab.js +59 -0
  133. package/core/document/index.js +39 -0
  134. package/core/dom.js +180 -0
  135. package/core/overlay/_spec.scss +28 -0
  136. package/core/overlay/_theme.scss +147 -0
  137. package/core/overlay/index.js +95 -0
  138. package/core/overlay/index.scss +2 -0
  139. package/core/ripple/_spec.scss +196 -0
  140. package/core/ripple/_theme.scss +20 -0
  141. package/core/ripple/index.js +286 -0
  142. package/core/ripple/index.scss +2 -0
  143. package/core/theme/_aliases.scss +15 -0
  144. package/core/theme/_config.scss +8 -0
  145. package/core/theme/_functions.scss +22 -0
  146. package/{components/theming/palettes.scss → core/theme/_palettes.scss} +173 -151
  147. package/core/theme/_spec.scss +0 -0
  148. package/core/theme/_theme.scss +268 -0
  149. package/core/theme/index.js +50 -0
  150. package/core/theme/index.scss +4 -0
  151. package/core/throttler.js +42 -0
  152. package/core/transition/index.js +465 -0
  153. package/docs/_flex.scss +28 -0
  154. package/docs/_menuoptions.js +183 -0
  155. package/docs/_partials/_androidnavbar.eta +5 -0
  156. package/docs/_partials/_androidstatusbar.eta +13 -0
  157. package/docs/_partials/_appbar.eta +27 -0
  158. package/docs/_partials/_buttontest.eta +31 -0
  159. package/docs/_partials/_header.eta +146 -0
  160. package/docs/_partials/_navlistitem.eta +16 -0
  161. package/docs/_partials/_target.eta +1 -0
  162. package/docs/_sample-utils.js +88 -0
  163. package/docs/{src/storage.js → _storage.js} +0 -0
  164. package/docs/docs.scss +331 -0
  165. package/docs/framework.scss +26 -0
  166. package/docs/index.eta +12 -0
  167. package/docs/index.js +7 -0
  168. package/docs/pages/appbar.eta +108 -0
  169. package/docs/pages/appbar.js +0 -0
  170. package/docs/pages/bottomnav.eta +188 -0
  171. package/docs/pages/bottomnav.js +118 -0
  172. package/docs/pages/button.eta +124 -0
  173. package/docs/pages/button.js +224 -0
  174. package/docs/pages/card.eta +90 -0
  175. package/docs/pages/card.js +175 -0
  176. package/docs/pages/chip.eta +122 -0
  177. package/docs/pages/chip.js +80 -0
  178. package/docs/pages/color.eta +143 -0
  179. package/docs/pages/color.js +261 -0
  180. package/docs/pages/datatable.eta +323 -0
  181. package/docs/pages/datatable.js +160 -0
  182. package/docs/pages/dialog.eta +184 -0
  183. package/docs/{src/components → pages}/dialog.js +35 -48
  184. package/docs/pages/dom.eta +26 -0
  185. package/docs/pages/dom.js +140 -0
  186. package/docs/pages/elevation.eta +35 -0
  187. package/docs/pages/elevation.js +0 -0
  188. package/docs/pages/fab.eta +99 -0
  189. package/docs/{src/components → pages}/fab.js +6 -13
  190. package/docs/pages/grid.eta +135 -0
  191. package/docs/pages/grid.js +128 -0
  192. package/docs/pages/layout.eta +8 -0
  193. package/docs/pages/layout.js +0 -0
  194. package/docs/pages/list.eta +465 -0
  195. package/docs/pages/list.js +8 -0
  196. package/docs/pages/menu.eta +274 -0
  197. package/docs/{src/components → pages}/menu.js +26 -42
  198. package/docs/pages/overlay.eta +69 -0
  199. package/docs/pages/overlay.js +3 -0
  200. package/docs/pages/progress.eta +23 -0
  201. package/docs/{src/components → pages}/progress.js +2 -4
  202. package/docs/pages/ripple.eta +27 -0
  203. package/docs/pages/ripple.js +3 -0
  204. package/docs/pages/search.eta +242 -0
  205. package/docs/pages/search.js +226 -0
  206. package/docs/pages/selection.eta +107 -0
  207. package/docs/pages/selection.js +12 -0
  208. package/docs/pages/slider.eta +23 -0
  209. package/docs/pages/slider.js +0 -0
  210. package/docs/pages/snackbar.eta +83 -0
  211. package/docs/{src/components → pages}/snackbar.js +31 -36
  212. package/docs/pages/tab.eta +407 -0
  213. package/docs/pages/tab.js +152 -0
  214. package/docs/pages/textfield.eta +487 -0
  215. package/docs/{src/components → pages}/textfield.js +41 -45
  216. package/docs/pages/tooltip.eta +92 -0
  217. package/docs/pages/tooltip.js +0 -0
  218. package/docs/pages/transition.eta +117 -0
  219. package/docs/pages/transition.js +52 -0
  220. package/docs/pages/type.eta +31 -0
  221. package/docs/pages/type.js +0 -0
  222. package/docs/postrender.js +41 -0
  223. package/docs/prerender.js +16 -0
  224. package/docs/pwa/_dialogs.eta +143 -0
  225. package/docs/pwa/_menus.eta +16 -0
  226. package/docs/pwa/pwa-prerender.js +3 -0
  227. package/docs/pwa/pwa.eta +478 -0
  228. package/docs/pwa/pwa.js +298 -0
  229. package/docs/pwa/pwa.scss +31 -0
  230. package/docs/themes/theme-colored.scss +15 -0
  231. package/docs/themes/theme-default.scss +3 -0
  232. package/index.scss +27 -0
  233. package/jsconfig.json +8 -2
  234. package/package.json +54 -27
  235. package/scripts/deploy-docs.sh +9 -0
  236. package/templates/index.eta +2 -0
  237. package/templates/index.pug +3 -0
  238. package/tsconfig.json +16 -0
  239. package/utils/function.js +3 -0
  240. package/webpack.config.js +224 -68
  241. package/_index.scss +0 -4
  242. package/components/all-components.scss +0 -21
  243. package/components/bottomnav/style.scss +0 -190
  244. package/components/bottomnav/theming.scss +0 -76
  245. package/components/button/style.scss +0 -315
  246. package/components/button/theming.scss +0 -134
  247. package/components/card/style.scss +0 -175
  248. package/components/card/theming.scss +0 -43
  249. package/components/common/dom.js +0 -51
  250. package/components/common/functions.scss +0 -174
  251. package/components/common/mixins.scss +0 -122
  252. package/components/common/motion.scss +0 -36
  253. package/components/common/type.scss +0 -104
  254. package/components/common/variables.scss +0 -46
  255. package/components/datatable/style.scss +0 -257
  256. package/components/datatable/theming.scss +0 -119
  257. package/components/dialog/style.scss +0 -159
  258. package/components/dialog/theming.scss +0 -29
  259. package/components/divider/style.scss +0 -7
  260. package/components/divider/theming.scss +0 -20
  261. package/components/elevation/style.scss +0 -32
  262. package/components/layout/style.scss +0 -223
  263. package/components/list/style.scss +0 -358
  264. package/components/list/theming.scss +0 -83
  265. package/components/menu/style.scss +0 -280
  266. package/components/menu/theming.scss +0 -80
  267. package/components/navdrawer/index.js +0 -200
  268. package/components/navdrawer/style.scss +0 -595
  269. package/components/navdrawer/theming.scss +0 -62
  270. package/components/progress/style.scss +0 -136
  271. package/components/ripple/index.js +0 -63
  272. package/components/ripple/ripple.scss +0 -122
  273. package/components/selection/style.scss +0 -320
  274. package/components/selection/theming.scss +0 -98
  275. package/components/snackbar/style.scss +0 -212
  276. package/components/switch/style.scss +0 -3
  277. package/components/tab/style.scss +0 -275
  278. package/components/tab/theming.scss +0 -34
  279. package/components/template/theming.scss +0 -31
  280. package/components/textfield/style.scss +0 -795
  281. package/components/textfield/theming.scss +0 -256
  282. package/components/theming/globals.scss +0 -25
  283. package/components/theming/theming.scss +0 -559
  284. package/components/toolbar/style.scss +0 -190
  285. package/components/toolbar/theming.scss +0 -32
  286. package/components/tooltip/style.scss +0 -135
  287. package/components/type/style.scss +0 -167
  288. package/components/type/theming.scss +0 -25
  289. package/docs/bottomnav.html +0 -1
  290. package/docs/bottomnav.min.js +0 -2
  291. package/docs/bottomnav.min.js.map +0 -1
  292. package/docs/button.html +0 -1
  293. package/docs/button.min.js +0 -2
  294. package/docs/button.min.js.map +0 -1
  295. package/docs/card.html +0 -1
  296. package/docs/card.min.js +0 -2
  297. package/docs/card.min.js.map +0 -1
  298. package/docs/components.min.css +0 -1
  299. package/docs/components.min.js +0 -2
  300. package/docs/components.min.js.map +0 -1
  301. package/docs/datatable.html +0 -1
  302. package/docs/datatable.min.js +0 -2
  303. package/docs/datatable.min.js.map +0 -1
  304. package/docs/dialog.html +0 -1
  305. package/docs/dialog.min.js +0 -2
  306. package/docs/dialog.min.js.map +0 -1
  307. package/docs/docs.min.css +0 -1
  308. package/docs/docs.min.js +0 -2
  309. package/docs/docs.min.js.map +0 -1
  310. package/docs/elevation.html +0 -1
  311. package/docs/elevation.min.js +0 -2
  312. package/docs/elevation.min.js.map +0 -1
  313. package/docs/fab.html +0 -1
  314. package/docs/fab.min.js +0 -2
  315. package/docs/fab.min.js.map +0 -1
  316. package/docs/index.html +0 -1
  317. package/docs/index.min.js +0 -2
  318. package/docs/index.min.js.map +0 -1
  319. package/docs/layout.html +0 -1
  320. package/docs/layout.min.js +0 -2
  321. package/docs/layout.min.js.map +0 -1
  322. package/docs/list.html +0 -1
  323. package/docs/list.min.js +0 -2
  324. package/docs/list.min.js.map +0 -1
  325. package/docs/menu.html +0 -1
  326. package/docs/menu.min.js +0 -2
  327. package/docs/menu.min.js.map +0 -1
  328. package/docs/navdrawer.html +0 -1
  329. package/docs/navdrawer.min.js +0 -2
  330. package/docs/navdrawer.min.js.map +0 -1
  331. package/docs/prerender.min.js +0 -2
  332. package/docs/prerender.min.js.map +0 -1
  333. package/docs/progress.html +0 -1
  334. package/docs/progress.min.js +0 -2
  335. package/docs/progress.min.js.map +0 -1
  336. package/docs/search.html +0 -1
  337. package/docs/search.min.js +0 -2
  338. package/docs/search.min.js.map +0 -1
  339. package/docs/selection.html +0 -1
  340. package/docs/selection.min.js +0 -2
  341. package/docs/selection.min.js.map +0 -1
  342. package/docs/slider.html +0 -1
  343. package/docs/slider.min.js +0 -2
  344. package/docs/slider.min.js.map +0 -1
  345. package/docs/snackbar.html +0 -1
  346. package/docs/snackbar.min.js +0 -2
  347. package/docs/snackbar.min.js.map +0 -1
  348. package/docs/src/components/bottomnav.js +0 -16
  349. package/docs/src/components/bottomnav.pug +0 -112
  350. package/docs/src/components/button.js +0 -156
  351. package/docs/src/components/button.pug +0 -194
  352. package/docs/src/components/card.js +0 -136
  353. package/docs/src/components/card.pug +0 -133
  354. package/docs/src/components/datatable.js +0 -183
  355. package/docs/src/components/datatable.pug +0 -324
  356. package/docs/src/components/dialog.pug +0 -138
  357. package/docs/src/components/elevation.js +0 -3
  358. package/docs/src/components/elevation.pug +0 -17
  359. package/docs/src/components/fab.pug +0 -84
  360. package/docs/src/components/layout.js +0 -116
  361. package/docs/src/components/layout.pug +0 -104
  362. package/docs/src/components/list.js +0 -15
  363. package/docs/src/components/list.pug +0 -293
  364. package/docs/src/components/menu.pug +0 -292
  365. package/docs/src/components/navdrawer.js +0 -112
  366. package/docs/src/components/navdrawer.pug +0 -113
  367. package/docs/src/components/progress.pug +0 -17
  368. package/docs/src/components/search.js +0 -206
  369. package/docs/src/components/search.pug +0 -149
  370. package/docs/src/components/selection.js +0 -6
  371. package/docs/src/components/selection.pug +0 -116
  372. package/docs/src/components/slider.js +0 -3
  373. package/docs/src/components/slider.pug +0 -19
  374. package/docs/src/components/snackbar.pug +0 -145
  375. package/docs/src/components/tab.js +0 -137
  376. package/docs/src/components/tab.pug +0 -329
  377. package/docs/src/components/textfield.pug +0 -416
  378. package/docs/src/components/toolbar.js +0 -6
  379. package/docs/src/components/toolbar.pug +0 -86
  380. package/docs/src/components/tooltip.js +0 -6
  381. package/docs/src/components/tooltip.pug +0 -76
  382. package/docs/src/components/type.js +0 -6
  383. package/docs/src/components/type.pug +0 -34
  384. package/docs/src/components.scss +0 -1
  385. package/docs/src/docs.scss +0 -284
  386. package/docs/src/index.js +0 -3
  387. package/docs/src/index.pug +0 -6
  388. package/docs/src/menuoptions.js +0 -136
  389. package/docs/src/mixins.pug +0 -139
  390. package/docs/src/prerender.js +0 -26
  391. package/docs/src/sample-utils.js +0 -108
  392. package/docs/src/targetHandler.js +0 -50
  393. package/docs/src/theming.ie11.scss +0 -18
  394. package/docs/src/theming.scss +0 -18
  395. package/docs/tab.html +0 -1
  396. package/docs/tab.min.js +0 -2
  397. package/docs/tab.min.js.map +0 -1
  398. package/docs/textfield.html +0 -2
  399. package/docs/textfield.min.js +0 -2
  400. package/docs/textfield.min.js.map +0 -1
  401. package/docs/theming.ie11.min.css +0 -1
  402. package/docs/theming.ie11.min.js +0 -2
  403. package/docs/theming.ie11.min.js.map +0 -1
  404. package/docs/theming.min.css +0 -1
  405. package/docs/theming.min.js +0 -2
  406. package/docs/theming.min.js.map +0 -1
  407. package/docs/toolbar.html +0 -1
  408. package/docs/toolbar.min.js +0 -2
  409. package/docs/toolbar.min.js.map +0 -1
  410. package/docs/tooltip.html +0 -1
  411. package/docs/tooltip.min.js +0 -2
  412. package/docs/tooltip.min.js.map +0 -1
  413. package/docs/type.html +0 -1
  414. package/docs/type.min.js +0 -2
  415. package/docs/type.min.js.map +0 -1
  416. package/index.js +0 -16
@@ -0,0 +1,88 @@
1
+ // https://www.w3.org/TR/wai-aria-1.1/#tab
2
+
3
+ import * as AriaTab from '../../core/aria/tab.js';
4
+ import * as Overlay from '../../core/overlay/index.js';
5
+ import * as Ripple from '../../core/ripple/index.js';
6
+
7
+ export const SELECTED_CHANGE_EVENT = 'mdw:bottomnavitem-selectedchange';
8
+
9
+ /**
10
+ * @param {Element} element
11
+ * @param {string|boolean} value
12
+ * @param {boolean} [dispatchEvent=true]
13
+ * @return {boolean} successful
14
+ */
15
+ export function setSelected(element, value, dispatchEvent = true) {
16
+ return AriaTab.setSelected(element, value, dispatchEvent ? SELECTED_CHANGE_EVENT : null);
17
+ }
18
+
19
+ /**
20
+ * @param {MouseEvent} event
21
+ * @return {void}
22
+ */
23
+ function onClick(event) {
24
+ const element = /** @type {HTMLElement} */ (event.currentTarget);
25
+ if (element.getAttribute('aria-disabled') === 'true') {
26
+ return;
27
+ }
28
+ setSelected(element, true);
29
+ }
30
+
31
+ /**
32
+ * @param {Element} element
33
+ * @return {void}
34
+ */
35
+ export function attachAria(element) {
36
+ AriaTab.attach(element);
37
+ for (const el of element.getElementsByClassName('mdw-bottomnav__icon')) {
38
+ el.setAttribute('aria-hidden', 'true');
39
+ }
40
+ }
41
+
42
+ /**
43
+ * @param {Element} element
44
+ * @return {void}
45
+ */
46
+ export function attachCore(element) {
47
+ attachAria(element);
48
+ element.addEventListener('click', onClick);
49
+ }
50
+
51
+ /**
52
+ * @param {Element} element
53
+ * @return {void}
54
+ */
55
+ export function attach(element) {
56
+ element.classList.add('mdw-overlay');
57
+ if (!element.hasAttribute('mdw-overlay-off')) {
58
+ element.setAttribute('mdw-overlay-off', 'selected activated');
59
+ }
60
+ if (!element.hasAttribute('mdw-overlay-default')) {
61
+ element.setAttribute('mdw-overlay-default', 'medium');
62
+ }
63
+ Overlay.attach(element);
64
+
65
+ element.classList.add('mdw-ripple');
66
+ Ripple.attach(element);
67
+
68
+ attachCore(element);
69
+ }
70
+
71
+ /**
72
+ * @param {Element} element
73
+ * @return {void}
74
+ */
75
+ export function detachCore(element) {
76
+ AriaTab.detach(element);
77
+ element.removeEventListener('click', onClick);
78
+ }
79
+
80
+ /**
81
+ * @param {Element} element
82
+ * @return {void}
83
+ */
84
+ export function detach(element) {
85
+ detachCore(element);
86
+ Ripple.detach(element);
87
+ Overlay.detach(element);
88
+ }
@@ -11,34 +11,36 @@
11
11
  .mdw-button(mdw-raised)
12
12
  ```
13
13
 
14
- ## Always Raised
14
+ ## Colored (Primary)
15
15
  ```
16
- .mdw-button(mdw-raised="always")
16
+ .mdw-button.mdw-theme(mdw-ink="primary contrast")
17
17
  ```
18
18
 
19
- ## Colored
19
+ ## Colored (Custom)
20
20
  ```
21
- .mdw-button(mdw-theme-color="primary")
21
+ .mdw-button.mdw-theme(mdw-ink="green contrast")
22
22
  ```
23
23
 
24
- ## Colored (Custom Tone)
24
+ ## Filled Light
25
25
  ```
26
- .mdw-button(mdw-theme-color="accent-A100")
26
+ .mdw-button.mdw-theme(mdw-surface="primary 100" mdw-light)
27
27
  ```
28
28
 
29
- ## Filled
29
+ ## Filled Dark
30
30
  ```
31
- .mdw-button(mdw-theme-fill="primary")
31
+ .mdw-button.mdw-theme(mdw-surface="secondary 600" mdw-dark)
32
32
  ```
33
33
 
34
- ## Filled (Custom Tone)
34
+ ## Toggled
35
35
  ```
36
- .mdw-button(mdw-theme-fill="accent-A400")
36
+ .mdw-button(aria-pressed="true")
37
37
  ```
38
38
 
39
- ## Filled (Custom Tone)
39
+ ## Disabled
40
40
  ```
41
- .mdw-button(disabled)
41
+ a.mdw-button(disabled)
42
+ button.mdw-button(disabled)
43
+ .mdw-button(aria-disabled="true")
42
44
  ```
43
45
 
44
46
  ## Icon Button
@@ -46,22 +48,14 @@
46
48
  .mdw-button(mdw-icon).material-icons favorite
47
49
  ```
48
50
 
49
- ## Focus Ring
50
- ```
51
- .mdw-button
52
- .mdw-button__focus-ring
53
- ```
54
-
55
51
  # Javascript
56
52
 
57
53
  ```
58
- document.querySelectorAll(".mdw-button").forEach((element) => {
59
- new mdw.Button(element);
60
- });
54
+ for (const el of document.getElementsByClassName("mdw-button")) Button.attach(el);
61
55
  ```
62
56
 
63
57
  # Notes
64
58
 
65
59
  The click ripple aftereffect is centered when using keyboard or when using only CSS. Initializing the element with Javascript will ensure the ripple will spawn from the cursor position.
66
60
 
67
- Use of `HTMLElementButton` or `HTMLAnchorElement` is supported, but note that using interactive content descendents violates the HTML specifications. Therefore, some browsers may not apply interactive elements such as ripples or focus rings.
61
+ Use of `HTMLElementButton` or `HTMLAnchorElement` is supported, but note that using interactive content descendents violates the HTML specifications. Therefore, some browsers may not apply interactive elements such as ripples.
@@ -0,0 +1,162 @@
1
+ // https://material.io/guidelines/components/buttons.html#buttons-raised-buttons
2
+ // https://material.io/guidelines/style/icons.html#
3
+
4
+ @use '../../core/_elevation.scss' as elevation;
5
+ @use '../../core/_length.scss' as *;
6
+ @use '../../core/_motion.scss' as motion;
7
+ @use '../../core/_platform.scss' as platform;
8
+ @use '../../core/_type.scss' as type;
9
+
10
+ :root {
11
+ --mdw-button__click-target-size: 48px;
12
+ --mdw-button__outline-size: 1px;
13
+ }
14
+
15
+ .mdw-button {
16
+ display: inline-flex;
17
+ position: relative;
18
+ align-items: center;
19
+ justify-content: center;
20
+ overflow: hidden;
21
+
22
+ box-sizing: border-box;
23
+ block-size: 36px;
24
+ min-inline-size: 64px;
25
+ margin: 0 8px;
26
+ border: none;
27
+ padding: 0 8px;
28
+
29
+ -moz-appearance: none;
30
+ -webkit-appearance: none;
31
+ appearance: none;
32
+ cursor: pointer;
33
+ -webkit-tap-highlight-color: transparent;
34
+ -moz-user-select: none;
35
+ -ms-user-select: none;
36
+ -webkit-user-select: none;
37
+ user-select: none;
38
+
39
+ transition-duration: motion.$shapeChangeDuration, motion.$simpleDuration;
40
+ transition-property: box-shadow, background-color, color;
41
+ transition-timing-function: motion.$standardEasing;
42
+
43
+ z-index: 0;
44
+
45
+ border-radius: 4px;
46
+ color: inherit;
47
+
48
+ text-align: center;
49
+ text-decoration: none;
50
+
51
+ // Remove Firefox inner
52
+
53
+ &::-moz-focus-inner {
54
+ border: 0;
55
+ }
56
+
57
+ &[mdw-border-ink],
58
+ &[mdw-surface] {
59
+ padding: 0 16px;
60
+ }
61
+
62
+ &:not([mdw-surface]) {
63
+ background-color: transparent;
64
+ }
65
+
66
+ // Don't override font icon properties
67
+
68
+ &:not([mdw-icon]) {
69
+ @include type.addRules('button');
70
+ font-family: inherit;
71
+ word-spacing: normal;
72
+ }
73
+
74
+ &[mdw-border-ink] {
75
+ border-style: solid;
76
+ border-width: var(--mdw-button__outline-size);
77
+
78
+ &::before,
79
+ & > .mdw-ripple {
80
+ box-sizing: content-box;
81
+ block-size: 100%;
82
+ inline-size: 100%;
83
+ margin-block-start: calc(-1 * var(--mdw-button__outline-size));
84
+ margin-inline-start: calc(-1 * var(--mdw-button__outline-size));
85
+ padding-block-end: calc(2 * var(--mdw-button__outline-size));
86
+ padding-inline-end: calc(2 * var(--mdw-button__outline-size));
87
+ }
88
+ }
89
+
90
+ // Icon properties
91
+
92
+ &[mdw-icon] {
93
+ block-size: 40px;
94
+ min-inline-size: 40px;
95
+ padding: 8px;
96
+
97
+ -moz-user-select: none;
98
+ -ms-user-select: none;
99
+ -webkit-user-select: none;
100
+ user-select: none;
101
+
102
+ border-radius: 50%;
103
+
104
+ font-size: 24px; // Internal padding provided by font
105
+ }
106
+
107
+ &[mdw-image] {
108
+ block-size: 24px;
109
+ min-inline-size: 24px;
110
+ margin: 0;
111
+ padding: 0;
112
+
113
+ -ms-user-select: none;
114
+ -moz-user-select: none;
115
+ -webkit-user-select: none;
116
+ user-select: none;
117
+
118
+ border-radius: 50%;
119
+
120
+ & > {
121
+ position: absolute;
122
+ inset-block-start: 0;
123
+ inset-inline-start: 0;
124
+
125
+ block-size: 100%;
126
+ inline-size: auto;
127
+ }
128
+ }
129
+ }
130
+
131
+ // Extended touch target
132
+ @mixin touchTarget {
133
+ @include platform.ifHasTouch() {
134
+ content: "";
135
+
136
+ position: absolute;
137
+ inset-block-start: 50%;
138
+ inset-inline-start: 0;
139
+
140
+ block-size: var(--mdw-button__click-target-size);
141
+ inline-size: 100%;
142
+
143
+ transform: translateY(-50%);
144
+ }
145
+ }
146
+
147
+ // Raised
148
+
149
+ .mdw-button[mdw-raised]:not([disabled]):not([aria-disabled="true"]) {
150
+ @include elevation.boxShadowMixin(2);
151
+
152
+ &:active {
153
+ @include elevation.boxShadowMixin(8);
154
+ }
155
+ }
156
+
157
+ // Disabled
158
+ .mdw-button[disabled],
159
+ .mdw-button[aria-disabled="true"] {
160
+ /* stylelint-disable-next-line plugin/no-unsupported-browser-features */
161
+ cursor: not-allowed;
162
+ }
@@ -0,0 +1,42 @@
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
+
5
+ .mdw-theme {
6
+ --mdw-button__default-text-rgb: var(--mdw-ink-default);
7
+ --mdw-button__disabled-text-rgb: var(--mdw-ink-default);
8
+ --mdw-button__disabled-surface-text-rgb: var(--mdw-ink-default);
9
+ --mdw-button__disabled-surface-background-rgb: var(--mdw-ink-default);
10
+ --mdw-button__default-text-opacity: var(--mdw-high-opacity);
11
+ --mdw-button__disabled-text-opacity: var(--mdw-inactive-opacity);
12
+ --mdw-button__disabled-surface-text-opacity: var(--mdw-high-opacity);
13
+ --mdw-button__disabled-surface-background-opacity: var(--mdw-inactive-opacity);
14
+ }
15
+
16
+ .mdw-button {
17
+ &:disabled:not([aria-disabled="true"]) {
18
+ color: RGBA(var(--mdw-button__disabled-text-rgb), var(--mdw-button__disabled-text-opacity));
19
+
20
+ &.mdw-overlay::before {
21
+ display: none;
22
+ }
23
+ }
24
+
25
+ &.mdw-overlay[aria-disabled="true"] {
26
+ // Sets foreground to default ink color
27
+ color: RGBA(var(--mdw-button__default-text-rgb), var(--mdw-button__default-text-opacity));
28
+
29
+ &[mdw-surface] {
30
+ background-color: RGBA(var(--mdw-button__disabled-surface-background-rgb), var(--mdw-button__disabled-surface-background-opacity));
31
+ color: RGBA(var(--mdw-button__disabled-surface-text-rgb), var(--mdw-button__disabled-surface-text-opacity));
32
+
33
+ &[mdw-dark],
34
+ &[mdw-light] {
35
+ --mdw-button__disabled-surface-text-rgb: inherit;
36
+ --mdw-button__disabled-surface-text-opacity: inherit;
37
+ --mdw-button__disabled-surface-background-rgb: inherit;
38
+ --mdw-button__disabled-surface-background-opacity: inherit;
39
+ }
40
+ }
41
+ }
42
+ }
@@ -0,0 +1,32 @@
1
+ <a <%~ Object.entries({
2
+ 'class': [
3
+ 'mdw-button',
4
+ it?.overlay != false ? 'mdw-overlay' : '',
5
+ it?.ripple != false ? 'mdw-ripple' : '',
6
+ it?.ink || it?.surface || it?.light || it?.dark || it?.borderInk || it?.theme ? 'mdw-theme' : '',
7
+ it?.class,
8
+ ].filter(v=>v).join(' '),
9
+ id: it?.id,
10
+ 'mdw-ink': it?.ink,
11
+ 'mdw-surface': it?.surface,
12
+ 'mdw-border-ink': it?.borderInk,
13
+ 'mdw-light': it?.light,
14
+ 'mdw-dark': it?.dark,
15
+ 'mdw-icon': it?.icon,
16
+ 'mdw-raised': it?.raised,
17
+ 'mdw-more-button': it?.moreButton ?? (
18
+ it?.icon && (it?.text === 'more_vert' || it?.body === 'more_vert') && it?.class?.split(' ').includes('material-icons')),
19
+ 'disabled': it?.disabled && it?.disabled !== 'false',
20
+ 'aria-disabled': it?.disabled === true ? 'true' : it?.disabled,
21
+ 'tabindex': it?.tabindex || '0',
22
+ 'href': it?.href,
23
+ ...it?.attributes,
24
+ }).map(([key, value]) => {
25
+ if (value === true) return key;
26
+ if (value === false || value == null) return false;
27
+ return `${key}="${value}"`
28
+ }).filter(v=>v).join(' ')-%>>
29
+
30
+ <%_~ it?.body ?? '' %><%= it?.text ?? '' _%>
31
+
32
+ </a>
@@ -1,54 +1,43 @@
1
+ /** @see https://www.w3.org/TR/wai-aria-practices/#button */
1
2
 
2
- // https://www.w3.org/TR/wai-aria-practices/#button
3
+ import * as AriaButton from '../../core/aria/button.js';
4
+ import * as Overlay from '../../core/overlay/index.js';
5
+ import * as Ripple from '../../core/ripple/index.js';
3
6
 
4
- import { Ripple } from '../ripple/index';
5
-
6
- class Button {
7
- /**
8
- * @param {Element} element
9
- * @return {void}
10
- */
11
- static attach(element) {
12
- element.setAttribute('mdw-js', '');
13
- if (!element.hasAttribute('mdw-icon')) {
14
- Ripple.attach(element);
15
- }
16
- if (element instanceof HTMLButtonElement === false
17
- && element instanceof HTMLInputElement === false) {
18
- element.addEventListener('keydown', Button.onKeyDown);
19
- }
20
- }
7
+ /**
8
+ * @param {Element} element
9
+ * @return {void}
10
+ */
11
+ export function attachCore(element) {
12
+ AriaButton.attach(element);
13
+ }
21
14
 
22
- /**
23
- * @param {Element} element
24
- * @return {void}
25
- */
26
- static detach(element) {
27
- element.removeEventListener('keydown', Button.onKeyDown);
28
- element.removeAttribute('mdw-js');
29
- Ripple.detach(element);
30
- }
15
+ /**
16
+ * @param {Element} element
17
+ * @return {void}
18
+ */
19
+ export function attach(element) {
20
+ element.classList.add('mdw-overlay');
21
+ Ripple.attach(element);
22
+ element.classList.add('mdw-ripple');
23
+ Overlay.attach(element);
24
+ attachCore(element);
25
+ }
31
26
 
32
- /**
33
- * @param {KeyboardEvent} event
34
- * @return {void}
35
- */
36
- static onKeyDown(event) {
37
- if (event.key !== 'Enter' && event.key !== 'Spacebar' && event.key !== ' ') {
38
- return;
39
- }
40
- const buttonElement = event.currentTarget;
41
- if (!buttonElement) {
42
- return;
43
- }
44
- event.stopPropagation();
45
- event.preventDefault();
46
- const newEvent = document.createEvent('Event');
47
- newEvent.initEvent('click', true, true);
48
- buttonElement.dispatchEvent(newEvent);
49
- }
27
+ /**
28
+ * @param {Element} element
29
+ * @return {void}
30
+ */
31
+ export function detachCore(element) {
32
+ AriaButton.detach(element);
50
33
  }
51
34
 
52
- export {
53
- Button,
54
- };
35
+ /**
36
+ * @param {Element} element
37
+ * @return {void}
38
+ */
39
+ export function detach(element) {
40
+ detachCore(element);
41
+ Ripple.detach(element);
42
+ Overlay.detach(element);
43
+ }
@@ -0,0 +1,18 @@
1
+ mixin mdwButton(options={})
2
+ a.mdw-button(class=([
3
+ options.overlay != false ? 'mdw-overlay' : '',
4
+ options.ripple != false ? 'mdw-ripple' : '',
5
+ options.ink || options.surface || options.light || options.dark || options.borderInk ? 'mdw-theme' : '',
6
+ ].filter(v=>v).join(' '))
7
+ mdw-ink=(options.ink)
8
+ mdw-surface=(options.surface)
9
+ mdw-border-ink=(options.borderInk === true ? '' : options.borderInk)
10
+ mdw-light=(options.light ? '' : false)
11
+ mdw-dark=(options.dark ? '' : false)
12
+ mdw-icon=(options.icon ? '' : false)
13
+ mdw-raised=(options.raised ? '' : false)
14
+ disabled=(options.disabled ? '' : false)
15
+ aria-disabled=(options.disabled ? 'true' : false)
16
+ tabindex=(options.tabindex == null ? '0' : options.tabindex)
17
+ )&attributes(attributes)
18
+ block
@@ -0,0 +1,2 @@
1
+ @forward './_spec.scss';
2
+ @forward './_theme.scss';