@mgdis/mg-components 5.5.0 → 5.7.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/dist/cjs/{index-c3450336.js → index-5e7ede97.js} +120 -4
- package/dist/cjs/loader.cjs.js +4 -3
- package/dist/cjs/{mg-badge_30.cjs.entry.js → mg-action-more_31.cjs.entry.js} +1223 -547
- package/dist/cjs/mg-components.cjs.js +7 -3
- package/dist/collection/collection-manifest.json +6 -5
- package/dist/collection/components/atoms/mg-badge/mg-badge.conf.js +1 -1
- package/dist/collection/components/atoms/mg-badge/mg-badge.css +13 -0
- package/dist/collection/components/atoms/mg-badge/mg-badge.js +4 -4
- package/dist/collection/components/atoms/mg-button/mg-button.css +9 -22
- package/dist/collection/components/atoms/mg-button/mg-button.js +1 -1
- package/dist/collection/components/atoms/mg-card/mg-card.css +13 -6
- package/dist/collection/components/atoms/mg-icon/mg-icon.conf.js +38 -28
- package/dist/collection/components/atoms/mg-icon/mg-icon.js +3 -3
- package/dist/collection/components/atoms/mg-tag/mg-tag.css +6 -6
- package/dist/collection/components/atoms/mg-tag/mg-tag.js +4 -4
- package/dist/collection/components/atoms/mg-tooltip/mg-tooltip.css +2 -0
- package/dist/collection/components/atoms/mg-tooltip/mg-tooltip.js +14 -17
- package/dist/collection/components/molecules/inputs/MgInput.js +6 -1
- package/dist/collection/components/molecules/inputs/mg-input-checkbox/mg-input-checkbox.css +4 -3
- package/dist/collection/components/molecules/inputs/mg-input-checkbox/mg-input-checkbox.js +3 -2
- package/dist/collection/components/molecules/inputs/mg-input-date/mg-input-date.css +7 -3
- package/dist/collection/components/molecules/inputs/mg-input-date/mg-input-date.js +5 -2
- package/dist/collection/components/molecules/inputs/mg-input-numeric/mg-input-numeric.css +7 -3
- package/dist/collection/components/molecules/inputs/mg-input-numeric/mg-input-numeric.js +1 -1
- package/dist/collection/components/molecules/inputs/mg-input-password/mg-input-password.css +7 -3
- package/dist/collection/components/molecules/inputs/mg-input-radio/mg-input-radio.css +4 -3
- package/dist/collection/components/molecules/inputs/mg-input-radio/mg-input-radio.js +2 -1
- package/dist/collection/components/molecules/inputs/mg-input-select/mg-input-select.css +7 -3
- package/dist/collection/components/molecules/inputs/mg-input-select/mg-input-select.js +8 -4
- package/dist/collection/components/molecules/inputs/mg-input-text/mg-input-text.css +7 -3
- package/dist/collection/components/molecules/inputs/mg-input-textarea/mg-input-textarea.css +7 -3
- package/dist/collection/components/molecules/inputs/mg-input-textarea/mg-input-textarea.js +1 -1
- package/dist/collection/components/molecules/inputs/mg-input-toggle/mg-input-toggle.css +4 -4
- package/dist/collection/components/molecules/menu/mg-menu/mg-menu.conf.js +17 -0
- package/dist/collection/components/molecules/menu/mg-menu/mg-menu.css +27 -0
- package/dist/collection/components/molecules/menu/mg-menu/mg-menu.js +141 -19
- package/dist/collection/components/molecules/menu/mg-menu-item/mg-menu-item.conf.js +0 -4
- package/dist/collection/components/molecules/menu/mg-menu-item/mg-menu-item.css +48 -21
- package/dist/collection/components/molecules/menu/mg-menu-item/mg-menu-item.js +139 -71
- package/dist/collection/components/molecules/mg-action-more/mg-action-more.conf.js +1 -0
- package/dist/collection/components/molecules/mg-action-more/mg-action-more.css +38 -0
- package/dist/collection/components/molecules/mg-action-more/mg-action-more.js +252 -0
- package/dist/collection/components/molecules/mg-form/mg-form.js +2 -2
- package/dist/collection/components/molecules/mg-illustrated-message/mg-illustrated-message.js +4 -3
- package/dist/collection/components/molecules/mg-message/mg-message.css +7 -0
- package/dist/collection/components/molecules/mg-message/mg-message.js +54 -13
- package/dist/collection/components/molecules/mg-modal/mg-modal.css +8 -1
- package/dist/collection/components/molecules/mg-pagination/mg-pagination.js +19 -1
- package/dist/collection/components/molecules/mg-panel/mg-panel.css +7 -0
- package/dist/collection/components/molecules/mg-panel/mg-panel.js +2 -2
- package/dist/collection/components/molecules/mg-popover/mg-popover.css +72 -15
- package/dist/collection/components/molecules/mg-popover/mg-popover.js +64 -7
- package/dist/collection/components/molecules/mg-skip-links/mg-skip-links.js +33 -1
- package/dist/collection/components/molecules/mg-tabs/mg-tabs.css +12 -7
- package/dist/collection/components/molecules/mg-tabs/mg-tabs.js +105 -57
- package/dist/collection/locales/en/messages.json +10 -1
- package/dist/collection/locales/fr/messages.json +10 -1
- package/dist/collection/locales/index.js +3 -26
- package/dist/collection/styles/a11y.scss +32 -0
- package/dist/collection/styles/components.scss +3 -0
- package/dist/collection/styles/fonts.scss +21 -0
- package/dist/collection/styles/form.scss +3 -0
- package/dist/collection/styles/global.scss +87 -0
- package/dist/collection/styles/layout.scss +29 -0
- package/dist/collection/styles/main.scss +23 -0
- package/dist/collection/styles/mg-icon-animation.scss +6 -0
- package/dist/collection/styles/navigation-button.scss +77 -0
- package/dist/collection/styles/reset-mg-card-slotted-variables.scss +9 -0
- package/dist/collection/styles/typography.scss +75 -0
- package/dist/collection/styles/utilities.scss +21 -0
- package/dist/collection/utils/behaviors.utils.js +151 -0
- package/dist/collection/utils/components.utils.js +52 -0
- package/dist/collection/utils/locale.utils.js +28 -6
- package/dist/collection/utils/unit.test.utils.js +65 -32
- package/dist/collection/variables.css +11 -10
- package/dist/components/MgInput.js +6 -1
- package/dist/components/components.utils.js +53 -1
- package/dist/components/index.d.ts +10 -0
- package/dist/components/index.js +2 -1
- package/dist/components/index2.js +79 -20
- package/dist/components/mg-action-more.d.ts +11 -0
- package/dist/components/mg-action-more.js +215 -0
- package/dist/components/mg-badge2.js +5 -5
- package/dist/components/mg-button2.js +2 -2
- package/dist/components/mg-card2.js +1 -1
- package/dist/components/mg-form.js +2 -2
- package/dist/components/mg-icon2.js +41 -31
- package/dist/components/mg-illustrated-message.js +4 -3
- package/dist/components/mg-input-checkbox.js +3 -3
- package/dist/components/mg-input-date.js +7 -5
- package/dist/components/mg-input-numeric.js +3 -4
- package/dist/components/mg-input-password.js +1 -1
- package/dist/components/mg-input-radio.js +2 -2
- package/dist/components/mg-input-select2.js +9 -5
- package/dist/components/mg-input-text2.js +1 -1
- package/dist/components/mg-input-textarea.js +2 -2
- package/dist/components/mg-input-toggle.js +1 -1
- package/dist/components/mg-menu-item.js +1 -253
- package/dist/components/mg-menu-item2.js +520 -0
- package/dist/components/mg-menu.js +1 -129
- package/dist/components/mg-menu2.js +247 -0
- package/dist/components/mg-message.js +55 -14
- package/dist/components/mg-modal.js +1 -1
- package/dist/components/mg-pagination.js +3 -1
- package/dist/components/mg-panel.js +3 -3
- package/dist/components/mg-popover.js +1 -190
- package/dist/components/mg-popover2.js +226 -0
- package/dist/components/mg-skip-links.js +16 -2
- package/dist/components/mg-tabs.js +104 -55
- package/dist/components/mg-tag.js +5 -5
- package/dist/components/mg-tooltip2.js +15 -18
- package/dist/esm/{index-78edde1d.js → index-03cceb11.js} +120 -5
- package/dist/esm/loader.js +4 -3
- package/dist/esm/{mg-badge_30.entry.js → mg-action-more_31.entry.js} +1223 -548
- package/dist/esm/mg-components.js +4 -3
- package/dist/esm/polyfills/css-shim.js +1 -1
- package/dist/mg-components/locales/en/messages.json +10 -1
- package/dist/mg-components/locales/fr/messages.json +10 -1
- package/dist/mg-components/mg-components.css +1 -1
- package/dist/mg-components/mg-components.esm.js +1 -1
- package/dist/mg-components/p-4cfd5423.entry.js +1 -0
- package/dist/mg-components/p-e126dd84.js +2 -0
- package/dist/mg-components/styles/a11y.scss +32 -0
- package/dist/mg-components/styles/components.scss +3 -0
- package/dist/mg-components/styles/fonts.scss +21 -0
- package/dist/mg-components/styles/form.scss +3 -0
- package/dist/mg-components/styles/global.scss +87 -0
- package/dist/mg-components/styles/layout.scss +29 -0
- package/dist/mg-components/styles/main.scss +23 -0
- package/dist/mg-components/styles/mg-icon-animation.scss +6 -0
- package/dist/mg-components/styles/navigation-button.scss +77 -0
- package/dist/mg-components/styles/reset-mg-card-slotted-variables.scss +9 -0
- package/dist/mg-components/styles/typography.scss +75 -0
- package/dist/mg-components/styles/utilities.scss +21 -0
- package/dist/mg-components/variables.css +11 -10
- package/dist/types/components/atoms/mg-badge/mg-badge.conf.d.ts +2 -2
- package/dist/types/components/atoms/mg-button/mg-button.conf.d.ts +2 -2
- package/dist/types/components/atoms/mg-icon/mg-icon.conf.d.ts +2 -2
- package/dist/types/components/atoms/mg-tag/mg-tag.conf.d.ts +1 -1
- package/dist/types/components/molecules/inputs/MgInput.conf.d.ts +2 -2
- package/dist/types/components/molecules/inputs/mg-input-checkbox/mg-input-checkbox.conf.d.ts +2 -2
- package/dist/types/components/molecules/inputs/mg-input-radio/mg-input-radio.conf.d.ts +1 -1
- package/dist/types/components/molecules/inputs/mg-input-select/mg-input-select.conf.d.ts +2 -2
- package/dist/types/components/molecules/inputs/mg-input-textarea/mg-input-textarea.d.ts +1 -1
- package/dist/types/components/molecules/inputs/mg-input-toggle/mg-input-toggle.conf.d.ts +1 -1
- package/dist/types/components/molecules/menu/mg-menu/mg-menu.conf.d.ts +37 -0
- package/dist/types/components/molecules/menu/mg-menu/mg-menu.d.ts +51 -3
- package/dist/types/components/molecules/menu/mg-menu-item/mg-menu-item.conf.d.ts +0 -8
- package/dist/types/components/molecules/menu/mg-menu-item/mg-menu-item.d.ts +61 -15
- package/dist/types/components/molecules/mg-action-more/mg-action-more.conf.d.ts +42 -0
- package/dist/types/components/molecules/mg-action-more/mg-action-more.d.ts +81 -0
- package/dist/types/components/molecules/mg-message/mg-message.d.ts +21 -4
- package/dist/types/components/molecules/mg-pagination/mg-pagination.d.ts +4 -0
- package/dist/types/components/molecules/mg-popover/mg-popover.d.ts +13 -0
- package/dist/types/components/molecules/mg-skip-links/mg-skip-links.conf.d.ts +1 -1
- package/dist/types/components/molecules/mg-skip-links/mg-skip-links.d.ts +15 -0
- package/dist/types/components/molecules/mg-tabs/mg-tabs.conf.d.ts +5 -3
- package/dist/types/components/molecules/mg-tabs/mg-tabs.d.ts +22 -12
- package/dist/types/components.d.ts +98 -12
- package/dist/types/locales/index.d.ts +21 -10
- package/dist/types/stencil-public-runtime.d.ts +48 -3
- package/dist/types/utils/behaviors.utils.d.ts +77 -0
- package/dist/types/utils/components.utils.d.ts +14 -0
- package/dist/types/utils/locale.utils.d.ts +16 -3
- package/dist/types/utils/unit.test.utils.d.ts +68 -14
- package/loader/index.d.ts +9 -0
- package/package.json +28 -27
- package/readme.md +22 -31
- package/dist/.storybook/utils.js +0 -24
- package/dist/collection/components/atoms/mg-badge/doc/mg-badge.stories.js +0 -27
- package/dist/collection/components/atoms/mg-button/doc/mg-button.stories.js +0 -38
- package/dist/collection/components/atoms/mg-card/doc/mg-card.stories.js +0 -18
- package/dist/collection/components/atoms/mg-character-left/doc/mg-character-left.stories.js +0 -20
- package/dist/collection/components/atoms/mg-divider/doc/mg-divider.stories.js +0 -18
- package/dist/collection/components/atoms/mg-icon/doc/mg-icon.stories.js +0 -41
- package/dist/collection/components/atoms/mg-input-title/doc/mg-input-title.stories.js +0 -21
- package/dist/collection/components/atoms/mg-tag/doc/mg-tag.stories.js +0 -22
- package/dist/collection/components/atoms/mg-tooltip/doc/mg-tooltip.stories.js +0 -50
- package/dist/collection/components/molecules/inputs/mg-input-checkbox/doc/mg-input-checkbox.stories.js +0 -50
- package/dist/collection/components/molecules/inputs/mg-input-date/doc/mg-input-date.stories.js +0 -43
- package/dist/collection/components/molecules/inputs/mg-input-numeric/doc/mg-input-numeric.stories.js +0 -68
- package/dist/collection/components/molecules/inputs/mg-input-password/doc/mg-input-password.stories.js +0 -46
- package/dist/collection/components/molecules/inputs/mg-input-radio/doc/mg-input-radio.stories.js +0 -59
- package/dist/collection/components/molecules/inputs/mg-input-select/doc/mg-input-select.stories.js +0 -77
- package/dist/collection/components/molecules/inputs/mg-input-text/doc/mg-input-text.stories.js +0 -110
- package/dist/collection/components/molecules/inputs/mg-input-textarea/doc/mg-input-textarea.stories.js +0 -54
- package/dist/collection/components/molecules/inputs/mg-input-toggle/doc/mg-input-toggle.stories.js +0 -51
- package/dist/collection/components/molecules/menu/mg-menu/doc/mg-menu.stories.js +0 -87
- package/dist/collection/components/molecules/menu/mg-menu-item/doc/mg-menu-item.stories.js +0 -39
- package/dist/collection/components/molecules/mg-details/doc/mg-details.stories.js +0 -24
- package/dist/collection/components/molecules/mg-form/doc/mg-form.stories.js +0 -47
- package/dist/collection/components/molecules/mg-illustrated-message/doc/mg-illustrated-message.stories.js +0 -19
- package/dist/collection/components/molecules/mg-message/doc/mg-message.stories.js +0 -39
- package/dist/collection/components/molecules/mg-modal/doc/mg-modal.stories.js +0 -39
- package/dist/collection/components/molecules/mg-pagination/doc/mg-pagination.stories.js +0 -20
- package/dist/collection/components/molecules/mg-panel/doc/mg-panel.stories.js +0 -22
- package/dist/collection/components/molecules/mg-popover/doc/mg-popover.stories.js +0 -34
- package/dist/collection/components/molecules/mg-skip-links/doc/mg-skip-links.stories.js +0 -24
- package/dist/collection/components/molecules/mg-tabs/doc/mg-tabs.stories.js +0 -51
- package/dist/collection/stories/grids.stories.js +0 -7
- package/dist/collection/stories/helpers.stories.js +0 -23
- package/dist/collection/stories/icons.stories.js +0 -25
- package/dist/collection/stories/typography.stories.js +0 -24
- package/dist/components/locale.utils.js +0 -40
- package/dist/components/mg-menu.conf.js +0 -10
- package/dist/mg-components/p-125c54ca.js +0 -2
- package/dist/mg-components/p-4961c96c.entry.js +0 -1
- package/dist/types/components/atoms/mg-badge/doc/mg-badge.stories.d.ts +0 -13
- package/dist/types/components/atoms/mg-button/doc/mg-button.stories.d.ts +0 -16
- package/dist/types/components/atoms/mg-card/doc/mg-card.stories.d.ts +0 -6
- package/dist/types/components/atoms/mg-character-left/doc/mg-character-left.stories.d.ts +0 -6
- package/dist/types/components/atoms/mg-divider/doc/mg-divider.stories.d.ts +0 -6
- package/dist/types/components/atoms/mg-icon/doc/mg-icon.stories.d.ts +0 -26
- package/dist/types/components/atoms/mg-input-title/doc/mg-input-title.stories.d.ts +0 -6
- package/dist/types/components/atoms/mg-tag/doc/mg-tag.stories.d.ts +0 -6
- package/dist/types/components/atoms/mg-tooltip/doc/mg-tooltip.stories.d.ts +0 -18
- package/dist/types/components/molecules/inputs/mg-input-checkbox/doc/mg-input-checkbox.stories.d.ts +0 -11
- package/dist/types/components/molecules/inputs/mg-input-date/doc/mg-input-date.stories.d.ts +0 -12
- package/dist/types/components/molecules/inputs/mg-input-numeric/doc/mg-input-numeric.stories.d.ts +0 -32
- package/dist/types/components/molecules/inputs/mg-input-password/doc/mg-input-password.stories.d.ts +0 -22
- package/dist/types/components/molecules/inputs/mg-input-radio/doc/mg-input-radio.stories.d.ts +0 -20
- package/dist/types/components/molecules/inputs/mg-input-select/doc/mg-input-select.stories.d.ts +0 -34
- package/dist/types/components/molecules/inputs/mg-input-text/doc/mg-input-text.stories.d.ts +0 -39
- package/dist/types/components/molecules/inputs/mg-input-textarea/doc/mg-input-textarea.stories.d.ts +0 -19
- package/dist/types/components/molecules/inputs/mg-input-toggle/doc/mg-input-toggle.stories.d.ts +0 -12
- package/dist/types/components/molecules/menu/mg-menu/doc/mg-menu.stories.d.ts +0 -17
- package/dist/types/components/molecules/menu/mg-menu-item/doc/mg-menu-item.stories.d.ts +0 -12
- package/dist/types/components/molecules/mg-details/doc/mg-details.stories.d.ts +0 -11
- package/dist/types/components/molecules/mg-form/doc/mg-form.stories.d.ts +0 -11
- package/dist/types/components/molecules/mg-illustrated-message/doc/mg-illustrated-message.stories.d.ts +0 -6
- package/dist/types/components/molecules/mg-message/doc/mg-message.stories.d.ts +0 -26
- package/dist/types/components/molecules/mg-modal/doc/mg-modal.stories.d.ts +0 -13
- package/dist/types/components/molecules/mg-pagination/doc/mg-pagination.stories.d.ts +0 -11
- package/dist/types/components/molecules/mg-panel/doc/mg-panel.stories.d.ts +0 -11
- package/dist/types/components/molecules/mg-popover/doc/mg-popover.stories.d.ts +0 -22
- package/dist/types/components/molecules/mg-skip-links/doc/mg-skip-links.stories.d.ts +0 -11
- package/dist/types/components/molecules/mg-tabs/doc/mg-tabs.stories.d.ts +0 -20
- package/dist/types/home/runner/work/mg-components/mg-components/.stencil/.storybook/utils.d.ts +0 -1
- package/dist/types/stories/grids.stories.d.ts +0 -5
- package/dist/types/stories/helpers.stories.d.ts +0 -13
- package/dist/types/stories/icons.stories.d.ts +0 -13
- package/dist/types/stories/typography.stories.d.ts +0 -5
|
@@ -16,25 +16,7 @@ export class MgTabs {
|
|
|
16
16
|
// classes
|
|
17
17
|
this.tabPanel = 'panel';
|
|
18
18
|
this.buttonTabBaseClass = 'mg-tabs__navigation-button';
|
|
19
|
-
// variables
|
|
20
19
|
this.startIndex = 1;
|
|
21
|
-
/**
|
|
22
|
-
* Method to set active tab
|
|
23
|
-
*
|
|
24
|
-
* @param {number} tabKey item tab key to set to ACTIVE status
|
|
25
|
-
* @returns {void}
|
|
26
|
-
*/
|
|
27
|
-
this.setActiveTab = (tabKey) => {
|
|
28
|
-
// reset active tabs
|
|
29
|
-
this.tabs.forEach(tab => {
|
|
30
|
-
if (this.tabHasGivenStatus(tab, Status.ACTIVE))
|
|
31
|
-
tab.status = Status.VISIBLE;
|
|
32
|
-
});
|
|
33
|
-
// set active tab from given tab key
|
|
34
|
-
this.tabs[tabKey - this.startIndex].status = Status.ACTIVE;
|
|
35
|
-
// emit change active tab key event
|
|
36
|
-
this.activeTabChange.emit(tabKey);
|
|
37
|
-
};
|
|
38
20
|
/**
|
|
39
21
|
* Method to know if given tab has the given status
|
|
40
22
|
*
|
|
@@ -42,7 +24,7 @@ export class MgTabs {
|
|
|
42
24
|
* @param {Status} status status to valide
|
|
43
25
|
* @returns {boolean} status comparaison
|
|
44
26
|
*/
|
|
45
|
-
this.
|
|
27
|
+
this.tabHasStatus = (tab, status) => tab.status === status;
|
|
46
28
|
/**
|
|
47
29
|
* Method to get element id from index
|
|
48
30
|
*
|
|
@@ -50,31 +32,43 @@ export class MgTabs {
|
|
|
50
32
|
* @param {number} index to generate id
|
|
51
33
|
* @returns {string} generated element id
|
|
52
34
|
*/
|
|
53
|
-
this.getElementId = (element, index) => `${element}-${this.
|
|
35
|
+
this.getElementId = (element, index) => `${element}-${this.getTabItemIndex(index)}`;
|
|
54
36
|
/**
|
|
55
|
-
* Method to get tab index
|
|
37
|
+
* Method to get tab item index
|
|
56
38
|
*
|
|
57
39
|
* @param {number} index to get
|
|
58
40
|
* @returns {number} index
|
|
59
41
|
*/
|
|
60
|
-
this.
|
|
42
|
+
this.getTabItemIndex = (index) => index + this.startIndex;
|
|
43
|
+
/**
|
|
44
|
+
* Method to get the active-tab value
|
|
45
|
+
*
|
|
46
|
+
* @returns {number} of the active-tab
|
|
47
|
+
*/
|
|
48
|
+
this.getActiveTab = () => this.activeTab || this.getTabItemIndex(this.tabs.map((tab, index) => (Object.assign(Object.assign({}, tab), { index }))).find(tab => this.tabHasStatus(tab, Status.ACTIVE)).index);
|
|
61
49
|
/**
|
|
62
50
|
* Handle click events on tabs
|
|
63
51
|
*
|
|
64
52
|
* @param {MouseEvent} event mouse event
|
|
65
53
|
*/
|
|
66
54
|
this.handleClick = (event) => {
|
|
67
|
-
const tabId = event.currentTarget.
|
|
68
|
-
|
|
55
|
+
const tabId = event.currentTarget.dataset.index;
|
|
56
|
+
const tab = this.tabs[Number(tabId) - this.startIndex];
|
|
57
|
+
if (this.tabHasStatus(tab, Status.HIDDEN) || this.tabHasStatus(tab, Status.DISABLED)) {
|
|
58
|
+
event.preventDefault();
|
|
59
|
+
}
|
|
60
|
+
else {
|
|
61
|
+
this.activeTab = Number(tabId);
|
|
62
|
+
this.tabFocus = undefined;
|
|
63
|
+
}
|
|
69
64
|
};
|
|
70
65
|
/**
|
|
71
66
|
* get navigation button class from given status
|
|
72
67
|
*
|
|
73
68
|
* @param {Status} status button tab status
|
|
74
|
-
* @param {boolean} isSelector set if we need a CSS selector with the dot '.' at the begin. default value = false.
|
|
75
69
|
* @returns {string} button class/selector variant
|
|
76
70
|
*/
|
|
77
|
-
this.getNavigationButtonClass = (status
|
|
71
|
+
this.getNavigationButtonClass = (status) => `${this.buttonTabBaseClass}--${status}`;
|
|
78
72
|
/**
|
|
79
73
|
* Handle keyboard event on tabs
|
|
80
74
|
*
|
|
@@ -82,37 +76,66 @@ export class MgTabs {
|
|
|
82
76
|
* @returns {void}
|
|
83
77
|
*/
|
|
84
78
|
this.handleKeydown = (event) => {
|
|
85
|
-
let tabId = Number(event.target.getAttribute('data-index'));
|
|
86
79
|
const parent = event.target.parentElement;
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
80
|
+
if (['ArrowRight', 'ArrowLeft'].includes(event.key)) {
|
|
81
|
+
this.tabFocus = Number(event.target.dataset.index);
|
|
82
|
+
parent.querySelector(`[data-index="${this.tabFocus}"]`).setAttribute('tabindex', '-1');
|
|
83
|
+
// Move right
|
|
84
|
+
if (event.key === 'ArrowRight') {
|
|
85
|
+
this.tabFocus++;
|
|
86
|
+
// If we're at the end, go to the start
|
|
87
|
+
if (this.tabFocus > this.tabs.length)
|
|
88
|
+
this.tabFocus = this.startIndex;
|
|
89
|
+
// Move left
|
|
90
|
+
}
|
|
91
|
+
else if (event.key === 'ArrowLeft') {
|
|
92
|
+
this.tabFocus--;
|
|
93
|
+
// If we're at the start, move to the end
|
|
94
|
+
if (this.tabFocus < this.startIndex)
|
|
95
|
+
this.tabFocus = this.tabs.length;
|
|
96
|
+
}
|
|
97
|
+
const parentButtonElement = parent.querySelector(`[data-index="${this.tabFocus}"]`);
|
|
98
|
+
// if focus item is ['hidden'] we recursively repeat action
|
|
99
|
+
if (this.tabHasStatus(this.tabs[this.tabFocus - 1], Status.HIDDEN)) {
|
|
100
|
+
parentButtonElement.dispatchEvent(new KeyboardEvent('keydown', { key: event.key, bubbles: true }));
|
|
101
|
+
// else run focus methods on tabFocus element
|
|
102
|
+
}
|
|
103
|
+
else {
|
|
104
|
+
parentButtonElement.setAttribute('tabindex', '0');
|
|
105
|
+
parentButtonElement.focus();
|
|
106
|
+
}
|
|
93
107
|
}
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
// apply selected tab if exist
|
|
97
|
-
if (selectedTab !== null) {
|
|
98
|
-
selectedTab.focus();
|
|
99
|
-
this.activeTab = tabId;
|
|
108
|
+
else if (event.key === 'Tab') {
|
|
109
|
+
this.resetFocus();
|
|
100
110
|
}
|
|
101
111
|
};
|
|
112
|
+
/**
|
|
113
|
+
* Method to reset focus behavior
|
|
114
|
+
*
|
|
115
|
+
* @returns {void}
|
|
116
|
+
*/
|
|
117
|
+
this.resetFocus = () => {
|
|
118
|
+
// update asynchronously tabindex to prevent get focus on new tabindex at then end of event process
|
|
119
|
+
setTimeout(() => {
|
|
120
|
+
this.tabFocus = undefined;
|
|
121
|
+
Array.from(this.element.shadowRoot.querySelectorAll('[data-index]')).forEach((tab, index) => {
|
|
122
|
+
tab.setAttribute('tabindex', this.getActiveTab() - this.startIndex !== index ? '-1' : '0');
|
|
123
|
+
});
|
|
124
|
+
}, 0);
|
|
125
|
+
};
|
|
102
126
|
/**
|
|
103
127
|
* Validate slots setting
|
|
104
128
|
*/
|
|
105
129
|
this.validateSlots = () => {
|
|
106
130
|
const slots = Array.from(this.element.children).filter(slot => { var _a; return (_a = slot.getAttribute('slot')) === null || _a === void 0 ? void 0 : _a.includes('tab_content-'); });
|
|
107
|
-
if (slots.length !== this.tabs.length)
|
|
131
|
+
if (slots.length !== this.tabs.length)
|
|
108
132
|
throw new Error('<mg-tabs> Must have slots counts equal to tabs count.');
|
|
109
|
-
}
|
|
110
133
|
};
|
|
111
134
|
this.identifier = createID('mg-tabs');
|
|
112
135
|
this.label = undefined;
|
|
113
136
|
this.size = 'regular';
|
|
114
137
|
this.items = undefined;
|
|
115
|
-
this.activeTab =
|
|
138
|
+
this.activeTab = undefined;
|
|
116
139
|
this.tabs = [];
|
|
117
140
|
this.classList = new ClassList(['mg-tabs']);
|
|
118
141
|
}
|
|
@@ -123,29 +146,44 @@ export class MgTabs {
|
|
|
123
146
|
}
|
|
124
147
|
validateSize(newValue) {
|
|
125
148
|
if (!sizes.includes(newValue)) {
|
|
126
|
-
throw new Error(`<mg-tabs> prop "size" must be one of
|
|
149
|
+
throw new Error(`<mg-tabs> prop "size" must be one of: ${sizes.join(', ')}`);
|
|
127
150
|
}
|
|
128
151
|
this.classList.add(`mg-tabs--size-${this.size}`);
|
|
129
152
|
}
|
|
130
153
|
validateItems(newValue) {
|
|
131
154
|
// String array
|
|
132
155
|
if (allItemsAreString(newValue)) {
|
|
133
|
-
this.tabs = newValue.map(item => ({ label: item, status: Status.VISIBLE }));
|
|
156
|
+
this.tabs = newValue.map((item, index) => ({ label: item, status: index === 0 ? Status.ACTIVE : Status.VISIBLE }));
|
|
134
157
|
}
|
|
135
158
|
// Object array
|
|
136
|
-
else if (newValue && newValue.every(item => isTabItem(item))) {
|
|
159
|
+
else if (newValue && newValue.length > 0 && newValue.every(item => isTabItem(item))) {
|
|
137
160
|
this.tabs = newValue;
|
|
161
|
+
// init active tabs if not set. Default: index 0.
|
|
162
|
+
if (this.tabs.find(tab => this.tabHasStatus(tab, Status.ACTIVE)) === undefined)
|
|
163
|
+
this.tabs[0].status = Status.ACTIVE;
|
|
138
164
|
}
|
|
139
165
|
else {
|
|
140
166
|
throw new Error('<mg-tabs> prop "items" is required and all items must be the same type: TabItem.');
|
|
141
167
|
}
|
|
142
168
|
}
|
|
143
169
|
validateActiveTab(newValue) {
|
|
144
|
-
if (newValue
|
|
145
|
-
|
|
170
|
+
if (typeof newValue === 'number' && newValue >= 1 && newValue <= this.tabs.length) {
|
|
171
|
+
this.tabs.forEach((tab, index) => {
|
|
172
|
+
const isNewActiveTab = index === newValue - this.startIndex;
|
|
173
|
+
// reset active tabs
|
|
174
|
+
if (this.tabHasStatus(tab, Status.ACTIVE) && !isNewActiveTab)
|
|
175
|
+
tab.status = Status.VISIBLE;
|
|
176
|
+
// set active tab from given tab key
|
|
177
|
+
else if ((tab.status === undefined || this.tabHasStatus(tab, Status.VISIBLE)) && isNewActiveTab)
|
|
178
|
+
tab.status = Status.ACTIVE;
|
|
179
|
+
});
|
|
180
|
+
// emit change active tab key event
|
|
181
|
+
if (this.tabs.find(tab => this.tabHasStatus(tab, Status.ACTIVE)) !== undefined) {
|
|
182
|
+
this.activeTabChange.emit(newValue);
|
|
183
|
+
}
|
|
146
184
|
}
|
|
147
|
-
else {
|
|
148
|
-
|
|
185
|
+
else if (newValue !== undefined) {
|
|
186
|
+
throw new Error('<mg-tabs> prop "activeTab" must be between 1 and tabs length.');
|
|
149
187
|
}
|
|
150
188
|
}
|
|
151
189
|
/*************
|
|
@@ -164,19 +202,30 @@ export class MgTabs {
|
|
|
164
202
|
this.validateSize(this.size);
|
|
165
203
|
this.validateSlots();
|
|
166
204
|
}
|
|
205
|
+
/**
|
|
206
|
+
* add listners
|
|
207
|
+
*
|
|
208
|
+
* @returns {void}
|
|
209
|
+
*/
|
|
210
|
+
componentDidLoad() {
|
|
211
|
+
document.addEventListener('click', (event) => {
|
|
212
|
+
if (event.target.closest('mg-tabs') !== this.element)
|
|
213
|
+
this.resetFocus();
|
|
214
|
+
}, false);
|
|
215
|
+
}
|
|
167
216
|
/**
|
|
168
217
|
* Render
|
|
169
218
|
*
|
|
170
219
|
* @returns {HTMLElement} HTML Element
|
|
171
220
|
*/
|
|
172
221
|
render() {
|
|
173
|
-
return (h("div", { class: this.classList.join() }, h("header", { role: "tablist", "aria-label": this.label, class: "mg-tabs__header" }, this.tabs.map((tab, index) => (h("button", { role: "tab", id: this.getElementId(this.identifier, index), class: {
|
|
222
|
+
return (h("div", { class: this.classList.join() }, h("header", { role: "tablist", "aria-label": this.label, class: "mg-tabs__header" }, this.tabs.map((tab, index) => (h("button", { key: tab.label, role: "tab", id: this.getElementId(this.identifier, index), class: {
|
|
174
223
|
[`${this.buttonTabBaseClass}`]: true,
|
|
175
224
|
[`${this.buttonTabBaseClass}--horizontal`]: true,
|
|
176
|
-
[`${this.getNavigationButtonClass(Status.ACTIVE)}`]: this.
|
|
177
|
-
[`${this.getNavigationButtonClass(Status.DISABLED)}`]: this.
|
|
178
|
-
[`${this.getNavigationButtonClass(Status.HIDDEN)}`]: this.
|
|
179
|
-
}, tabindex: this.
|
|
225
|
+
[`${this.getNavigationButtonClass(Status.ACTIVE)}`]: this.tabHasStatus(tab, Status.ACTIVE),
|
|
226
|
+
[`${this.getNavigationButtonClass(Status.DISABLED)}`]: this.tabHasStatus(tab, Status.DISABLED),
|
|
227
|
+
[`${this.getNavigationButtonClass(Status.HIDDEN)}`]: this.tabHasStatus(tab, Status.HIDDEN),
|
|
228
|
+
}, tabindex: this.tabHasStatus(tab, Status.ACTIVE) ? 0 : -1, "aria-selected": this.tabHasStatus(tab, Status.ACTIVE).toString(), "aria-controls": this.getElementId(this.tabPanel, index), "aria-disabled": this.tabHasStatus(tab, Status.DISABLED), onClick: this.handleClick, onKeyDown: this.handleKeydown, "data-index": this.getTabItemIndex(index) }, tab.icon !== undefined && h("mg-icon", { icon: tab.icon }), tab.label, tab.badge !== undefined && h("mg-badge", { variant: "text-color", value: tab.badge.value, label: tab.badge.label, outline: tab.badge.role === 'information' }))))), this.tabs.map((tab, index) => (h("article", { key: tab.label, role: "tabpanel", id: this.getElementId(this.tabPanel, index), hidden: !this.tabHasStatus(tab, Status.ACTIVE), "aria-labelledby": this.getElementId(this.identifier, index), tabindex: this.tabHasStatus(tab, Status.ACTIVE) ? 0 : -1, class: "mg-tabs__content-container" }, h("slot", { name: this.getElementId('tab_content', index) }))))));
|
|
180
229
|
}
|
|
181
230
|
static get is() { return "mg-tabs"; }
|
|
182
231
|
static get encapsulation() { return "shadow"; }
|
|
@@ -282,11 +331,10 @@ export class MgTabs {
|
|
|
282
331
|
"optional": false,
|
|
283
332
|
"docs": {
|
|
284
333
|
"tags": [],
|
|
285
|
-
"text": "Active tab number
|
|
334
|
+
"text": "Active tab number"
|
|
286
335
|
},
|
|
287
336
|
"attribute": "active-tab",
|
|
288
|
-
"reflect": true
|
|
289
|
-
"defaultValue": "1"
|
|
337
|
+
"reflect": true
|
|
290
338
|
}
|
|
291
339
|
};
|
|
292
340
|
}
|
|
@@ -21,7 +21,9 @@
|
|
|
21
21
|
},
|
|
22
22
|
"form": {
|
|
23
23
|
"required": "Fields with a <strong class=\"is-asterisk\">*</strong> are required",
|
|
24
|
-
"
|
|
24
|
+
"requiredSingle": "Field with a <strong class=\"is-asterisk\">*</strong> is required",
|
|
25
|
+
"allRequired": "All fields are required",
|
|
26
|
+
"allRequiredSingle": "The field is required"
|
|
25
27
|
},
|
|
26
28
|
"message": {
|
|
27
29
|
"closeButton": "Close message"
|
|
@@ -49,5 +51,12 @@
|
|
|
49
51
|
"close": "Close",
|
|
50
52
|
"next": "next",
|
|
51
53
|
"previous": "previous"
|
|
54
|
+
},
|
|
55
|
+
"plusMenu": {
|
|
56
|
+
"moreLabel": "Additional menu",
|
|
57
|
+
"badgeLabel": "Include notification(s)"
|
|
58
|
+
},
|
|
59
|
+
"actionMore": {
|
|
60
|
+
"label": "Actions"
|
|
52
61
|
}
|
|
53
62
|
}
|
|
@@ -21,7 +21,9 @@
|
|
|
21
21
|
},
|
|
22
22
|
"form": {
|
|
23
23
|
"required": "Les champs marqués d'un <strong class=\"is-asterisk\">*</strong> sont obligatoires",
|
|
24
|
-
"
|
|
24
|
+
"requiredSingle": "Le champ marqué d'un <strong class=\"is-asterisk\">*</strong> est obligatoire",
|
|
25
|
+
"allRequired": "Tous les champs sont obligatoires",
|
|
26
|
+
"allRequiredSingle": "Le champ est obligatoire"
|
|
25
27
|
},
|
|
26
28
|
"message": {
|
|
27
29
|
"closeButton": "Fermer le message"
|
|
@@ -49,5 +51,12 @@
|
|
|
49
51
|
"close": "Fermer",
|
|
50
52
|
"next": "suivant",
|
|
51
53
|
"previous": "précédent"
|
|
54
|
+
},
|
|
55
|
+
"plusMenu": {
|
|
56
|
+
"moreLabel": "Menu complémentaire",
|
|
57
|
+
"badgeLabel": "Notification(s) incluse(s)"
|
|
58
|
+
},
|
|
59
|
+
"actionMore": {
|
|
60
|
+
"label": "Actions"
|
|
52
61
|
}
|
|
53
62
|
}
|
|
@@ -1,35 +1,12 @@
|
|
|
1
1
|
import en from './en/messages.json';
|
|
2
2
|
import fr from './fr/messages.json';
|
|
3
|
+
import { getLocaleMessages } from '../utils/locale.utils';
|
|
3
4
|
const defaultLocale = 'en';
|
|
4
5
|
const messages = { en, fr };
|
|
5
|
-
/**
|
|
6
|
-
* Get locale
|
|
7
|
-
*
|
|
8
|
-
* @param {HTMLElement} element element that needs to know the locale to use
|
|
9
|
-
* @returns {string} locale
|
|
10
|
-
*/
|
|
11
|
-
const getLocale = (element) => {
|
|
12
|
-
var _a;
|
|
13
|
-
// validate locale
|
|
14
|
-
const closestLang = Intl.NumberFormat.supportedLocalesOf((_a = element.closest('[lang]')) === null || _a === void 0 ? void 0 : _a.lang);
|
|
15
|
-
return closestLang.length > 0 ? closestLang[0] : navigator.language || defaultLocale;
|
|
16
|
-
};
|
|
17
6
|
/**
|
|
18
7
|
* Get Intl object
|
|
19
|
-
* We load the defined locale but for now we only support the first subtag for messages
|
|
20
8
|
*
|
|
21
9
|
* @param {HTMLElement} element element we need to get the language
|
|
22
|
-
* @returns {{ locale: string; messages: unknown }} messages object
|
|
10
|
+
* @returns {{ locale: string; messages: Record<string, unknown> }} messages object
|
|
23
11
|
*/
|
|
24
|
-
|
|
25
|
-
export const initLocales = (element) => {
|
|
26
|
-
// Get local
|
|
27
|
-
const locale = getLocale(element);
|
|
28
|
-
// Only keep first subtag
|
|
29
|
-
const localeSubtag = locale.split('-').shift();
|
|
30
|
-
// Return
|
|
31
|
-
return {
|
|
32
|
-
locale,
|
|
33
|
-
messages: messages[localeSubtag] || messages[defaultLocale],
|
|
34
|
-
};
|
|
35
|
-
};
|
|
12
|
+
export const initLocales = (element) => getLocaleMessages(element, messages, defaultLocale);
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A11Y
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
// Make content available only for screen reader
|
|
6
|
+
// https://gist.github.com/ffoodd/000b59f431e3e64e4ce1a24d5bb36034
|
|
7
|
+
.sr-only {
|
|
8
|
+
border: 0 !important;
|
|
9
|
+
clip: rect(1px, 1px, 1px, 1px) !important;
|
|
10
|
+
-webkit-clip-path: inset(50%) !important;
|
|
11
|
+
clip-path: inset(50%) !important;
|
|
12
|
+
height: 1px !important;
|
|
13
|
+
margin: -1px !important;
|
|
14
|
+
overflow: hidden !important;
|
|
15
|
+
padding: 0 !important;
|
|
16
|
+
position: absolute !important;
|
|
17
|
+
width: 1px !important;
|
|
18
|
+
white-space: nowrap !important;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
// Remove outline for non-keyboard :focus
|
|
22
|
+
// https://www.tpgi.com/focus-visible-and-backwards-compatibility/
|
|
23
|
+
*:focus:not(:focus-visible) {
|
|
24
|
+
outline: none;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
@media (prefers-reduced-motion) {
|
|
28
|
+
.mg-a11y-animation {
|
|
29
|
+
animation: none !important;
|
|
30
|
+
transition: none !important;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Open Sans
|
|
3
|
+
* https://fonts.google.com/specimen/Open+Sans
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
@font-face {
|
|
7
|
+
font-family: 'Open Sans';
|
|
8
|
+
src: url('fonts/OpenSans-Regular.ttf') format('truetype');
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
@font-face {
|
|
12
|
+
font-family: 'Open Sans';
|
|
13
|
+
font-weight: 600;
|
|
14
|
+
src: url('fonts/OpenSans-SemiBold.ttf') format('truetype');
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
@font-face {
|
|
18
|
+
font-family: 'Open Sans';
|
|
19
|
+
font-weight: 700;
|
|
20
|
+
src: url('fonts/OpenSans-Bold.ttf') format('truetype');
|
|
21
|
+
}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Here we building the CSS for the component library
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
// Normalize CSS : https://necolas.github.io/normalize.css/
|
|
6
|
+
@import '~normalize.css/normalize.css';
|
|
7
|
+
|
|
8
|
+
// Fonts
|
|
9
|
+
@import './fonts.scss';
|
|
10
|
+
|
|
11
|
+
// Variables
|
|
12
|
+
@import './variables.css';
|
|
13
|
+
|
|
14
|
+
// Main style
|
|
15
|
+
@import './main.scss';
|
|
16
|
+
|
|
17
|
+
// Typography style
|
|
18
|
+
@import './typography.scss';
|
|
19
|
+
|
|
20
|
+
// Accessibility
|
|
21
|
+
@import './a11y.scss';
|
|
22
|
+
|
|
23
|
+
// Form
|
|
24
|
+
// already included by mg-form
|
|
25
|
+
// @import './form.scss';
|
|
26
|
+
|
|
27
|
+
// Layout
|
|
28
|
+
@import './layout.scss';
|
|
29
|
+
|
|
30
|
+
// Utilities
|
|
31
|
+
@import './utilities.scss';
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Components style
|
|
35
|
+
* molecules
|
|
36
|
+
*/
|
|
37
|
+
|
|
38
|
+
@import './components.scss';
|
|
39
|
+
|
|
40
|
+
/* Atoms */
|
|
41
|
+
|
|
42
|
+
// <mg-badge>
|
|
43
|
+
@import '../components/atoms/mg-badge/mg-badge.scss';
|
|
44
|
+
|
|
45
|
+
// <mg-button>
|
|
46
|
+
@import '../components/atoms/mg-button/mg-button.scss';
|
|
47
|
+
|
|
48
|
+
// <mg-character-left>
|
|
49
|
+
@import '../components/atoms/mg-character-left/mg-character-left.scss';
|
|
50
|
+
|
|
51
|
+
// <mg-icon>
|
|
52
|
+
@import '../components/atoms/mg-icon/mg-icon.scss';
|
|
53
|
+
|
|
54
|
+
// <mg-input-title>
|
|
55
|
+
//! For now input style will not be included
|
|
56
|
+
// @import '../components/atoms/mg-input-title/mg-input-title.scss';
|
|
57
|
+
|
|
58
|
+
// <mg-tag>
|
|
59
|
+
@import '../components/atoms/mg-tag/mg-tag.scss';
|
|
60
|
+
|
|
61
|
+
// <mg-tooltip>
|
|
62
|
+
@import '../components/atoms/mg-tooltip/mg-tooltip.scss';
|
|
63
|
+
|
|
64
|
+
/* Molecules */
|
|
65
|
+
|
|
66
|
+
// <mg-input-...>
|
|
67
|
+
//! For now input style will not be included
|
|
68
|
+
// @import '../components/molecules/inputs/styles/mg-input.scss';
|
|
69
|
+
// @import '../components/molecules/inputs/styles/mg-input-box.scss';
|
|
70
|
+
// @import '../components/molecules/inputs/styles/mg-input-charleft.scss';
|
|
71
|
+
// @import '../components/molecules/inputs/styles/mg-input-fieldset.scss';
|
|
72
|
+
// @import '../components/molecules/inputs/styles/mg-input-width.scss';
|
|
73
|
+
|
|
74
|
+
// <mg-form>
|
|
75
|
+
@import '../components/molecules/mg-form/mg-form.scss';
|
|
76
|
+
|
|
77
|
+
// <mg-message>
|
|
78
|
+
@import '../components/molecules/mg-message/mg-message.scss';
|
|
79
|
+
|
|
80
|
+
// <mg-pagination>
|
|
81
|
+
@import '../components/molecules/mg-pagination/mg-pagination.scss';
|
|
82
|
+
|
|
83
|
+
// <mg-popover>
|
|
84
|
+
@import '../components/molecules/mg-popover/mg-popover.scss';
|
|
85
|
+
|
|
86
|
+
// <mg-tabs>
|
|
87
|
+
@import '../components/molecules/mg-tabs/mg-tabs.scss';
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
@use 'sass:math';
|
|
2
|
+
|
|
3
|
+
// Number of column
|
|
4
|
+
$grid-columns: 12;
|
|
5
|
+
|
|
6
|
+
// Calculate width
|
|
7
|
+
@function round-width($i) {
|
|
8
|
+
$width: math.div(100 * $i, $grid-columns);
|
|
9
|
+
@return #{$width}#{'%'};
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
.mg-grid {
|
|
13
|
+
display: flex;
|
|
14
|
+
flex-wrap: wrap;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
// Those columns will equaly share space
|
|
18
|
+
.mg-grid__col {
|
|
19
|
+
flex: 1 0 0;
|
|
20
|
+
padding: 0 var(--mg-grid-spacing);
|
|
21
|
+
|
|
22
|
+
// Building columns
|
|
23
|
+
@for $i from 1 through $grid-columns {
|
|
24
|
+
&.mg-grid__col-#{$i} {
|
|
25
|
+
flex: 0 0 auto;
|
|
26
|
+
width: round-width($i);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
// Make all element use the border box model
|
|
2
|
+
*,
|
|
3
|
+
*::before,
|
|
4
|
+
*::after {
|
|
5
|
+
box-sizing: border-box;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* We set html font size to 62.5% to get 10px in most of the case.
|
|
10
|
+
* This is a common use for an easiest calculation : 1rem = 10px
|
|
11
|
+
* Default font size will be defined in body element.
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
html {
|
|
15
|
+
font-size: 62.5%;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
body {
|
|
19
|
+
font-size: var(--font-size);
|
|
20
|
+
font-family: var(--font-family);
|
|
21
|
+
line-height: var(--line-height);
|
|
22
|
+
-webkit-font-smoothing: antialiased;
|
|
23
|
+
}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
@use 'sass:map';
|
|
2
|
+
|
|
3
|
+
$border-bottom-size: 0.3rem;
|
|
4
|
+
$font-size-large: calc(var(--font-size) + 0.2rem);
|
|
5
|
+
$navigation-button-column-gap: 1rem;
|
|
6
|
+
|
|
7
|
+
@mixin navigation-button($element, $button-sizes) {
|
|
8
|
+
@each $name, $size in $button-sizes {
|
|
9
|
+
.#{$element}.#{$element}--size-#{$name} .#{$element}__navigation-button,
|
|
10
|
+
.#{$element}__navigation-button.#{$element}__navigation-button--size-#{$name} {
|
|
11
|
+
padding: #{map.get($size, 'vertical')} #{map.get($size, 'horizontal')};
|
|
12
|
+
height: calc(#{map.get($size, 'height')});
|
|
13
|
+
&,
|
|
14
|
+
::slotted([slot='label']),
|
|
15
|
+
::slotted([slot='metadata']) {
|
|
16
|
+
@if $name == 'regular' {
|
|
17
|
+
font-size: var(--font-size);
|
|
18
|
+
} @else {
|
|
19
|
+
font-size: $font-size-large;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
&.#{$element}__navigation-button--horizontal {
|
|
23
|
+
padding-bottom: calc(#{map.get($size, 'vertical')} - #{$border-bottom-size});
|
|
24
|
+
}
|
|
25
|
+
&.#{$element}__navigation-button--vertical {
|
|
26
|
+
padding-left: calc(#{map.get($size, 'horizontal')} - #{$border-bottom-size});
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
.#{$element}__navigation-button {
|
|
32
|
+
display: flex;
|
|
33
|
+
align-items: center;
|
|
34
|
+
column-gap: var(--#{$element}-navigation-button-column-gap, $navigation-button-column-gap);
|
|
35
|
+
background-color: unset;
|
|
36
|
+
border: none;
|
|
37
|
+
font-family: var(--font-family);
|
|
38
|
+
font-weight: 400;
|
|
39
|
+
color: hsl(var(--#{$element}-color-hsl, var(--color-dark)));
|
|
40
|
+
line-height: var(--line-height);
|
|
41
|
+
text-decoration: none;
|
|
42
|
+
white-space: nowrap;
|
|
43
|
+
box-sizing: border-box;
|
|
44
|
+
cursor: pointer;
|
|
45
|
+
&:disabled,
|
|
46
|
+
&--disabled {
|
|
47
|
+
cursor: default;
|
|
48
|
+
opacity: var(--mg-disabled-opacity);
|
|
49
|
+
}
|
|
50
|
+
&:focus-visible {
|
|
51
|
+
z-index: 10;
|
|
52
|
+
}
|
|
53
|
+
&:hover:not(.#{$element}__navigation-button--disabled),
|
|
54
|
+
&:focus-visible:not(.#{$element}__navigation-button--disabled) {
|
|
55
|
+
background-color: hsl(var(--#{$element}-focused-background-color-hsl), 0.1);
|
|
56
|
+
}
|
|
57
|
+
&.#{$element}__navigation-button--active {
|
|
58
|
+
color: hsl(var(--#{$element}-color-active-hsl));
|
|
59
|
+
font-weight: 600;
|
|
60
|
+
&.#{$element}__navigation-button--horizontal {
|
|
61
|
+
border-bottom-color: hsl(var(--#{$element}-border-color-active-hsl));
|
|
62
|
+
}
|
|
63
|
+
&.#{$element}__navigation-button--vertical {
|
|
64
|
+
border-left-color: hsl(var(--#{$element}-border-color-active-hsl));
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
&.#{$element}__navigation-button--hidden {
|
|
68
|
+
display: none;
|
|
69
|
+
}
|
|
70
|
+
&.#{$element}__navigation-button--horizontal {
|
|
71
|
+
border-bottom: $border-bottom-size solid transparent;
|
|
72
|
+
}
|
|
73
|
+
&.#{$element}__navigation-button--vertical {
|
|
74
|
+
border-left: $border-bottom-size solid transparent;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
@mixin reset-slot-card-variables() {
|
|
2
|
+
::slotted(*) {
|
|
3
|
+
--mg-card-border: var(--mg-card-border-default);
|
|
4
|
+
--mg-card-padding: var(--mg-card-padding-default);
|
|
5
|
+
--mg-card-border-radius: var(--mg-card-border-radius-default);
|
|
6
|
+
--mg-card-background: var(--mg-card-background-default);
|
|
7
|
+
--mg-card-box-shadow: var(--mg-card-box-shadow-default);
|
|
8
|
+
}
|
|
9
|
+
}
|