@mgdis/mg-components 3.1.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/LICENSE +29 -0
- package/dist/cjs/css-shim-a22512c4.js +6 -0
- package/dist/cjs/index-85a4a0b6.js +1674 -0
- package/dist/cjs/index.cjs.js +2 -0
- package/dist/cjs/loader.cjs.js +35 -0
- package/dist/cjs/mg-badge_20.cjs.entry.js +4661 -0
- package/dist/cjs/mg-components.cjs.js +23 -0
- package/dist/cjs/shadow-css-8940f82d.js +390 -0
- package/dist/collection/collection-manifest.json +31 -0
- package/dist/collection/components/atoms/mg-badge/mg-badge.conf.js +4 -0
- package/dist/collection/components/atoms/mg-badge/mg-badge.css +99 -0
- package/dist/collection/components/atoms/mg-badge/mg-badge.js +148 -0
- package/dist/collection/components/atoms/mg-badge/mg-badge.stories.js +27 -0
- package/dist/collection/components/atoms/mg-button/mg-button.conf.js +4 -0
- package/dist/collection/components/atoms/mg-button/mg-button.css +134 -0
- package/dist/collection/components/atoms/mg-button/mg-button.js +236 -0
- package/dist/collection/components/atoms/mg-button/mg-button.stories.js +38 -0
- package/dist/collection/components/atoms/mg-character-left/mg-character-left.css +3 -0
- package/dist/collection/components/atoms/mg-character-left/mg-character-left.js +133 -0
- package/dist/collection/components/atoms/mg-character-left/mg-character-left.stories.js +15 -0
- package/dist/collection/components/atoms/mg-icon/mg-icon.conf.js +54 -0
- package/dist/collection/components/atoms/mg-icon/mg-icon.css +57 -0
- package/dist/collection/components/atoms/mg-icon/mg-icon.js +155 -0
- package/dist/collection/components/atoms/mg-icon/mg-icon.stories.js +34 -0
- package/dist/collection/components/atoms/mg-input-title/mg-input-title.css +12 -0
- package/dist/collection/components/atoms/mg-input-title/mg-input-title.js +95 -0
- package/dist/collection/components/atoms/mg-input-title/mg-input-title.stories.js +21 -0
- package/dist/collection/components/atoms/mg-tag/mg-tag.conf.js +4 -0
- package/dist/collection/components/atoms/mg-tag/mg-tag.css +73 -0
- package/dist/collection/components/atoms/mg-tag/mg-tag.js +94 -0
- package/dist/collection/components/atoms/mg-tag/mg-tag.stories.js +25 -0
- package/dist/collection/components/atoms/mg-tooltip/mg-tooltip.css +44 -0
- package/dist/collection/components/atoms/mg-tooltip/mg-tooltip.js +225 -0
- package/dist/collection/components/atoms/mg-tooltip/mg-tooltip.stories.js +26 -0
- package/dist/collection/components/molecules/inputs/MgInput.conf.js +7 -0
- package/dist/collection/components/molecules/inputs/MgInput.js +130 -0
- package/dist/collection/components/molecules/inputs/mg-input-checkbox/mg-input-checkbox.conf.js +1 -0
- package/dist/collection/components/molecules/inputs/mg-input-checkbox/mg-input-checkbox.css +156 -0
- package/dist/collection/components/molecules/inputs/mg-input-checkbox/mg-input-checkbox.js +444 -0
- package/dist/collection/components/molecules/inputs/mg-input-checkbox/mg-input-checkbox.stories.js +57 -0
- package/dist/collection/components/molecules/inputs/mg-input-date/mg-input-date.conf.js +7 -0
- package/dist/collection/components/molecules/inputs/mg-input-date/mg-input-date.css +171 -0
- package/dist/collection/components/molecules/inputs/mg-input-date/mg-input-date.js +467 -0
- package/dist/collection/components/molecules/inputs/mg-input-date/mg-input-date.stories.js +46 -0
- package/dist/collection/components/molecules/inputs/mg-input-numeric/mg-input-numeric.conf.js +11 -0
- package/dist/collection/components/molecules/inputs/mg-input-numeric/mg-input-numeric.css +199 -0
- package/dist/collection/components/molecules/inputs/mg-input-numeric/mg-input-numeric.js +633 -0
- package/dist/collection/components/molecules/inputs/mg-input-numeric/mg-input-numeric.stories.js +68 -0
- package/dist/collection/components/molecules/inputs/mg-input-password/mg-input-password.css +195 -0
- package/dist/collection/components/molecules/inputs/mg-input-password/mg-input-password.js +401 -0
- package/dist/collection/components/molecules/inputs/mg-input-password/mg-input-password.stories.js +43 -0
- package/dist/collection/components/molecules/inputs/mg-input-radio/mg-input-radio.conf.js +1 -0
- package/dist/collection/components/molecules/inputs/mg-input-radio/mg-input-radio.css +156 -0
- package/dist/collection/components/molecules/inputs/mg-input-radio/mg-input-radio.js +443 -0
- package/dist/collection/components/molecules/inputs/mg-input-radio/mg-input-radio.stories.js +65 -0
- package/dist/collection/components/molecules/inputs/mg-input-select/mg-input-select.conf.js +1 -0
- package/dist/collection/components/molecules/inputs/mg-input-select/mg-input-select.css +201 -0
- package/dist/collection/components/molecules/inputs/mg-input-select/mg-input-select.js +532 -0
- package/dist/collection/components/molecules/inputs/mg-input-select/mg-input-select.stories.js +70 -0
- package/dist/collection/components/molecules/inputs/mg-input-text/mg-input-text.css +222 -0
- package/dist/collection/components/molecules/inputs/mg-input-text/mg-input-text.js +589 -0
- package/dist/collection/components/molecules/inputs/mg-input-text/mg-input-text.stories.js +115 -0
- package/dist/collection/components/molecules/inputs/mg-input-textarea/mg-input-textarea.css +217 -0
- package/dist/collection/components/molecules/inputs/mg-input-textarea/mg-input-textarea.js +553 -0
- package/dist/collection/components/molecules/inputs/mg-input-textarea/mg-input-textarea.stories.js +52 -0
- package/dist/collection/components/molecules/inputs/mg-input-toggle/mg-input-toggle.conf.js +1 -0
- package/dist/collection/components/molecules/inputs/mg-input-toggle/mg-input-toggle.css +213 -0
- package/dist/collection/components/molecules/inputs/mg-input-toggle/mg-input-toggle.js +457 -0
- package/dist/collection/components/molecules/inputs/mg-input-toggle/mg-input-toggle.stories.js +73 -0
- package/dist/collection/components/molecules/mg-message/mg-message.conf.js +4 -0
- package/dist/collection/components/molecules/mg-message/mg-message.css +94 -0
- package/dist/collection/components/molecules/mg-message/mg-message.js +285 -0
- package/dist/collection/components/molecules/mg-message/mg-message.stories.js +43 -0
- package/dist/collection/components/molecules/mg-pagination/mg-pagination.conf.js +5 -0
- package/dist/collection/components/molecules/mg-pagination/mg-pagination.css +39 -0
- package/dist/collection/components/molecules/mg-pagination/mg-pagination.js +218 -0
- package/dist/collection/components/molecules/mg-pagination/mg-pagination.stories.js +23 -0
- package/dist/collection/components/molecules/mg-popover/mg-popover.css +59 -0
- package/dist/collection/components/molecules/mg-popover/mg-popover.js +249 -0
- package/dist/collection/components/molecules/mg-popover/mg-popover.stories.js +36 -0
- package/dist/collection/components/molecules/mg-tabs/mg-tabs.conf.js +1 -0
- package/dist/collection/components/molecules/mg-tabs/mg-tabs.css +30 -0
- package/dist/collection/components/molecules/mg-tabs/mg-tabs.js +212 -0
- package/dist/collection/components/molecules/mg-tabs/mg-tabs.stories.js +40 -0
- package/dist/collection/fonts/OpenSans-Regular.ttf +0 -0
- package/dist/collection/fonts/OpenSans-SemiBold.ttf +0 -0
- package/dist/collection/fonts/Poppins-Bold.ttf +0 -0
- package/dist/collection/index.js +1 -0
- package/dist/collection/locales/index.js +4 -0
- package/dist/collection/stories/buttons.stories.js +43 -0
- package/dist/collection/stories/grids.stories.js +50 -0
- package/dist/collection/stories/icons.stories.js +20 -0
- package/dist/collection/stories/messages.stories.js +44 -0
- package/dist/collection/stories/tags.stories.js +13 -0
- package/dist/collection/stories/typography.stories.js +28 -0
- package/dist/collection/utils/components.utils.js +67 -0
- package/dist/collection/utils/locale.utils.js +32 -0
- package/dist/collection/utils/test.utils.js +26 -0
- package/dist/collection/variables.css +177 -0
- package/dist/collection/variables.scss +177 -0
- package/dist/components/MgInput.js +140 -0
- package/dist/components/components.utils.js +69 -0
- package/dist/components/index.d.ts +26 -0
- package/dist/components/index.js +1 -0
- package/dist/components/index2.js +54 -0
- package/dist/components/locale.utils.js +35 -0
- package/dist/components/mg-badge.d.ts +11 -0
- package/dist/components/mg-badge.js +6 -0
- package/dist/components/mg-badge2.js +82 -0
- package/dist/components/mg-button.d.ts +11 -0
- package/dist/components/mg-button.js +6 -0
- package/dist/components/mg-button2.js +148 -0
- package/dist/components/mg-character-left.d.ts +11 -0
- package/dist/components/mg-character-left.js +6 -0
- package/dist/components/mg-character-left2.js +77 -0
- package/dist/components/mg-icon.d.ts +11 -0
- package/dist/components/mg-icon.js +6 -0
- package/dist/components/mg-icon2.js +147 -0
- package/dist/components/mg-input-checkbox.d.ts +11 -0
- package/dist/components/mg-input-checkbox.js +222 -0
- package/dist/components/mg-input-date.d.ts +11 -0
- package/dist/components/mg-input-date.js +245 -0
- package/dist/components/mg-input-numeric.d.ts +11 -0
- package/dist/components/mg-input-numeric.js +324 -0
- package/dist/components/mg-input-password.d.ts +11 -0
- package/dist/components/mg-input-password.js +171 -0
- package/dist/components/mg-input-radio.d.ts +11 -0
- package/dist/components/mg-input-radio.js +211 -0
- package/dist/components/mg-input-select.d.ts +11 -0
- package/dist/components/mg-input-select.js +6 -0
- package/dist/components/mg-input-select2.js +243 -0
- package/dist/components/mg-input-text.d.ts +11 -0
- package/dist/components/mg-input-text.js +242 -0
- package/dist/components/mg-input-textarea.d.ts +11 -0
- package/dist/components/mg-input-textarea.js +224 -0
- package/dist/components/mg-input-title.d.ts +11 -0
- package/dist/components/mg-input-title.js +6 -0
- package/dist/components/mg-input-title2.js +55 -0
- package/dist/components/mg-input-toggle.d.ts +11 -0
- package/dist/components/mg-input-toggle.js +247 -0
- package/dist/components/mg-message.d.ts +11 -0
- package/dist/components/mg-message.js +183 -0
- package/dist/components/mg-pagination.d.ts +11 -0
- package/dist/components/mg-pagination.js +175 -0
- package/dist/components/mg-popover.d.ts +11 -0
- package/dist/components/mg-popover.js +183 -0
- package/dist/components/mg-tabs.d.ts +11 -0
- package/dist/components/mg-tabs.js +160 -0
- package/dist/components/mg-tag.d.ts +11 -0
- package/dist/components/mg-tag.js +76 -0
- package/dist/components/mg-tooltip.d.ts +11 -0
- package/dist/components/mg-tooltip.js +6 -0
- package/dist/components/mg-tooltip2.js +150 -0
- package/dist/components/popper.js +1784 -0
- package/dist/esm/css-shim-7c240feb.js +4 -0
- package/dist/esm/index-e3e84606.js +1643 -0
- package/dist/esm/index.js +1 -0
- package/dist/esm/loader.js +31 -0
- package/dist/esm/mg-badge_20.entry.js +4638 -0
- package/dist/esm/mg-components.js +21 -0
- package/dist/esm/polyfills/core-js.js +11 -0
- package/dist/esm/polyfills/css-shim.js +1 -0
- package/dist/esm/polyfills/dom.js +79 -0
- package/dist/esm/polyfills/es5-html-element.js +1 -0
- package/dist/esm/polyfills/index.js +34 -0
- package/dist/esm/polyfills/system.js +6 -0
- package/dist/esm/shadow-css-5d2d01ce.js +388 -0
- package/dist/esm-es5/css-shim-7c240feb.js +1 -0
- package/dist/esm-es5/index-e3e84606.js +1 -0
- package/dist/esm-es5/index.js +0 -0
- package/dist/esm-es5/loader.js +1 -0
- package/dist/esm-es5/mg-badge_20.entry.js +2 -0
- package/dist/esm-es5/mg-components.js +1 -0
- package/dist/esm-es5/shadow-css-5d2d01ce.js +12 -0
- package/dist/index.cjs.js +1 -0
- package/dist/index.js +1 -0
- package/dist/mg-components/fonts/OpenSans-Regular.ttf +0 -0
- package/dist/mg-components/fonts/OpenSans-SemiBold.ttf +0 -0
- package/dist/mg-components/fonts/Poppins-Bold.ttf +0 -0
- package/dist/mg-components/index.esm.js +0 -0
- package/dist/mg-components/mg-components.css +1 -0
- package/dist/mg-components/mg-components.esm.js +1 -0
- package/dist/mg-components/mg-components.js +132 -0
- package/dist/mg-components/p-1cd24462.system.js +1 -0
- package/dist/mg-components/p-2e2f6b27.system.entry.js +2 -0
- package/dist/mg-components/p-366a224e.js +1 -0
- package/dist/mg-components/p-422c429b.system.js +1 -0
- package/dist/mg-components/p-50ea2036.system.js +1 -0
- package/dist/mg-components/p-62fa3797.js +1 -0
- package/dist/mg-components/p-71d57b8b.system.js +13 -0
- package/dist/mg-components/p-9a215712.system.js +1 -0
- package/dist/mg-components/p-cbf0464b.entry.js +1 -0
- package/dist/mg-components/p-f6455ab3.js +12 -0
- package/dist/mg-components/variables.css +177 -0
- package/dist/mg-components/variables.scss +177 -0
- package/dist/types/components/atoms/mg-badge/mg-badge.conf.d.ts +8 -0
- package/dist/types/components/atoms/mg-badge/mg-badge.d.ts +36 -0
- package/dist/types/components/atoms/mg-badge/mg-badge.stories.d.ts +19 -0
- package/dist/types/components/atoms/mg-button/mg-button.conf.d.ts +4 -0
- package/dist/types/components/atoms/mg-button/mg-button.d.ts +67 -0
- package/dist/types/components/atoms/mg-button/mg-button.stories.d.ts +16 -0
- package/dist/types/components/atoms/mg-character-left/mg-character-left.d.ts +39 -0
- package/dist/types/components/atoms/mg-character-left/mg-character-left.stories.d.ts +7 -0
- package/dist/types/components/atoms/mg-icon/mg-icon.conf.d.ts +12 -0
- package/dist/types/components/atoms/mg-icon/mg-icon.d.ts +36 -0
- package/dist/types/components/atoms/mg-icon/mg-icon.stories.d.ts +26 -0
- package/dist/types/components/atoms/mg-input-title/mg-input-title.d.ts +24 -0
- package/dist/types/components/atoms/mg-input-title/mg-input-title.stories.d.ts +6 -0
- package/dist/types/components/atoms/mg-tag/mg-tag.conf.d.ts +4 -0
- package/dist/types/components/atoms/mg-tag/mg-tag.d.ts +25 -0
- package/dist/types/components/atoms/mg-tag/mg-tag.stories.d.ts +14 -0
- package/dist/types/components/atoms/mg-tooltip/mg-tooltip.d.ts +56 -0
- package/dist/types/components/atoms/mg-tooltip/mg-tooltip.stories.d.ts +11 -0
- package/dist/types/components/molecules/inputs/MgInput.conf.d.ts +10 -0
- package/dist/types/components/molecules/inputs/MgInput.d.ts +35 -0
- package/dist/types/components/molecules/inputs/mg-input-checkbox/mg-input-checkbox.conf.d.ts +19 -0
- package/dist/types/components/molecules/inputs/mg-input-checkbox/mg-input-checkbox.d.ts +120 -0
- package/dist/types/components/molecules/inputs/mg-input-checkbox/mg-input-checkbox.stories.d.ts +6 -0
- package/dist/types/components/molecules/inputs/mg-input-date/mg-input-date.conf.d.ts +6 -0
- package/dist/types/components/molecules/inputs/mg-input-date/mg-input-date.d.ts +128 -0
- package/dist/types/components/molecules/inputs/mg-input-date/mg-input-date.stories.d.ts +7 -0
- package/dist/types/components/molecules/inputs/mg-input-numeric/mg-input-numeric.conf.d.ts +10 -0
- package/dist/types/components/molecules/inputs/mg-input-numeric/mg-input-numeric.d.ts +173 -0
- package/dist/types/components/molecules/inputs/mg-input-numeric/mg-input-numeric.stories.d.ts +21 -0
- package/dist/types/components/molecules/inputs/mg-input-password/mg-input-password.d.ts +111 -0
- package/dist/types/components/molecules/inputs/mg-input-password/mg-input-password.stories.d.ts +9 -0
- package/dist/types/components/molecules/inputs/mg-input-radio/mg-input-radio.conf.d.ts +9 -0
- package/dist/types/components/molecules/inputs/mg-input-radio/mg-input-radio.d.ts +121 -0
- package/dist/types/components/molecules/inputs/mg-input-radio/mg-input-radio.stories.d.ts +15 -0
- package/dist/types/components/molecules/inputs/mg-input-select/mg-input-select.conf.d.ts +18 -0
- package/dist/types/components/molecules/inputs/mg-input-select/mg-input-select.d.ts +133 -0
- package/dist/types/components/molecules/inputs/mg-input-select/mg-input-select.stories.d.ts +14 -0
- package/dist/types/components/molecules/inputs/mg-input-text/mg-input-text.d.ts +160 -0
- package/dist/types/components/molecules/inputs/mg-input-text/mg-input-text.stories.d.ts +26 -0
- package/dist/types/components/molecules/inputs/mg-input-textarea/mg-input-textarea.d.ts +150 -0
- package/dist/types/components/molecules/inputs/mg-input-textarea/mg-input-textarea.stories.d.ts +6 -0
- package/dist/types/components/molecules/inputs/mg-input-toggle/mg-input-toggle.conf.d.ts +8 -0
- package/dist/types/components/molecules/inputs/mg-input-toggle/mg-input-toggle.d.ts +117 -0
- package/dist/types/components/molecules/inputs/mg-input-toggle/mg-input-toggle.stories.d.ts +7 -0
- package/dist/types/components/molecules/mg-message/mg-message.conf.d.ts +4 -0
- package/dist/types/components/molecules/mg-message/mg-message.d.ts +76 -0
- package/dist/types/components/molecules/mg-message/mg-message.stories.d.ts +16 -0
- package/dist/types/components/molecules/mg-pagination/mg-pagination.conf.d.ts +4 -0
- package/dist/types/components/molecules/mg-pagination/mg-pagination.d.ts +53 -0
- package/dist/types/components/molecules/mg-pagination/mg-pagination.stories.d.ts +6 -0
- package/dist/types/components/molecules/mg-popover/mg-popover.d.ts +62 -0
- package/dist/types/components/molecules/mg-popover/mg-popover.stories.d.ts +12 -0
- package/dist/types/components/molecules/mg-tabs/mg-tabs.conf.d.ts +10 -0
- package/dist/types/components/molecules/mg-tabs/mg-tabs.d.ts +63 -0
- package/dist/types/components/molecules/mg-tabs/mg-tabs.stories.d.ts +7 -0
- package/dist/types/components.d.ts +1987 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/types/locales/index.d.ts +44 -0
- package/dist/types/stencil-public-runtime.d.ts +1565 -0
- package/dist/types/stories/buttons.stories.d.ts +13 -0
- package/dist/types/stories/grids.stories.d.ts +5 -0
- package/dist/types/stories/icons.stories.d.ts +13 -0
- package/dist/types/stories/messages.stories.d.ts +13 -0
- package/dist/types/stories/tags.stories.d.ts +5 -0
- package/dist/types/stories/typography.stories.d.ts +5 -0
- package/dist/types/utils/components.utils.d.ts +43 -0
- package/dist/types/utils/locale.utils.d.ts +22 -0
- package/dist/types/utils/test.utils.d.ts +5 -0
- package/loader/cdn.js +3 -0
- package/loader/index.cjs.js +3 -0
- package/loader/index.d.ts +12 -0
- package/loader/index.es2017.js +3 -0
- package/loader/index.js +4 -0
- package/loader/package.json +10 -0
- package/package.json +86 -0
- package/readme.md +159 -0
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
import { Component, h, Prop, State, Watch } from '@stencil/core';
|
|
2
|
+
import { variants } from './mg-badge.conf';
|
|
3
|
+
import { ClassList } from '../../../utils/components.utils';
|
|
4
|
+
export class MgBadge {
|
|
5
|
+
constructor() {
|
|
6
|
+
/**
|
|
7
|
+
* Define button variant
|
|
8
|
+
*/
|
|
9
|
+
this.variant = variants[variants.length - 1];
|
|
10
|
+
/**
|
|
11
|
+
* Component classes
|
|
12
|
+
*/
|
|
13
|
+
this.classList = new ClassList(['mg-badge']);
|
|
14
|
+
}
|
|
15
|
+
valideValue(newValue) {
|
|
16
|
+
if (`${newValue}`.match(/^(\d+|[?*!a-z])$/i) === null) {
|
|
17
|
+
throw new Error('<mg-badge> prop "value" must be interger or ponctuation character.');
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
validateVariant(newValue) {
|
|
21
|
+
if (!variants.includes(newValue)) {
|
|
22
|
+
throw new Error(`<mg-badge> prop "variant" must be one of : ${variants.join(', ')}.`);
|
|
23
|
+
}
|
|
24
|
+
this.classList.add(`mg-badge--${this.variant}`);
|
|
25
|
+
}
|
|
26
|
+
validateOutline(newValue) {
|
|
27
|
+
if (newValue)
|
|
28
|
+
this.classList.add(`mg-badge--outline`);
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Check if props are well configured on init
|
|
32
|
+
*/
|
|
33
|
+
componentWillLoad() {
|
|
34
|
+
this.valideValue(this.value);
|
|
35
|
+
this.validateVariant(this.variant);
|
|
36
|
+
this.validateOutline(this.outline);
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Render
|
|
40
|
+
*/
|
|
41
|
+
render() {
|
|
42
|
+
return (h("span", { class: this.classList.join() },
|
|
43
|
+
this.value,
|
|
44
|
+
h("span", { class: "sr-only" }, this.label)));
|
|
45
|
+
}
|
|
46
|
+
static get is() { return "mg-badge"; }
|
|
47
|
+
static get encapsulation() { return "shadow"; }
|
|
48
|
+
static get originalStyleUrls() { return {
|
|
49
|
+
"$": ["mg-badge.scss"]
|
|
50
|
+
}; }
|
|
51
|
+
static get styleUrls() { return {
|
|
52
|
+
"$": ["mg-badge.css"]
|
|
53
|
+
}; }
|
|
54
|
+
static get properties() { return {
|
|
55
|
+
"value": {
|
|
56
|
+
"type": "any",
|
|
57
|
+
"mutable": true,
|
|
58
|
+
"complexType": {
|
|
59
|
+
"original": "BadgeType['value']",
|
|
60
|
+
"resolved": "number | string",
|
|
61
|
+
"references": {
|
|
62
|
+
"BadgeType": {
|
|
63
|
+
"location": "import",
|
|
64
|
+
"path": "./mg-badge.conf"
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
},
|
|
68
|
+
"required": true,
|
|
69
|
+
"optional": false,
|
|
70
|
+
"docs": {
|
|
71
|
+
"tags": [],
|
|
72
|
+
"text": "Badge value"
|
|
73
|
+
},
|
|
74
|
+
"attribute": "value",
|
|
75
|
+
"reflect": false
|
|
76
|
+
},
|
|
77
|
+
"label": {
|
|
78
|
+
"type": "string",
|
|
79
|
+
"mutable": false,
|
|
80
|
+
"complexType": {
|
|
81
|
+
"original": "BadgeType['label']",
|
|
82
|
+
"resolved": "string",
|
|
83
|
+
"references": {
|
|
84
|
+
"BadgeType": {
|
|
85
|
+
"location": "import",
|
|
86
|
+
"path": "./mg-badge.conf"
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
},
|
|
90
|
+
"required": true,
|
|
91
|
+
"optional": false,
|
|
92
|
+
"docs": {
|
|
93
|
+
"tags": [],
|
|
94
|
+
"text": "Badge label. Include short description.\nRequired for accessibility"
|
|
95
|
+
},
|
|
96
|
+
"attribute": "label",
|
|
97
|
+
"reflect": false
|
|
98
|
+
},
|
|
99
|
+
"variant": {
|
|
100
|
+
"type": "string",
|
|
101
|
+
"mutable": false,
|
|
102
|
+
"complexType": {
|
|
103
|
+
"original": "string",
|
|
104
|
+
"resolved": "string",
|
|
105
|
+
"references": {}
|
|
106
|
+
},
|
|
107
|
+
"required": false,
|
|
108
|
+
"optional": true,
|
|
109
|
+
"docs": {
|
|
110
|
+
"tags": [],
|
|
111
|
+
"text": "Define button variant"
|
|
112
|
+
},
|
|
113
|
+
"attribute": "variant",
|
|
114
|
+
"reflect": false,
|
|
115
|
+
"defaultValue": "variants[variants.length - 1]"
|
|
116
|
+
},
|
|
117
|
+
"outline": {
|
|
118
|
+
"type": "boolean",
|
|
119
|
+
"mutable": false,
|
|
120
|
+
"complexType": {
|
|
121
|
+
"original": "boolean",
|
|
122
|
+
"resolved": "boolean",
|
|
123
|
+
"references": {}
|
|
124
|
+
},
|
|
125
|
+
"required": false,
|
|
126
|
+
"optional": true,
|
|
127
|
+
"docs": {
|
|
128
|
+
"tags": [],
|
|
129
|
+
"text": "Define if button is using outline style"
|
|
130
|
+
},
|
|
131
|
+
"attribute": "outline",
|
|
132
|
+
"reflect": false
|
|
133
|
+
}
|
|
134
|
+
}; }
|
|
135
|
+
static get states() { return {
|
|
136
|
+
"classList": {}
|
|
137
|
+
}; }
|
|
138
|
+
static get watchers() { return [{
|
|
139
|
+
"propName": "value",
|
|
140
|
+
"methodName": "valideValue"
|
|
141
|
+
}, {
|
|
142
|
+
"propName": "variant",
|
|
143
|
+
"methodName": "validateVariant"
|
|
144
|
+
}, {
|
|
145
|
+
"propName": "outline",
|
|
146
|
+
"methodName": "validateOutline"
|
|
147
|
+
}]; }
|
|
148
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { h } from '@stencil/core';
|
|
2
|
+
import { variants } from './mg-badge.conf';
|
|
3
|
+
export default {
|
|
4
|
+
component: 'mg-badge',
|
|
5
|
+
title: 'Atoms/mg-badge',
|
|
6
|
+
argTypes: {
|
|
7
|
+
variant: {
|
|
8
|
+
options: variants,
|
|
9
|
+
control: { type: 'select' },
|
|
10
|
+
},
|
|
11
|
+
value: {
|
|
12
|
+
control: { type: 'text' },
|
|
13
|
+
},
|
|
14
|
+
},
|
|
15
|
+
};
|
|
16
|
+
const Template = args => {
|
|
17
|
+
// Extract slot so it won't be render as an attribute
|
|
18
|
+
// return element
|
|
19
|
+
return h("mg-badge", Object.assign({}, args));
|
|
20
|
+
};
|
|
21
|
+
export const MgBadge = Template.bind({});
|
|
22
|
+
MgBadge.args = {
|
|
23
|
+
value: '99',
|
|
24
|
+
label: 'unread messages',
|
|
25
|
+
variant: variants[0],
|
|
26
|
+
outline: false,
|
|
27
|
+
};
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
/* Variables */
|
|
2
|
+
/* Mixins */
|
|
3
|
+
/* Styles */
|
|
4
|
+
.mg-button {
|
|
5
|
+
position: relative;
|
|
6
|
+
display: inline-flex;
|
|
7
|
+
align-items: center;
|
|
8
|
+
padding: calc((var(--default-size) - 0.2rem - var(--font-size) * var(--line-height)) / 2) 1.1rem;
|
|
9
|
+
min-height: var(--default-size);
|
|
10
|
+
box-sizing: border-box;
|
|
11
|
+
border-top-right-radius: var(--mg-button-border-radius-top-right, var(--mg-button-border-radius));
|
|
12
|
+
border-top-left-radius: var(--mg-button-border-radius-top-left, var(--mg-button-border-radius));
|
|
13
|
+
border-bottom-right-radius: var(--mg-button-border-radius-bottom-right, var(--mg-button-border-radius));
|
|
14
|
+
border-bottom-left-radius: var(--mg-button-border-radius-bottom-left, var(--mg-button-border-radius));
|
|
15
|
+
cursor: pointer;
|
|
16
|
+
background-image: none;
|
|
17
|
+
border: 0.1rem solid;
|
|
18
|
+
font-family: inherit;
|
|
19
|
+
text-decoration: none;
|
|
20
|
+
font-weight: normal;
|
|
21
|
+
text-align: left;
|
|
22
|
+
touch-action: manipulation;
|
|
23
|
+
}
|
|
24
|
+
.mg-button[disabled], .mg-button[aria-disabled], .mg-button.disabled {
|
|
25
|
+
opacity: var(--mg-button-disabled-opacity);
|
|
26
|
+
cursor: not-allowed;
|
|
27
|
+
}
|
|
28
|
+
.mg-button.mg-button--icon {
|
|
29
|
+
padding: 0;
|
|
30
|
+
justify-content: center;
|
|
31
|
+
width: var(--default-size);
|
|
32
|
+
height: var(--default-size);
|
|
33
|
+
border-radius: var(--mg-button-icon-border-radius);
|
|
34
|
+
}
|
|
35
|
+
.mg-button.mg-button--primary {
|
|
36
|
+
border-color: hsl(var(--mg-button-primary-color-h), var(--mg-button-primary-color-s), var(--mg-button-primary-color-l));
|
|
37
|
+
/* IE FIX */
|
|
38
|
+
border-color: hsl(var(--mg-button-primary-color-h), var(--mg-button-primary-color-s), calc(var(--mg-button-primary-color-l) - 10%));
|
|
39
|
+
color: hsl(var(--mg-button-primary-font-color));
|
|
40
|
+
background: hsl(var(--mg-button-primary-color-h), var(--mg-button-primary-color-s), var(--mg-button-primary-color-l));
|
|
41
|
+
/* IE FIX */
|
|
42
|
+
background: linear-gradient(to bottom, hsl(var(--mg-button-primary-color-h), var(--mg-button-primary-color-s), var(--mg-button-primary-color-l)), hsl(var(--mg-button-primary-color-h), var(--mg-button-primary-color-s), calc(var(--mg-button-primary-color-l) - 10%)));
|
|
43
|
+
}
|
|
44
|
+
.mg-button.mg-button--primary:hover:not([disabled], [aria-disabled], .disabled), .mg-button.mg-button--primary:focus:not([disabled], [aria-disabled], .disabled), .mg-button.mg-button--primary:active:not([disabled], [aria-disabled], .disabled) {
|
|
45
|
+
background: hsl(var(--mg-button-primary-color-h), var(--mg-button-primary-color-s), var(--mg-button-primary-color-l));
|
|
46
|
+
}
|
|
47
|
+
.mg-button.mg-button--secondary {
|
|
48
|
+
border-color: hsl(var(--mg-button-secondary-color-h), var(--mg-button-secondary-color-s), var(--mg-button-secondary-color-l));
|
|
49
|
+
/* IE FIX */
|
|
50
|
+
border-color: hsl(var(--mg-button-secondary-color-h), var(--mg-button-secondary-color-s), calc(var(--mg-button-secondary-color-l) - 10%));
|
|
51
|
+
color: hsl(var(--mg-button-secondary-font-color));
|
|
52
|
+
background: hsl(var(--mg-button-secondary-color-h), var(--mg-button-secondary-color-s), var(--mg-button-secondary-color-l));
|
|
53
|
+
/* IE FIX */
|
|
54
|
+
background: linear-gradient(to bottom, hsl(var(--mg-button-secondary-color-h), var(--mg-button-secondary-color-s), var(--mg-button-secondary-color-l)), hsl(var(--mg-button-secondary-color-h), var(--mg-button-secondary-color-s), calc(var(--mg-button-secondary-color-l) - 10%)));
|
|
55
|
+
}
|
|
56
|
+
.mg-button.mg-button--secondary:hover:not([disabled], [aria-disabled], .disabled), .mg-button.mg-button--secondary:focus:not([disabled], [aria-disabled], .disabled), .mg-button.mg-button--secondary:active:not([disabled], [aria-disabled], .disabled) {
|
|
57
|
+
background: hsl(var(--mg-button-secondary-color-h), var(--mg-button-secondary-color-s), var(--mg-button-secondary-color-l));
|
|
58
|
+
}
|
|
59
|
+
.mg-button.mg-button--danger {
|
|
60
|
+
border-color: hsl(var(--color-danger-h), var(--color-danger-s), var(--color-danger-l));
|
|
61
|
+
/* IE FIX */
|
|
62
|
+
border-color: hsl(var(--color-danger-h), var(--color-danger-s), calc(var(--color-danger-l) - 10%));
|
|
63
|
+
color: hsl(var(--color-neutral));
|
|
64
|
+
background: hsl(var(--color-danger-h), var(--color-danger-s), var(--color-danger-l));
|
|
65
|
+
/* IE FIX */
|
|
66
|
+
background: linear-gradient(to bottom, hsl(var(--color-danger-h), var(--color-danger-s), var(--color-danger-l)), hsl(var(--color-danger-h), var(--color-danger-s), calc(var(--color-danger-l) - 10%)));
|
|
67
|
+
}
|
|
68
|
+
.mg-button.mg-button--danger:hover:not([disabled], [aria-disabled], .disabled), .mg-button.mg-button--danger:focus:not([disabled], [aria-disabled], .disabled), .mg-button.mg-button--danger:active:not([disabled], [aria-disabled], .disabled) {
|
|
69
|
+
background: hsl(var(--color-danger-h), var(--color-danger-s), var(--color-danger-l));
|
|
70
|
+
}
|
|
71
|
+
.mg-button.mg-button--danger-alt {
|
|
72
|
+
border-color: hsl(var(--color-neutral-h), var(--color-neutral-s), var(--color-neutral-l));
|
|
73
|
+
/* IE FIX */
|
|
74
|
+
border-color: hsl(var(--color-neutral-h), var(--color-neutral-s), calc(var(--color-neutral-l) - 10%));
|
|
75
|
+
color: hsl(var(--color-danger));
|
|
76
|
+
background: hsl(var(--color-neutral-h), var(--color-neutral-s), var(--color-neutral-l));
|
|
77
|
+
/* IE FIX */
|
|
78
|
+
background: linear-gradient(to bottom, hsl(var(--color-neutral-h), var(--color-neutral-s), var(--color-neutral-l)), hsl(var(--color-neutral-h), var(--color-neutral-s), calc(var(--color-neutral-l) - 10%)));
|
|
79
|
+
}
|
|
80
|
+
.mg-button.mg-button--danger-alt:hover:not([disabled], [aria-disabled], .disabled), .mg-button.mg-button--danger-alt:focus:not([disabled], [aria-disabled], .disabled), .mg-button.mg-button--danger-alt:active:not([disabled], [aria-disabled], .disabled) {
|
|
81
|
+
background: hsl(var(--color-neutral-h), var(--color-neutral-s), var(--color-neutral-l));
|
|
82
|
+
}
|
|
83
|
+
.mg-button.mg-button--info {
|
|
84
|
+
border-color: hsl(var(--color-info-h), var(--color-info-s), var(--color-info-l));
|
|
85
|
+
/* IE FIX */
|
|
86
|
+
border-color: hsl(var(--color-info-h), var(--color-info-s), calc(var(--color-info-l) - 10%));
|
|
87
|
+
color: hsl(var(--color-neutral));
|
|
88
|
+
background: hsl(var(--color-info-h), var(--color-info-s), var(--color-info-l));
|
|
89
|
+
/* IE FIX */
|
|
90
|
+
background: linear-gradient(to bottom, hsl(var(--color-info-h), var(--color-info-s), var(--color-info-l)), hsl(var(--color-info-h), var(--color-info-s), calc(var(--color-info-l) - 10%)));
|
|
91
|
+
}
|
|
92
|
+
.mg-button.mg-button--info:hover:not([disabled], [aria-disabled], .disabled), .mg-button.mg-button--info:focus:not([disabled], [aria-disabled], .disabled), .mg-button.mg-button--info:active:not([disabled], [aria-disabled], .disabled) {
|
|
93
|
+
background: hsl(var(--color-info-h), var(--color-info-s), var(--color-info-l));
|
|
94
|
+
}
|
|
95
|
+
.mg-button.mg-button--flat {
|
|
96
|
+
background: none;
|
|
97
|
+
border: none;
|
|
98
|
+
}
|
|
99
|
+
.mg-button.mg-button--flat:hover:not([disabled], [aria-disabled], .disabled), .mg-button.mg-button--flat:focus:not([disabled], [aria-disabled], .disabled), .mg-button.mg-button--flat:active:not([disabled], [aria-disabled], .disabled) {
|
|
100
|
+
background: hsla(var(--color-dark), 0.1);
|
|
101
|
+
}
|
|
102
|
+
.mg-button ::slotted(mg-icon) {
|
|
103
|
+
display: inline-flex;
|
|
104
|
+
flex-shrink: 0;
|
|
105
|
+
line-height: 1;
|
|
106
|
+
margin: auto 0;
|
|
107
|
+
}
|
|
108
|
+
.mg-button__content {
|
|
109
|
+
display: flex;
|
|
110
|
+
align-items: baseline;
|
|
111
|
+
column-gap: 0.6rem;
|
|
112
|
+
}
|
|
113
|
+
.mg-button--loading > mg-icon {
|
|
114
|
+
position: absolute;
|
|
115
|
+
left: 50%;
|
|
116
|
+
top: 50%;
|
|
117
|
+
transform: translate(-50%, -50%);
|
|
118
|
+
}
|
|
119
|
+
.mg-button--loading .mg-button__content {
|
|
120
|
+
opacity: 0;
|
|
121
|
+
}
|
|
122
|
+
.mg-button ::slotted(mg-badge) {
|
|
123
|
+
margin-left: 0.3rem;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
mg-button {
|
|
127
|
+
display: inline-block;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
.mg-button,
|
|
131
|
+
mg-button {
|
|
132
|
+
vertical-align: middle;
|
|
133
|
+
max-width: 100%;
|
|
134
|
+
}
|
|
@@ -0,0 +1,236 @@
|
|
|
1
|
+
import { Component, Element, h, Prop, State, Watch } from '@stencil/core';
|
|
2
|
+
import { variants } from './mg-button.conf';
|
|
3
|
+
import { ClassList, createID } from '../../../utils/components.utils';
|
|
4
|
+
export class MgButton {
|
|
5
|
+
constructor() {
|
|
6
|
+
/************
|
|
7
|
+
* Internal *
|
|
8
|
+
************/
|
|
9
|
+
this.onClickElementFn = null;
|
|
10
|
+
/**
|
|
11
|
+
* Define button variant
|
|
12
|
+
*/
|
|
13
|
+
this.variant = variants[0]; // Primary
|
|
14
|
+
/**
|
|
15
|
+
* Identifier is used for the element ID (id is a reserved prop in Stencil.js)
|
|
16
|
+
* If not set, it will be created.
|
|
17
|
+
*/
|
|
18
|
+
this.identifier = createID('mg-button');
|
|
19
|
+
/**
|
|
20
|
+
* Disable button
|
|
21
|
+
*/
|
|
22
|
+
this.disabled = false;
|
|
23
|
+
/**
|
|
24
|
+
* Define if button is round.
|
|
25
|
+
* Used for icon button.
|
|
26
|
+
*/
|
|
27
|
+
this.isIcon = false;
|
|
28
|
+
/**
|
|
29
|
+
* Option to set input disable on click, in order to prevent multi-click.
|
|
30
|
+
* Parent component have to remove the attribute 'disabled' when the process ends.
|
|
31
|
+
*/
|
|
32
|
+
this.disableOnClick = false;
|
|
33
|
+
/**
|
|
34
|
+
* Define if button is loading, default to false.
|
|
35
|
+
* Trigger when button is clicked or key-up ['enter', 'space], then value change to true.
|
|
36
|
+
* It's required to reset to false when action/promise in parent is done to stop the loading state
|
|
37
|
+
*/
|
|
38
|
+
this.loading = false;
|
|
39
|
+
/**
|
|
40
|
+
* Component classes
|
|
41
|
+
*/
|
|
42
|
+
this.classList = new ClassList(['mg-button']);
|
|
43
|
+
/**
|
|
44
|
+
* Trigger actions onClick event
|
|
45
|
+
*/
|
|
46
|
+
this.handleClick = (event) => {
|
|
47
|
+
if (this.disabled)
|
|
48
|
+
event.stopPropagation();
|
|
49
|
+
// Used to prevent multi-click.
|
|
50
|
+
if (this.disableOnClick && !this.disabled) {
|
|
51
|
+
this.loading = true;
|
|
52
|
+
this.disabled = true;
|
|
53
|
+
}
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
validateVariant(newValue) {
|
|
57
|
+
if (!variants.includes(newValue)) {
|
|
58
|
+
throw new Error(`<mg-button> prop "variant" must be one of : ${variants.join(', ')}`);
|
|
59
|
+
}
|
|
60
|
+
this.classList.add(`mg-button--${this.variant}`);
|
|
61
|
+
}
|
|
62
|
+
disabledHandler(isDisabled) {
|
|
63
|
+
// Remove loading when enable
|
|
64
|
+
// Will be set back onclick
|
|
65
|
+
if (!isDisabled && this.disableOnClick) {
|
|
66
|
+
this.loading = false;
|
|
67
|
+
}
|
|
68
|
+
// Manage if onclick
|
|
69
|
+
this.element.onclick = isDisabled ? undefined : this.onClickElementFn;
|
|
70
|
+
}
|
|
71
|
+
loadingHandler(newValue) {
|
|
72
|
+
// we add loading style if it newvalue is true else we remove it
|
|
73
|
+
if (newValue) {
|
|
74
|
+
this.classList.add('mg-button--loading');
|
|
75
|
+
}
|
|
76
|
+
else {
|
|
77
|
+
this.classList.delete('mg-button--loading');
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Check if props are well configured on init
|
|
82
|
+
*/
|
|
83
|
+
componentWillLoad() {
|
|
84
|
+
this.validateVariant(this.variant);
|
|
85
|
+
if (this.isIcon) {
|
|
86
|
+
this.classList.add(`mg-button--icon`);
|
|
87
|
+
if (typeof this.label !== 'string' || this.label === '') {
|
|
88
|
+
throw new Error(`<mg-button> prop "label" is mandatory when prop "isIcon" is set to true.`);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
// Store the onclick fn
|
|
92
|
+
this.onClickElementFn = this.element.onclick;
|
|
93
|
+
this.disabledHandler(this.disabled);
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Render component
|
|
97
|
+
*/
|
|
98
|
+
render() {
|
|
99
|
+
return (h("button", { id: this.identifier, class: this.classList.join(), "aria-label": this.label, "aria-disabled": this.disabled, onClick: this.handleClick },
|
|
100
|
+
this.loading && h("mg-icon", { icon: "loader", spin: true }),
|
|
101
|
+
h("div", { class: "mg-button__content" },
|
|
102
|
+
h("slot", null))));
|
|
103
|
+
}
|
|
104
|
+
static get is() { return "mg-button"; }
|
|
105
|
+
static get encapsulation() { return "scoped"; }
|
|
106
|
+
static get originalStyleUrls() { return {
|
|
107
|
+
"$": ["mg-button.scss"]
|
|
108
|
+
}; }
|
|
109
|
+
static get styleUrls() { return {
|
|
110
|
+
"$": ["mg-button.css"]
|
|
111
|
+
}; }
|
|
112
|
+
static get properties() { return {
|
|
113
|
+
"variant": {
|
|
114
|
+
"type": "string",
|
|
115
|
+
"mutable": false,
|
|
116
|
+
"complexType": {
|
|
117
|
+
"original": "string",
|
|
118
|
+
"resolved": "string",
|
|
119
|
+
"references": {}
|
|
120
|
+
},
|
|
121
|
+
"required": false,
|
|
122
|
+
"optional": false,
|
|
123
|
+
"docs": {
|
|
124
|
+
"tags": [],
|
|
125
|
+
"text": "Define button variant"
|
|
126
|
+
},
|
|
127
|
+
"attribute": "variant",
|
|
128
|
+
"reflect": false,
|
|
129
|
+
"defaultValue": "variants[0]"
|
|
130
|
+
},
|
|
131
|
+
"identifier": {
|
|
132
|
+
"type": "string",
|
|
133
|
+
"mutable": false,
|
|
134
|
+
"complexType": {
|
|
135
|
+
"original": "string",
|
|
136
|
+
"resolved": "string",
|
|
137
|
+
"references": {}
|
|
138
|
+
},
|
|
139
|
+
"required": false,
|
|
140
|
+
"optional": true,
|
|
141
|
+
"docs": {
|
|
142
|
+
"tags": [],
|
|
143
|
+
"text": "Identifier is used for the element ID (id is a reserved prop in Stencil.js)\nIf not set, it will be created."
|
|
144
|
+
},
|
|
145
|
+
"attribute": "identifier",
|
|
146
|
+
"reflect": false,
|
|
147
|
+
"defaultValue": "createID('mg-button')"
|
|
148
|
+
},
|
|
149
|
+
"label": {
|
|
150
|
+
"type": "string",
|
|
151
|
+
"mutable": false,
|
|
152
|
+
"complexType": {
|
|
153
|
+
"original": "string",
|
|
154
|
+
"resolved": "string",
|
|
155
|
+
"references": {}
|
|
156
|
+
},
|
|
157
|
+
"required": false,
|
|
158
|
+
"optional": false,
|
|
159
|
+
"docs": {
|
|
160
|
+
"tags": [],
|
|
161
|
+
"text": "aria-label\nIn case button text is not explicit enough"
|
|
162
|
+
},
|
|
163
|
+
"attribute": "label",
|
|
164
|
+
"reflect": false
|
|
165
|
+
},
|
|
166
|
+
"disabled": {
|
|
167
|
+
"type": "boolean",
|
|
168
|
+
"mutable": true,
|
|
169
|
+
"complexType": {
|
|
170
|
+
"original": "boolean",
|
|
171
|
+
"resolved": "boolean",
|
|
172
|
+
"references": {}
|
|
173
|
+
},
|
|
174
|
+
"required": false,
|
|
175
|
+
"optional": false,
|
|
176
|
+
"docs": {
|
|
177
|
+
"tags": [],
|
|
178
|
+
"text": "Disable button"
|
|
179
|
+
},
|
|
180
|
+
"attribute": "disabled",
|
|
181
|
+
"reflect": false,
|
|
182
|
+
"defaultValue": "false"
|
|
183
|
+
},
|
|
184
|
+
"isIcon": {
|
|
185
|
+
"type": "boolean",
|
|
186
|
+
"mutable": false,
|
|
187
|
+
"complexType": {
|
|
188
|
+
"original": "boolean",
|
|
189
|
+
"resolved": "boolean",
|
|
190
|
+
"references": {}
|
|
191
|
+
},
|
|
192
|
+
"required": false,
|
|
193
|
+
"optional": false,
|
|
194
|
+
"docs": {
|
|
195
|
+
"tags": [],
|
|
196
|
+
"text": "Define if button is round.\nUsed for icon button."
|
|
197
|
+
},
|
|
198
|
+
"attribute": "is-icon",
|
|
199
|
+
"reflect": false,
|
|
200
|
+
"defaultValue": "false"
|
|
201
|
+
},
|
|
202
|
+
"disableOnClick": {
|
|
203
|
+
"type": "boolean",
|
|
204
|
+
"mutable": false,
|
|
205
|
+
"complexType": {
|
|
206
|
+
"original": "boolean",
|
|
207
|
+
"resolved": "boolean",
|
|
208
|
+
"references": {}
|
|
209
|
+
},
|
|
210
|
+
"required": false,
|
|
211
|
+
"optional": false,
|
|
212
|
+
"docs": {
|
|
213
|
+
"tags": [],
|
|
214
|
+
"text": "Option to set input disable on click, in order to prevent multi-click.\nParent component have to remove the attribute 'disabled' when the process ends."
|
|
215
|
+
},
|
|
216
|
+
"attribute": "disable-on-click",
|
|
217
|
+
"reflect": false,
|
|
218
|
+
"defaultValue": "false"
|
|
219
|
+
}
|
|
220
|
+
}; }
|
|
221
|
+
static get states() { return {
|
|
222
|
+
"loading": {},
|
|
223
|
+
"classList": {}
|
|
224
|
+
}; }
|
|
225
|
+
static get elementRef() { return "element"; }
|
|
226
|
+
static get watchers() { return [{
|
|
227
|
+
"propName": "variant",
|
|
228
|
+
"methodName": "validateVariant"
|
|
229
|
+
}, {
|
|
230
|
+
"propName": "disabled",
|
|
231
|
+
"methodName": "disabledHandler"
|
|
232
|
+
}, {
|
|
233
|
+
"propName": "loading",
|
|
234
|
+
"methodName": "loadingHandler"
|
|
235
|
+
}]; }
|
|
236
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { h } from '@stencil/core';
|
|
2
|
+
import { variants } from './mg-button.conf';
|
|
3
|
+
import { icons } from '../mg-icon/mg-icon.conf';
|
|
4
|
+
export default {
|
|
5
|
+
component: 'mg-button',
|
|
6
|
+
title: 'Atoms/mg-button',
|
|
7
|
+
argTypes: {
|
|
8
|
+
variant: {
|
|
9
|
+
options: variants,
|
|
10
|
+
control: { type: 'select' },
|
|
11
|
+
},
|
|
12
|
+
},
|
|
13
|
+
};
|
|
14
|
+
const Template = args => {
|
|
15
|
+
// Extract slot so it won't be render as an attribute
|
|
16
|
+
const slot = args.slot;
|
|
17
|
+
delete args.slot;
|
|
18
|
+
const disableOnClick = args.disableOnClick;
|
|
19
|
+
delete args.disableOnClick;
|
|
20
|
+
const isIcon = args.isIcon;
|
|
21
|
+
delete args.isIcon;
|
|
22
|
+
// return element
|
|
23
|
+
return (h("mg-button", Object.assign({}, args, { "disable-on-click": disableOnClick, "is-icon": isIcon }), slot));
|
|
24
|
+
};
|
|
25
|
+
export const MgButton = Template.bind({});
|
|
26
|
+
MgButton.args = {
|
|
27
|
+
slot: 'Text button',
|
|
28
|
+
variant: variants[0],
|
|
29
|
+
label: 'Explicit aria label',
|
|
30
|
+
identifier: undefined,
|
|
31
|
+
disabled: false,
|
|
32
|
+
disableOnClick: false,
|
|
33
|
+
isIcon: false,
|
|
34
|
+
};
|
|
35
|
+
export const IsIcon = Template.bind({});
|
|
36
|
+
IsIcon.args = Object.assign(Object.assign({}, MgButton.args), { isIcon: true, slot: h("mg-icon", { icon: Object.keys(icons)[0] }) });
|
|
37
|
+
export const DisableOnClick = Template.bind({});
|
|
38
|
+
DisableOnClick.args = Object.assign(Object.assign({}, MgButton.args), { disableOnClick: true });
|