@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.
- package/.browserslistrc +2 -1
- package/.eslintrc.json +188 -30
- package/.stylelintrc.json +643 -2
- package/.vscode/launch.json +20 -5
- package/.vscode/settings.json +3 -0
- package/CHANGELOG.md +36 -0
- package/README.md +82 -2
- package/adapters/datatable/column.js +176 -0
- package/adapters/datatable/index.js +253 -437
- package/adapters/dom/index.js +586 -0
- package/adapters/list/index.js +36 -113
- package/adapters/search/index.js +153 -180
- package/components/appbar/_spec.scss +165 -0
- package/components/appbar/_theme.scss +0 -0
- package/components/appbar/index.scss +2 -0
- package/components/banner/_spec.scss +83 -0
- package/components/banner/_theme.scss +0 -0
- package/components/banner/index.scss +2 -0
- package/components/bottomnav/README.md +4 -4
- package/components/bottomnav/_spec.scss +149 -0
- package/components/bottomnav/_theme.scss +0 -0
- package/components/bottomnav/index.js +100 -120
- package/components/bottomnav/index.scss +2 -0
- package/components/bottomnav/item.js +88 -0
- package/components/button/README.md +16 -22
- package/components/button/_spec.scss +162 -0
- package/components/button/_theme.scss +42 -0
- package/components/button/index.eta +32 -0
- package/components/button/index.js +37 -48
- package/components/button/index.pug +18 -0
- package/components/button/index.scss +2 -0
- package/components/card/_spec.scss +241 -0
- package/components/card/_theme.scss +0 -0
- package/components/card/index.scss +2 -0
- package/components/chip/_spec.scss +111 -0
- package/components/chip/_theme.scss +105 -0
- package/components/chip/index.js +23 -0
- package/components/chip/index.scss +2 -0
- package/components/chip/item.js +20 -0
- package/components/datatable/_spec.scss +225 -0
- package/components/datatable/_theme.scss +128 -0
- package/components/datatable/cell.js +44 -0
- package/components/datatable/columnheader.js +46 -0
- package/components/datatable/index.js +339 -443
- package/components/datatable/index.scss +2 -0
- package/components/datatable/row.js +48 -0
- package/components/datatable/rowheader.js +18 -0
- package/components/dialog/_spec.scss +203 -0
- package/components/dialog/_theme.scss +7 -0
- package/components/dialog/index.js +512 -437
- package/components/dialog/index.scss +2 -0
- package/components/divider/_spec.scss +11 -0
- package/components/divider/_theme.scss +0 -0
- package/components/divider/index.scss +2 -0
- package/components/elevation/_spec.scss +9 -0
- package/components/elevation/_theme.scss +0 -0
- package/components/elevation/index.scss +2 -0
- package/components/fab/{style.scss → _spec.scss} +104 -79
- package/components/fab/_theme.scss +0 -0
- package/components/fab/index.js +85 -79
- package/components/fab/index.scss +2 -0
- package/components/grid/_spec.scss +169 -0
- package/components/grid/_theme.scss +0 -0
- package/components/grid/index.scss +2 -0
- package/components/layout/_mixins.scss +11 -0
- package/components/layout/_spec.scss +916 -0
- package/components/layout/_theme.scss +19 -0
- package/components/layout/index.js +454 -0
- package/components/layout/index.scss +2 -0
- package/components/list/_spec.scss +363 -0
- package/components/list/_theme.scss +102 -0
- package/components/list/content.js +106 -0
- package/components/list/index.js +234 -79
- package/components/list/index.scss +2 -0
- package/components/list/item.js +167 -0
- package/components/list/secondary.js +45 -0
- package/components/menu/_spec.scss +329 -0
- package/components/menu/_theme.scss +0 -0
- package/components/menu/index.js +636 -651
- package/components/menu/index.scss +2 -0
- package/components/menu/item.js +231 -0
- package/components/progress/_spec.scss +156 -0
- package/components/progress/_theme.scss +0 -0
- package/components/progress/index.js +29 -13
- package/components/progress/index.scss +2 -0
- package/components/selection/_spec.scss +376 -0
- package/components/selection/_theme.scss +134 -0
- package/components/selection/index.eta +60 -0
- package/components/selection/index.js +70 -0
- package/components/selection/index.pug +30 -0
- package/components/selection/index.scss +2 -0
- package/components/selection/input.js +54 -0
- package/components/selection/radiogroup.js +40 -0
- package/components/slider/{style.scss → _spec.scss} +31 -34
- package/components/slider/_theme.scss +0 -0
- package/components/slider/index.scss +2 -0
- package/components/snackbar/_spec.scss +150 -0
- package/components/snackbar/_theme.scss +0 -0
- package/components/snackbar/index.js +293 -206
- package/components/snackbar/index.scss +2 -0
- package/components/tab/_spec.scss +220 -0
- package/components/tab/_theme.scss +0 -0
- package/components/tab/content.js +210 -0
- package/components/tab/index.js +229 -213
- package/components/tab/index.scss +2 -0
- package/components/tab/item.js +88 -0
- package/components/tab/list.js +196 -0
- package/components/tab/panel.js +54 -0
- package/components/textfield/README.md +4 -4
- package/components/textfield/_spec.scss +763 -0
- package/components/textfield/_theme.scss +264 -0
- package/components/textfield/index.eta +74 -0
- package/components/textfield/index.js +132 -138
- package/components/textfield/index.pug +30 -0
- package/components/textfield/index.scss +2 -0
- package/components/tooltip/_spec.scss +185 -0
- package/components/tooltip/_theme.scss +0 -0
- package/components/tooltip/index.scss +2 -0
- package/components/type/_spec.scss +227 -0
- package/components/type/_theme.scss +0 -0
- package/components/type/index.scss +2 -0
- package/core/_breakpoint.scss +189 -0
- package/core/_elevation.scss +78 -0
- package/core/_length.scss +8 -0
- package/core/_motion.scss +31 -0
- package/core/_platform.scss +12 -0
- package/core/_type.scss +128 -0
- package/core/aria/attributes.js +141 -0
- package/core/aria/button.js +49 -0
- package/core/aria/keyboard.js +92 -0
- package/core/aria/rovingtabindex.js +175 -0
- package/core/aria/tab.js +59 -0
- package/core/document/index.js +39 -0
- package/core/dom.js +180 -0
- package/core/overlay/_spec.scss +28 -0
- package/core/overlay/_theme.scss +147 -0
- package/core/overlay/index.js +95 -0
- package/core/overlay/index.scss +2 -0
- package/core/ripple/_spec.scss +196 -0
- package/core/ripple/_theme.scss +20 -0
- package/core/ripple/index.js +286 -0
- package/core/ripple/index.scss +2 -0
- package/core/theme/_aliases.scss +15 -0
- package/core/theme/_config.scss +8 -0
- package/core/theme/_functions.scss +22 -0
- package/{components/theming/palettes.scss → core/theme/_palettes.scss} +173 -151
- package/core/theme/_spec.scss +0 -0
- package/core/theme/_theme.scss +268 -0
- package/core/theme/index.js +50 -0
- package/core/theme/index.scss +4 -0
- package/core/throttler.js +42 -0
- package/core/transition/index.js +465 -0
- package/docs/_flex.scss +28 -0
- package/docs/_menuoptions.js +183 -0
- package/docs/_partials/_androidnavbar.eta +5 -0
- package/docs/_partials/_androidstatusbar.eta +13 -0
- package/docs/_partials/_appbar.eta +27 -0
- package/docs/_partials/_buttontest.eta +31 -0
- package/docs/_partials/_header.eta +146 -0
- package/docs/_partials/_navlistitem.eta +16 -0
- package/docs/_partials/_target.eta +1 -0
- package/docs/_sample-utils.js +88 -0
- package/docs/{src/storage.js → _storage.js} +0 -0
- package/docs/docs.scss +331 -0
- package/docs/framework.scss +26 -0
- package/docs/index.eta +12 -0
- package/docs/index.js +7 -0
- package/docs/pages/appbar.eta +108 -0
- package/docs/pages/appbar.js +0 -0
- package/docs/pages/bottomnav.eta +188 -0
- package/docs/pages/bottomnav.js +118 -0
- package/docs/pages/button.eta +124 -0
- package/docs/pages/button.js +224 -0
- package/docs/pages/card.eta +90 -0
- package/docs/pages/card.js +175 -0
- package/docs/pages/chip.eta +122 -0
- package/docs/pages/chip.js +80 -0
- package/docs/pages/color.eta +143 -0
- package/docs/pages/color.js +261 -0
- package/docs/pages/datatable.eta +323 -0
- package/docs/pages/datatable.js +160 -0
- package/docs/pages/dialog.eta +184 -0
- package/docs/{src/components → pages}/dialog.js +35 -48
- package/docs/pages/dom.eta +26 -0
- package/docs/pages/dom.js +140 -0
- package/docs/pages/elevation.eta +35 -0
- package/docs/pages/elevation.js +0 -0
- package/docs/pages/fab.eta +99 -0
- package/docs/{src/components → pages}/fab.js +6 -13
- package/docs/pages/grid.eta +135 -0
- package/docs/pages/grid.js +128 -0
- package/docs/pages/layout.eta +8 -0
- package/docs/pages/layout.js +0 -0
- package/docs/pages/list.eta +465 -0
- package/docs/pages/list.js +8 -0
- package/docs/pages/menu.eta +274 -0
- package/docs/{src/components → pages}/menu.js +26 -42
- package/docs/pages/overlay.eta +69 -0
- package/docs/pages/overlay.js +3 -0
- package/docs/pages/progress.eta +23 -0
- package/docs/{src/components → pages}/progress.js +2 -4
- package/docs/pages/ripple.eta +27 -0
- package/docs/pages/ripple.js +3 -0
- package/docs/pages/search.eta +242 -0
- package/docs/pages/search.js +226 -0
- package/docs/pages/selection.eta +107 -0
- package/docs/pages/selection.js +12 -0
- package/docs/pages/slider.eta +23 -0
- package/docs/pages/slider.js +0 -0
- package/docs/pages/snackbar.eta +83 -0
- package/docs/{src/components → pages}/snackbar.js +31 -36
- package/docs/pages/tab.eta +407 -0
- package/docs/pages/tab.js +152 -0
- package/docs/pages/textfield.eta +487 -0
- package/docs/{src/components → pages}/textfield.js +41 -45
- package/docs/pages/tooltip.eta +92 -0
- package/docs/pages/tooltip.js +0 -0
- package/docs/pages/transition.eta +117 -0
- package/docs/pages/transition.js +52 -0
- package/docs/pages/type.eta +31 -0
- package/docs/pages/type.js +0 -0
- package/docs/postrender.js +41 -0
- package/docs/prerender.js +16 -0
- package/docs/pwa/_dialogs.eta +143 -0
- package/docs/pwa/_menus.eta +16 -0
- package/docs/pwa/pwa-prerender.js +3 -0
- package/docs/pwa/pwa.eta +478 -0
- package/docs/pwa/pwa.js +298 -0
- package/docs/pwa/pwa.scss +31 -0
- package/docs/themes/theme-colored.scss +15 -0
- package/docs/themes/theme-default.scss +3 -0
- package/index.scss +27 -0
- package/jsconfig.json +8 -2
- package/package.json +54 -27
- package/scripts/deploy-docs.sh +9 -0
- package/templates/index.eta +2 -0
- package/templates/index.pug +3 -0
- package/tsconfig.json +16 -0
- package/utils/function.js +3 -0
- package/webpack.config.js +224 -68
- package/_index.scss +0 -4
- package/components/all-components.scss +0 -21
- package/components/bottomnav/style.scss +0 -190
- package/components/bottomnav/theming.scss +0 -76
- package/components/button/style.scss +0 -315
- package/components/button/theming.scss +0 -134
- package/components/card/style.scss +0 -175
- package/components/card/theming.scss +0 -43
- package/components/common/dom.js +0 -51
- package/components/common/functions.scss +0 -174
- package/components/common/mixins.scss +0 -122
- package/components/common/motion.scss +0 -36
- package/components/common/type.scss +0 -104
- package/components/common/variables.scss +0 -46
- package/components/datatable/style.scss +0 -257
- package/components/datatable/theming.scss +0 -119
- package/components/dialog/style.scss +0 -159
- package/components/dialog/theming.scss +0 -29
- package/components/divider/style.scss +0 -7
- package/components/divider/theming.scss +0 -20
- package/components/elevation/style.scss +0 -32
- package/components/layout/style.scss +0 -223
- package/components/list/style.scss +0 -358
- package/components/list/theming.scss +0 -83
- package/components/menu/style.scss +0 -280
- package/components/menu/theming.scss +0 -80
- package/components/navdrawer/index.js +0 -200
- package/components/navdrawer/style.scss +0 -595
- package/components/navdrawer/theming.scss +0 -62
- package/components/progress/style.scss +0 -136
- package/components/ripple/index.js +0 -63
- package/components/ripple/ripple.scss +0 -122
- package/components/selection/style.scss +0 -320
- package/components/selection/theming.scss +0 -98
- package/components/snackbar/style.scss +0 -212
- package/components/switch/style.scss +0 -3
- package/components/tab/style.scss +0 -275
- package/components/tab/theming.scss +0 -34
- package/components/template/theming.scss +0 -31
- package/components/textfield/style.scss +0 -795
- package/components/textfield/theming.scss +0 -256
- package/components/theming/globals.scss +0 -25
- package/components/theming/theming.scss +0 -559
- package/components/toolbar/style.scss +0 -190
- package/components/toolbar/theming.scss +0 -32
- package/components/tooltip/style.scss +0 -135
- package/components/type/style.scss +0 -167
- package/components/type/theming.scss +0 -25
- package/docs/bottomnav.html +0 -1
- package/docs/bottomnav.min.js +0 -2
- package/docs/bottomnav.min.js.map +0 -1
- package/docs/button.html +0 -1
- package/docs/button.min.js +0 -2
- package/docs/button.min.js.map +0 -1
- package/docs/card.html +0 -1
- package/docs/card.min.js +0 -2
- package/docs/card.min.js.map +0 -1
- package/docs/components.min.css +0 -1
- package/docs/components.min.js +0 -2
- package/docs/components.min.js.map +0 -1
- package/docs/datatable.html +0 -1
- package/docs/datatable.min.js +0 -2
- package/docs/datatable.min.js.map +0 -1
- package/docs/dialog.html +0 -1
- package/docs/dialog.min.js +0 -2
- package/docs/dialog.min.js.map +0 -1
- package/docs/docs.min.css +0 -1
- package/docs/docs.min.js +0 -2
- package/docs/docs.min.js.map +0 -1
- package/docs/elevation.html +0 -1
- package/docs/elevation.min.js +0 -2
- package/docs/elevation.min.js.map +0 -1
- package/docs/fab.html +0 -1
- package/docs/fab.min.js +0 -2
- package/docs/fab.min.js.map +0 -1
- package/docs/index.html +0 -1
- package/docs/index.min.js +0 -2
- package/docs/index.min.js.map +0 -1
- package/docs/layout.html +0 -1
- package/docs/layout.min.js +0 -2
- package/docs/layout.min.js.map +0 -1
- package/docs/list.html +0 -1
- package/docs/list.min.js +0 -2
- package/docs/list.min.js.map +0 -1
- package/docs/menu.html +0 -1
- package/docs/menu.min.js +0 -2
- package/docs/menu.min.js.map +0 -1
- package/docs/navdrawer.html +0 -1
- package/docs/navdrawer.min.js +0 -2
- package/docs/navdrawer.min.js.map +0 -1
- package/docs/prerender.min.js +0 -2
- package/docs/prerender.min.js.map +0 -1
- package/docs/progress.html +0 -1
- package/docs/progress.min.js +0 -2
- package/docs/progress.min.js.map +0 -1
- package/docs/search.html +0 -1
- package/docs/search.min.js +0 -2
- package/docs/search.min.js.map +0 -1
- package/docs/selection.html +0 -1
- package/docs/selection.min.js +0 -2
- package/docs/selection.min.js.map +0 -1
- package/docs/slider.html +0 -1
- package/docs/slider.min.js +0 -2
- package/docs/slider.min.js.map +0 -1
- package/docs/snackbar.html +0 -1
- package/docs/snackbar.min.js +0 -2
- package/docs/snackbar.min.js.map +0 -1
- package/docs/src/components/bottomnav.js +0 -16
- package/docs/src/components/bottomnav.pug +0 -112
- package/docs/src/components/button.js +0 -156
- package/docs/src/components/button.pug +0 -194
- package/docs/src/components/card.js +0 -136
- package/docs/src/components/card.pug +0 -133
- package/docs/src/components/datatable.js +0 -183
- package/docs/src/components/datatable.pug +0 -324
- package/docs/src/components/dialog.pug +0 -138
- package/docs/src/components/elevation.js +0 -3
- package/docs/src/components/elevation.pug +0 -17
- package/docs/src/components/fab.pug +0 -84
- package/docs/src/components/layout.js +0 -116
- package/docs/src/components/layout.pug +0 -104
- package/docs/src/components/list.js +0 -15
- package/docs/src/components/list.pug +0 -293
- package/docs/src/components/menu.pug +0 -292
- package/docs/src/components/navdrawer.js +0 -112
- package/docs/src/components/navdrawer.pug +0 -113
- package/docs/src/components/progress.pug +0 -17
- package/docs/src/components/search.js +0 -206
- package/docs/src/components/search.pug +0 -149
- package/docs/src/components/selection.js +0 -6
- package/docs/src/components/selection.pug +0 -116
- package/docs/src/components/slider.js +0 -3
- package/docs/src/components/slider.pug +0 -19
- package/docs/src/components/snackbar.pug +0 -145
- package/docs/src/components/tab.js +0 -137
- package/docs/src/components/tab.pug +0 -329
- package/docs/src/components/textfield.pug +0 -416
- package/docs/src/components/toolbar.js +0 -6
- package/docs/src/components/toolbar.pug +0 -86
- package/docs/src/components/tooltip.js +0 -6
- package/docs/src/components/tooltip.pug +0 -76
- package/docs/src/components/type.js +0 -6
- package/docs/src/components/type.pug +0 -34
- package/docs/src/components.scss +0 -1
- package/docs/src/docs.scss +0 -284
- package/docs/src/index.js +0 -3
- package/docs/src/index.pug +0 -6
- package/docs/src/menuoptions.js +0 -136
- package/docs/src/mixins.pug +0 -139
- package/docs/src/prerender.js +0 -26
- package/docs/src/sample-utils.js +0 -108
- package/docs/src/targetHandler.js +0 -50
- package/docs/src/theming.ie11.scss +0 -18
- package/docs/src/theming.scss +0 -18
- package/docs/tab.html +0 -1
- package/docs/tab.min.js +0 -2
- package/docs/tab.min.js.map +0 -1
- package/docs/textfield.html +0 -2
- package/docs/textfield.min.js +0 -2
- package/docs/textfield.min.js.map +0 -1
- package/docs/theming.ie11.min.css +0 -1
- package/docs/theming.ie11.min.js +0 -2
- package/docs/theming.ie11.min.js.map +0 -1
- package/docs/theming.min.css +0 -1
- package/docs/theming.min.js +0 -2
- package/docs/theming.min.js.map +0 -1
- package/docs/toolbar.html +0 -1
- package/docs/toolbar.min.js +0 -2
- package/docs/toolbar.min.js.map +0 -1
- package/docs/tooltip.html +0 -1
- package/docs/tooltip.min.js +0 -2
- package/docs/tooltip.min.js.map +0 -1
- package/docs/type.html +0 -1
- package/docs/type.min.js +0 -2
- package/docs/type.min.js.map +0 -1
- 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
|
-
##
|
|
14
|
+
## Colored (Primary)
|
|
15
15
|
```
|
|
16
|
-
.mdw-button(mdw-
|
|
16
|
+
.mdw-button.mdw-theme(mdw-ink="primary contrast")
|
|
17
17
|
```
|
|
18
18
|
|
|
19
|
-
## Colored
|
|
19
|
+
## Colored (Custom)
|
|
20
20
|
```
|
|
21
|
-
.mdw-button
|
|
21
|
+
.mdw-button.mdw-theme(mdw-ink="green contrast")
|
|
22
22
|
```
|
|
23
23
|
|
|
24
|
-
##
|
|
24
|
+
## Filled Light
|
|
25
25
|
```
|
|
26
|
-
.mdw-button
|
|
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
|
|
31
|
+
.mdw-button.mdw-theme(mdw-surface="secondary 600" mdw-dark)
|
|
32
32
|
```
|
|
33
33
|
|
|
34
|
-
##
|
|
34
|
+
## Toggled
|
|
35
35
|
```
|
|
36
|
-
.mdw-button(
|
|
36
|
+
.mdw-button(aria-pressed="true")
|
|
37
37
|
```
|
|
38
38
|
|
|
39
|
-
##
|
|
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.
|
|
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
|
|
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
|
-
|
|
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
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
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
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
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
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
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
|
-
|
|
53
|
-
|
|
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
|