@pnx-mixtape/mxds 0.0.13 → 0.0.15
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/README.md +37 -23
- package/dist/build/accordion.css +1 -98
- package/dist/build/accordion.entry.js +1 -83
- package/dist/build/base.css +1 -996
- package/dist/build/breadcrumb.css +1 -51
- package/dist/build/button.css +1 -132
- package/dist/build/callout.css +1 -11
- package/dist/build/card.css +1 -149
- package/dist/build/carousel.css +1 -0
- package/dist/build/chunks/Accordion-RtUfbsTy.js +1 -0
- package/dist/build/chunks/disclosure-widget-CPdkUWkq.js +1 -0
- package/dist/build/chunks/drop-menu.entry-BqBzLfVC.js +1 -0
- package/dist/build/chunks/keyboard-Cs0cduxq.js +1 -0
- package/dist/build/chunks/polyfills-5KNOJw2W.js +1 -0
- package/dist/build/chunks/popover-CiVl-0jk.js +1 -0
- package/dist/build/chunks/utilities-CE6xwgqF.js +2 -0
- package/dist/build/constants.css +1 -120
- package/dist/build/container-grid.css +1 -208
- package/dist/build/content-block.css +1 -36
- package/dist/build/dialog.css +1 -98
- package/dist/build/dialog.entry.js +1 -113
- package/dist/build/drop-menu.css +1 -78
- package/dist/build/drop-menu.entry.js +1 -2
- package/dist/build/drupal.css +1 -74
- package/dist/build/filters.css +1 -105
- package/dist/build/filters.entry.js +1 -137
- package/dist/build/footer.css +1 -151
- package/dist/build/form.css +1 -517
- package/dist/build/global-alert.css +1 -60
- package/dist/build/global-alert.entry.js +1 -68
- package/dist/build/grid.css +1 -200
- package/dist/build/header.css +1 -153
- package/dist/build/header.entry.js +1 -103
- package/dist/build/hero-banner.css +1 -62
- package/dist/build/icon.css +1 -399
- package/dist/build/in-page-alert.css +1 -94
- package/dist/build/in-page-navigation.css +1 -17
- package/dist/build/in-page-navigation.entry.js +1 -99
- package/dist/build/link-list.css +1 -45
- package/dist/build/list-item.css +1 -114
- package/dist/build/masthead.css +1 -53
- package/dist/build/navigation.css +1 -396
- package/dist/build/navigation.entry.js +1 -124
- package/dist/build/page.css +1 -80
- package/dist/build/pagination.css +1 -130
- package/dist/build/results-bar.css +1 -0
- package/dist/build/section.css +1 -163
- package/dist/build/side-navigation.css +1 -88
- package/dist/build/sidebar.css +1 -59
- package/dist/build/social-links.css +1 -20
- package/dist/build/steps.css +1 -118
- package/dist/build/sticky.css +1 -47
- package/dist/build/sticky.entry.js +1 -60
- package/dist/build/tabs.css +1 -109
- package/dist/build/tabs.entry.js +1 -202
- package/dist/build/tag.css +1 -71
- package/dist/build/utilities.css +1 -178
- package/package.json +56 -64
- package/src/Atom/Background/Backgrounds.stories.ts +13 -1
- package/src/Atom/Background/__snapshots__/Backgrounds.stories.ts.snap +157 -81
- package/src/Atom/Background/_background.css +16 -10
- package/src/Atom/Base.mdx +25 -17
- package/src/Atom/Button/Button.stories.ts +1 -4
- package/src/Atom/Button/Button.stories.tsx +1 -1
- package/src/Atom/Button/__snapshots__/Button.stories.ts.snap +47 -37
- package/src/Atom/Button/_buttons-styles.css +7 -7
- package/src/Atom/Button/_buttons.css +1 -6
- package/src/Atom/DefinitionList/DefinitionList.stories.ts +32 -0
- package/src/Atom/DefinitionList/DefinitionList.stories.tsx +1 -1
- package/src/Atom/DefinitionList/__snapshots__/DefinitionList.stories.ts.snap +32 -0
- package/src/Atom/DefinitionList/definition-list.twig +9 -0
- package/src/Atom/Heading/Heading.stories.ts +1 -1
- package/src/Atom/Heading/Heading.stories.tsx +1 -1
- package/src/Atom/Heading/__snapshots__/Heading.stories.ts.snap +5 -3
- package/src/Atom/Heading/_headings.css +24 -24
- package/src/Atom/Icon/Icon.mdx +1 -1
- package/src/Atom/Icon/Icon.stories.ts +1 -1
- package/src/Atom/Icon/Icon.stories.tsx +1 -1
- package/src/Atom/Icon/Icon.tsx +2 -2
- package/src/Atom/Icon/__snapshots__/Icon.stories.ts.snap +14 -8
- package/src/Atom/Icon/_icon.css +4 -4
- package/src/Atom/Image/Image.stories.ts +1 -1
- package/src/Atom/Image/__snapshots__/Image.stories.ts.snap +7 -5
- package/src/Atom/Image/_image.css +2 -7
- package/src/Atom/Link/Link.stories.ts +1 -1
- package/src/Atom/Link/Link.stories.tsx +1 -1
- package/src/Atom/Link/__snapshots__/Link.stories.ts.snap +50 -37
- package/src/Atom/Link/_links.css +2 -22
- package/src/Atom/Link/link.twig +1 -0
- package/src/Atom/Media/Media.stories.ts +2 -1
- package/src/Atom/Media/Media.stories.tsx +1 -1
- package/src/Atom/Media/__snapshots__/Media.stories.ts.snap +11 -24
- package/src/Atom/Media/_media.css +8 -8
- package/src/Atom/Spacing/Spacing.stories.ts +1 -1
- package/src/Atom/Spacing/__snapshots__/Spacing.stories.ts.snap +5 -3
- package/src/Atom/Table/Table.stories.ts +1 -1
- package/src/Atom/Table/TableResponsive.stories.ts +1 -1
- package/src/Atom/Table/__snapshots__/Table.stories.ts.snap +256 -248
- package/src/Atom/Table/__snapshots__/TableResponsive.stories.ts.snap +65 -63
- package/src/Atom/Text/Text.stories.tsx +1 -1
- package/src/Atom/Text/TextSizes.stories.ts +1 -1
- package/src/Atom/Text/__snapshots__/TextSizes.stories.ts.snap +59 -55
- package/src/Atom/Text/_text-sizes.css +17 -17
- package/src/Atom/Text/rich-text.twig +9 -0
- package/src/Atom/Video/Video.stories.ts +1 -1
- package/src/Atom/Video/__snapshots__/Video.stories.ts.snap +9 -7
- package/src/Atom/_animated.css +0 -14
- package/src/Atom/_generic.css +57 -15
- package/src/Atom/base.css +1 -1
- package/src/Component/Accordion/Accordion.stories.ts +1 -4
- package/src/Component/Accordion/Accordion.stories.tsx +1 -2
- package/src/Component/Accordion/__snapshots__/Accordion.stories.ts.snap +60 -56
- package/src/Component/Accordion/__snapshots__/Accordion.stories.tsx.snap +0 -1
- package/src/Component/Accordion/accordion.css +16 -4
- package/src/Component/Breadcrumb/Breadcrumb.stories.ts +1 -1
- package/src/Component/Breadcrumb/Breadcrumb.stories.tsx +1 -1
- package/src/Component/Breadcrumb/__snapshots__/Breadcrumb.stories.ts.snap +31 -29
- package/src/Component/Breadcrumb/breadcrumb.css +4 -0
- package/src/Component/Callout/Callout.stories.ts +1 -9
- package/src/Component/Callout/__snapshots__/Callout.stories.ts.snap +9 -7
- package/src/Component/Card/Card.stories.ts +11 -18
- package/src/Component/Card/Card.stories.tsx +1 -1
- package/src/Component/Card/Card.tsx +9 -5
- package/src/Component/Card/__snapshots__/Card.stories.ts.snap +257 -229
- package/src/Component/Card/card.css +36 -33
- package/src/Component/Card/card.twig +6 -6
- package/src/Component/Carousel/Carousel.stories.ts +201 -0
- package/src/Component/Carousel/Elements/Carousel.ts +241 -0
- package/src/Component/Carousel/__snapshots__/Carousel.stories.ts.snap +912 -0
- package/src/Component/Carousel/carousel.css +119 -0
- package/src/Component/Carousel/carousel.twig +27 -0
- package/src/Component/ContentBlock/ContentBlock.stories.ts +27 -19
- package/src/Component/ContentBlock/ContentBlock.stories.tsx +1 -1
- package/src/Component/ContentBlock/__snapshots__/ContentBlock.stories.ts.snap +153 -93
- package/src/Component/Dialog/Dialog.stories.ts +75 -7
- package/src/Component/Dialog/Dialog.stories.tsx +1 -1
- package/src/Component/Dialog/Elements/Dialog.ts +14 -34
- package/src/Component/Dialog/__snapshots__/Dialog.stories.ts.snap +102 -66
- package/src/Component/Dialog/dialog.css +32 -20
- package/src/Component/Dialog/dialog.twig +14 -15
- package/src/Component/DropMenu/Components/DropMenuContext.tsx +7 -9
- package/src/Component/DropMenu/Components/DropMenuItem.tsx +1 -1
- package/src/Component/DropMenu/DropMenu.stories.ts +1 -1
- package/src/Component/DropMenu/DropMenu.stories.tsx +1 -1
- package/src/Component/DropMenu/Elements/DropMenu.ts +1 -1
- package/src/Component/DropMenu/__snapshots__/DropMenu.stories.ts.snap +28 -26
- package/src/Component/DropMenu/drop-menu.css +11 -3
- package/src/Component/Filters/Filters.stories.ts +1 -4
- package/src/Component/Filters/__snapshots__/Filters.stories.ts.snap +397 -389
- package/src/Component/Filters/filters.css +14 -5
- package/src/Component/GlobalAlert/GlobalAlert.stories.ts +1 -1
- package/src/Component/GlobalAlert/GlobalAlert.stories.tsx +1 -1
- package/src/Component/GlobalAlert/__snapshots__/GlobalAlert.stories.ts.snap +33 -29
- package/src/Component/GlobalAlert/__snapshots__/GlobalAlert.stories.tsx.snap +2 -2
- package/src/Component/GlobalAlert/global-alert.css +2 -2
- package/src/Component/HeroBanner/HeroBanner.stories.ts +1 -4
- package/src/Component/HeroBanner/HeroBanner.stories.tsx +1 -1
- package/src/Component/HeroBanner/__snapshots__/HeroBanner.stories.ts.snap +68 -64
- package/src/Component/HeroBanner/hero-banner.css +6 -1
- package/src/Component/HeroBanner/hero-banner.twig +3 -4
- package/src/Component/InPageAlert/InPageAlert.stories.ts +1 -1
- package/src/Component/InPageAlert/InPageAlert.stories.tsx +1 -1
- package/src/Component/InPageAlert/__snapshots__/InPageAlert.stories.ts.snap +10 -8
- package/src/Component/InPageAlert/in-page-alert.css +8 -8
- package/src/Component/InPageNavigation/Elements/InPageNavigation.ts +1 -1
- package/src/Component/InPageNavigation/InPageNavigation.stories.ts +1 -4
- package/src/Component/InPageNavigation/InPageNavigation.stories.tsx +1 -1
- package/src/Component/InPageNavigation/__snapshots__/InPageNavigation.stories.ts.snap +64 -62
- package/src/Component/LinkList/LinkList.stories.ts +1 -1
- package/src/Component/LinkList/LinkList.stories.tsx +1 -1
- package/src/Component/LinkList/__snapshots__/LinkList.stories.ts.snap +31 -29
- package/src/Component/ListItem/ListItem.stories.ts +2 -4
- package/src/Component/ListItem/ListItem.stories.tsx +1 -1
- package/src/Component/ListItem/__snapshots__/ListItem.stories.ts.snap +162 -148
- package/src/Component/ListItem/list-item.css +7 -88
- package/src/Component/ListItem/list-item.twig +8 -8
- package/src/Component/Navigation/Dropdown.stories.tsx +1 -1
- package/src/Component/Navigation/Navigation.stories.ts +1 -1
- package/src/Component/Navigation/Navigation.stories.tsx +1 -1
- package/src/Component/Navigation/__snapshots__/Navigation.stories.ts.snap +291 -283
- package/src/Component/Navigation/_navigation-collapsible.css +11 -14
- package/src/Component/Navigation/_navigation-dropdown.css +11 -17
- package/src/Component/Pagination/Components/PaginationContext.tsx +4 -8
- package/src/Component/Pagination/Pagination.stories.ts +1 -1
- package/src/Component/Pagination/Pagination.stories.tsx +1 -1
- package/src/Component/Pagination/__snapshots__/Pagination.stories.ts.snap +59 -57
- package/src/Component/Pagination/pagination.css +2 -8
- package/src/Component/ResultsBar/Components/ResultsBarInfo.tsx +28 -0
- package/src/Component/ResultsBar/Components/ResultsBarSort.tsx +17 -0
- package/src/Component/ResultsBar/ResultsBar.stories.ts +37 -0
- package/src/Component/ResultsBar/ResultsBar.stories.tsx +50 -0
- package/src/Component/ResultsBar/ResultsBar.tsx +7 -0
- package/src/Component/ResultsBar/__snapshots__/ResultsBar.stories.ts.snap +54 -0
- package/src/Component/ResultsBar/__snapshots__/ResultsBar.stories.tsx.snap +53 -0
- package/src/Component/ResultsBar/results-bar.css +19 -0
- package/src/Component/ResultsBar/results-bar.twig +24 -0
- package/src/Component/SideNavigation/SideNavigation.stories.ts +1 -1
- package/src/Component/SideNavigation/__snapshots__/SideNavigation.stories.ts.snap +82 -80
- package/src/Component/SideNavigation/side-navigation.css +2 -8
- package/src/Component/SocialLinks/SocialLinks.stories.ts +1 -1
- package/src/Component/SocialLinks/__snapshots__/SocialLinks.stories.ts.snap +30 -28
- package/src/Component/Steps/Steps.stories.ts +1 -1
- package/src/Component/Steps/__snapshots__/Steps.stories.ts.snap +86 -78
- package/src/Component/Steps/steps.css +1 -1
- package/src/Component/Sticky/Sticky.stories.ts +1 -1
- package/src/Component/Sticky/Sticky.stories.tsx +1 -1
- package/src/Component/Sticky/__snapshots__/Sticky.stories.ts.snap +9 -7
- package/src/Component/Tabs/Tabs.stories.ts +1 -1
- package/src/Component/Tabs/Tabs.stories.tsx +1 -1
- package/src/Component/Tabs/Tabs.tsx +4 -4
- package/src/Component/Tabs/__snapshots__/Tabs.stories.ts.snap +73 -71
- package/src/Component/Tabs/__snapshots__/Tabs.stories.tsx.snap +0 -2
- package/src/Component/Tabs/tabs.css +14 -21
- package/src/Component/Tag/Tag.stories.ts +1 -1
- package/src/Component/Tag/Tag.stories.tsx +1 -1
- package/src/Component/Tag/__snapshots__/Tag.stories.ts.snap +59 -53
- package/src/Component/Tag/tag.css +6 -6
- package/src/Component/Tile/Tile.stories.ts +38 -12
- package/src/Component/Tile/Tile.stories.tsx +2 -2
- package/src/Component/Tile/Tile.tsx +30 -17
- package/src/Component/Tile/__snapshots__/Tile.stories.ts.snap +49 -75
- package/src/Component/Tile/__snapshots__/Tile.stories.tsx.snap +6 -16
- package/src/Form/Checkbox/Checkbox.stories.ts +1 -1
- package/src/Form/Checkbox/FormCheckbox.stories.tsx +1 -1
- package/src/Form/Checkbox/FormCheckbox.tsx +5 -7
- package/src/Form/Checkbox/__snapshots__/Checkbox.stories.ts.snap +23 -19
- package/src/Form/Description/Description.stories.ts +1 -1
- package/src/Form/Description/FormDescription.stories.tsx +1 -1
- package/src/Form/Description/FormStatus.stories.ts +1 -1
- package/src/Form/Description/__snapshots__/Description.stories.ts.snap +7 -5
- package/src/Form/Description/__snapshots__/FormStatus.stories.ts.snap +14 -10
- package/src/Form/Form/Form.stories.tsx +1 -1
- package/src/Form/Form/FormTitle.stories.tsx +1 -1
- package/src/Form/FormItem/FormItem.stories.ts +1 -4
- package/src/Form/FormItem/FormItem.stories.tsx +1 -1
- package/src/Form/FormItem/__snapshots__/FormItem.stories.ts.snap +119 -109
- package/src/Form/FormItem/__snapshots__/FormItem.stories.tsx.snap +4 -4
- package/src/Form/Label/FormLabel.stories.tsx +1 -1
- package/src/Form/Label/FormLabel.tsx +1 -1
- package/src/Form/Label/Label.stories.ts +1 -1
- package/src/Form/Label/__snapshots__/Label.stories.ts.snap +21 -15
- package/src/Form/Radio/FormRadio.stories.tsx +1 -1
- package/src/Form/Radio/FormRadio.tsx +4 -4
- package/src/Form/Radio/Radio.stories.ts +1 -1
- package/src/Form/Radio/__snapshots__/Radio.stories.ts.snap +55 -51
- package/src/Form/Search/Search.stories.ts +1 -4
- package/src/Form/Search/__snapshots__/Search.stories.ts.snap +23 -21
- package/src/Form/Select/FormSelect.stories.tsx +1 -1
- package/src/Form/Select/FormSelect.tsx +1 -1
- package/src/Form/Select/Select.stories.ts +1 -1
- package/src/Form/Select/__snapshots__/Select.stories.ts.snap +18 -16
- package/src/Form/TextInput/FormText.stories.tsx +1 -1
- package/src/Form/TextInput/InputDivider.stories.ts +1 -1
- package/src/Form/TextInput/TextInput.stories.ts +1 -1
- package/src/Form/TextInput/__snapshots__/FormText.stories.tsx.snap +1 -1
- package/src/Form/TextInput/__snapshots__/InputDivider.stories.ts.snap +24 -22
- package/src/Form/TextInput/__snapshots__/TextInput.stories.ts.snap +18 -14
- package/src/Form/Textarea/FormTextarea.stories.tsx +1 -1
- package/src/Form/Textarea/Textarea.stories.ts +1 -1
- package/src/Form/Textarea/__snapshots__/FormTextarea.stories.tsx.snap +1 -1
- package/src/Form/Textarea/__snapshots__/Textarea.stories.ts.snap +9 -7
- package/src/Form/form.css +24 -34
- package/src/Introduction.mdx +40 -0
- package/src/Layout/Footer/Footer.stories.ts +1 -6
- package/src/Layout/Footer/Footer.stories.tsx +1 -1
- package/src/Layout/Footer/__snapshots__/Footer.stories.ts.snap +10 -10
- package/src/Layout/Footer/footer.css +2 -6
- package/src/Layout/Footer/footer.twig +0 -1
- package/src/Layout/Grid/Grid.stories.ts +8 -8
- package/src/Layout/Grid/Grid.stories.tsx +2 -2
- package/src/Layout/Grid/__snapshots__/Grid.stories.ts.snap +38 -32
- package/src/Layout/Grid/container-grid.css +10 -10
- package/src/Layout/Grid/grid-item.twig +3 -1
- package/src/Layout/Grid/grid.css +3 -3
- package/src/Layout/Header/Header.stories.ts +1 -6
- package/src/Layout/Header/Header.stories.tsx +1 -1
- package/src/Layout/Header/__snapshots__/Header.stories.ts.snap +11 -11
- package/src/Layout/Header/__snapshots__/Header.stories.tsx.snap +3 -3
- package/src/Layout/Header/_header.css +18 -16
- package/src/Layout/Header/header.twig +1 -2
- package/src/Layout/Masthead/Masthead.stories.ts +1 -3
- package/src/Layout/Masthead/__snapshots__/Masthead.stories.ts.snap +6 -6
- package/src/Layout/Masthead/masthead.twig +0 -2
- package/src/Layout/Page/Page.stories.tsx +1 -1
- package/src/Layout/Page/__snapshots__/Page.stories.tsx.snap +3 -3
- package/src/Layout/Page/page.css +16 -40
- package/src/Layout/Page/page.twig +6 -1
- package/src/Layout/Section/Background.stories.ts +60 -8
- package/src/Layout/Section/Breakouts.stories.ts +1 -3
- package/src/Layout/Section/Flow.stories.ts +1 -3
- package/src/Layout/Section/Section.stories.ts +1 -6
- package/src/Layout/Section/Section.stories.tsx +1 -1
- package/src/Layout/Section/SectionGrid.stories.tsx +1 -1
- package/src/Layout/Section/__snapshots__/Background.stories.ts.snap +36 -24
- package/src/Layout/Section/__snapshots__/Breakouts.stories.ts.snap +54 -52
- package/src/Layout/Section/__snapshots__/Flow.stories.ts.snap +18 -18
- package/src/Layout/Section/__snapshots__/Section.stories.ts.snap +2 -2
- package/src/Layout/Section/section.css +15 -18
- package/src/Layout/Section/section.twig +0 -1
- package/src/Layout/Section/twig/section-background.twig +29 -10
- package/src/Layout/Section/twig/sections-breakout.twig +28 -33
- package/src/Layout/Section/twig/sections-flow.twig +17 -17
- package/src/Layout/Section/twig/sections-stacked.twig +4 -4
- package/src/Layout/Sidebar/Sidebar.stories.ts +1 -3
- package/src/Layout/Sidebar/Sidebar.stories.tsx +1 -1
- package/src/Layout/Sidebar/__snapshots__/Sidebar.stories.ts.snap +5 -5
- package/src/Layout/Sidebar/sidebar.css +2 -18
- package/src/Utility/Context/ImageComponent.tsx +3 -6
- package/src/Utility/Context/LinkComponent.tsx +3 -6
- package/src/Utility/Drupal/drupal.css +1 -5
- package/src/Utility/Elements/breakpoint-loader.ts +0 -1
- package/src/Utility/Elements/cookie-compliance.ts +0 -1
- package/src/Utility/Elements/io-loader.ts +0 -1
- package/src/Utility/Hooks/useLocalStorage.ts +0 -1
- package/src/Utility/Hooks/useMediaQuery.ts +0 -1
- package/src/Utility/Hooks/useToggle.ts +0 -1
- package/src/Utility/global.d.ts +0 -1
- package/src/Utility/utilities.ts +0 -1
- package/src/constants.css +53 -24
- package/src/enums.ts +1 -2
- package/src/react.ts +3 -0
- package/src/tokens.js +19 -19
- package/dist/build/accordion.entry.js.map +0 -1
- package/dist/build/chunks/Accordion-DSze7pxN.js +0 -61
- package/dist/build/chunks/Accordion-DSze7pxN.js.map +0 -1
- package/dist/build/chunks/disclosure-widget-CQLPJ8Ta.js +0 -124
- package/dist/build/chunks/disclosure-widget-CQLPJ8Ta.js.map +0 -1
- package/dist/build/chunks/drop-menu.entry-BC6x9vst.js +0 -132
- package/dist/build/chunks/drop-menu.entry-BC6x9vst.js.map +0 -1
- package/dist/build/chunks/keyboard-C73DHu0c.js +0 -101
- package/dist/build/chunks/keyboard-C73DHu0c.js.map +0 -1
- package/dist/build/chunks/polyfills-CJ5uTmUJ.js +0 -749
- package/dist/build/chunks/polyfills-CJ5uTmUJ.js.map +0 -1
- package/dist/build/chunks/popover-wbPSyFRj.js +0 -654
- package/dist/build/chunks/popover-wbPSyFRj.js.map +0 -1
- package/dist/build/chunks/utilities-B4YZb689.js +0 -243
- package/dist/build/chunks/utilities-B4YZb689.js.map +0 -1
- package/dist/build/dialog.entry.js.map +0 -1
- package/dist/build/drop-menu.entry.js.map +0 -1
- package/dist/build/filters.entry.js.map +0 -1
- package/dist/build/global-alert.entry.js.map +0 -1
- package/dist/build/header.entry.js.map +0 -1
- package/dist/build/in-page-navigation.entry.js.map +0 -1
- package/dist/build/navigation.entry.js.map +0 -1
- package/dist/build/sticky.entry.js.map +0 -1
- package/dist/build/tabs.entry.js.map +0 -1
- package/dist/build/tiles.css +0 -61
- package/src/Component/Tile/tile.twig +0 -10
- package/src/Component/Tile/tiles.css +0 -58
- package/src/Component/Tile/twig/tiles.twig +0 -18
|
@@ -4,19 +4,33 @@
|
|
|
4
4
|
|
|
5
5
|
@layer design-system.components {
|
|
6
6
|
.mx-card {
|
|
7
|
+
block-size: 100%;
|
|
7
8
|
display: grid;
|
|
8
9
|
gap: var(--card-gap, var(--gap));
|
|
9
10
|
|
|
10
11
|
&[class*="mx-background--"] {
|
|
11
12
|
border-radius: var(--border-radius);
|
|
12
13
|
|
|
14
|
+
@container (min-width: token("breakpoint.contentCard")) {
|
|
15
|
+
--content-min-spacing: var(--content-max-spacing, var(--spacing-m));
|
|
16
|
+
}
|
|
17
|
+
|
|
13
18
|
& .mx-card__content {
|
|
14
19
|
padding-inline: var(--content-min-spacing, var(--spacing-s));
|
|
15
20
|
padding-block-end: var(--content-min-spacing, var(--spacing-s));
|
|
21
|
+
}
|
|
16
22
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
23
|
+
&:not(:has(.mx-card__media, .mx-card__icon)) .mx-card__content {
|
|
24
|
+
padding-block-start: var(--content-min-spacing, var(--spacing-s));
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
& .mx-card__icon {
|
|
28
|
+
padding-inline: var(--content-min-spacing, var(--spacing-s));
|
|
29
|
+
padding-block-start: var(--content-min-spacing, var(--spacing-s));
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
&.mx-background--box {
|
|
33
|
+
padding-inline: unset;
|
|
20
34
|
}
|
|
21
35
|
}
|
|
22
36
|
|
|
@@ -26,20 +40,19 @@
|
|
|
26
40
|
@container (min-width: token("breakpoint.contentCard")) {
|
|
27
41
|
--card-gap: var(--gap-l);
|
|
28
42
|
|
|
29
|
-
grid-template: "media content" 1fr / 1fr
|
|
30
|
-
|
|
43
|
+
grid-template: "media content" 1fr / var(--media-col, 1fr) var(
|
|
44
|
+
--content-col,
|
|
45
|
+
1fr
|
|
46
|
+
);
|
|
31
47
|
|
|
32
48
|
&.mx-card--reversed {
|
|
33
49
|
grid-template-areas: "content media";
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
& .mx-card__content {
|
|
37
|
-
justify-content: center;
|
|
50
|
+
grid-template-columns: var(--content-col, 1fr) var(--media-col, 1fr);
|
|
38
51
|
}
|
|
39
52
|
}
|
|
40
53
|
|
|
41
54
|
@container (min-width: token("breakpoint.l")) {
|
|
42
|
-
--card-gap: 6rem;
|
|
55
|
+
--card-gap: var(--large-card-gap, 6rem);
|
|
43
56
|
}
|
|
44
57
|
|
|
45
58
|
&[class*="mx-background--"] {
|
|
@@ -60,25 +73,24 @@
|
|
|
60
73
|
|
|
61
74
|
& .mx-card__content {
|
|
62
75
|
grid-area: content;
|
|
76
|
+
align-self: var(--align-content, center);
|
|
63
77
|
}
|
|
64
78
|
|
|
65
|
-
&
|
|
79
|
+
& .mx-card__media {
|
|
66
80
|
grid-area: media;
|
|
67
|
-
|
|
68
|
-
margin: auto;
|
|
69
|
-
position: relative;
|
|
81
|
+
align-self: var(--align-media, center);
|
|
70
82
|
inline-size: 100%;
|
|
71
83
|
|
|
72
84
|
& img {
|
|
73
85
|
aspect-ratio: var(--ratio);
|
|
74
86
|
border-radius: var(--border-radius);
|
|
75
87
|
object-fit: cover;
|
|
76
|
-
|
|
88
|
+
inline-size: 100%;
|
|
77
89
|
}
|
|
90
|
+
}
|
|
78
91
|
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
}
|
|
92
|
+
& .mx-skeleton--bg {
|
|
93
|
+
grid-area: media;
|
|
82
94
|
}
|
|
83
95
|
|
|
84
96
|
& .mx-card__icon {
|
|
@@ -90,6 +102,10 @@
|
|
|
90
102
|
inline-size: 100%;
|
|
91
103
|
}
|
|
92
104
|
}
|
|
105
|
+
|
|
106
|
+
.mx-card__content > a:last-child {
|
|
107
|
+
margin-block-start: auto;
|
|
108
|
+
}
|
|
93
109
|
}
|
|
94
110
|
|
|
95
111
|
/**
|
|
@@ -99,8 +115,7 @@
|
|
|
99
115
|
@layer design-system.components {
|
|
100
116
|
.mx-grid:has(> *:nth-child(2):last-child)
|
|
101
117
|
> :is(.mx-card, .mx-container:has(.mx-card)) {
|
|
102
|
-
inline-size: 100
|
|
103
|
-
max-inline-size: var(--max-card-width, 37ch);
|
|
118
|
+
inline-size: min(100%, var(--max-card-width, 37ch));
|
|
104
119
|
margin-inline: auto;
|
|
105
120
|
}
|
|
106
121
|
}
|
|
@@ -119,19 +134,7 @@
|
|
|
119
134
|
.mx-card--block {
|
|
120
135
|
position: relative;
|
|
121
136
|
|
|
122
|
-
|
|
123
|
-
border-radius: var(--border-radius);
|
|
124
|
-
outline: var(--outline-width) var(--outline-style) var(--outline-color);
|
|
125
|
-
outline-offset: 2px;
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
& :is(a[href], button) {
|
|
129
|
-
&:focus-visible {
|
|
130
|
-
outline: none;
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
& a::after {
|
|
137
|
+
& a::before {
|
|
135
138
|
content: "";
|
|
136
139
|
position: absolute;
|
|
137
140
|
inset-block-start: 0;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{% set baseClass = 'mx-card' %}
|
|
2
2
|
{% set classes = [baseClass] %}
|
|
3
|
-
{% set background = null %}
|
|
3
|
+
{% set background = background ? "mx-background--"~background : null %}
|
|
4
4
|
{% for modifier in modifiers %}
|
|
5
5
|
{% if modifier == "dark" %}
|
|
6
6
|
{% set background = 'mx-background--reverse' %}
|
|
@@ -19,11 +19,6 @@
|
|
|
19
19
|
|
|
20
20
|
<div class="mx-container">
|
|
21
21
|
<article{{ attributes }}>
|
|
22
|
-
{% if image is not empty %}
|
|
23
|
-
<figure class="mx-card__media">
|
|
24
|
-
{{ image }}
|
|
25
|
-
</figure>
|
|
26
|
-
{% endif %}
|
|
27
22
|
{% if icon is not empty %}
|
|
28
23
|
<div class="mx-card__icon">
|
|
29
24
|
{{ icon }}
|
|
@@ -41,5 +36,10 @@
|
|
|
41
36
|
{{ linkList }}
|
|
42
37
|
{{ link }}
|
|
43
38
|
</div>
|
|
39
|
+
{% if image is not empty %}
|
|
40
|
+
<figure class="mx-card__media">
|
|
41
|
+
{{ image }}
|
|
42
|
+
</figure>
|
|
43
|
+
{% endif %}
|
|
44
44
|
</article>
|
|
45
45
|
</div>
|
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
import { Meta, StoryObj } from "@storybook/html-vite"
|
|
2
|
+
import Component from "./carousel.twig"
|
|
3
|
+
import "./carousel.css"
|
|
4
|
+
import "./Elements/Carousel"
|
|
5
|
+
import {
|
|
6
|
+
CardCarousel as CarouselType,
|
|
7
|
+
HeadingTypes,
|
|
8
|
+
ListItemModifiers,
|
|
9
|
+
} from "@pnx-mixtape/ids-shape"
|
|
10
|
+
|
|
11
|
+
// Deps.
|
|
12
|
+
import Card from "../Card/card.twig"
|
|
13
|
+
import "../Card/card.css"
|
|
14
|
+
import Heading from "../../Atom/Heading/heading.twig"
|
|
15
|
+
import Link from "../../Atom/Link/link.twig"
|
|
16
|
+
import { BackgroundStyles } from "../../enums"
|
|
17
|
+
|
|
18
|
+
const meta: Meta<CarouselType> = {
|
|
19
|
+
tags: ["autodocs", "ids-mvp"],
|
|
20
|
+
component: Component,
|
|
21
|
+
args: {
|
|
22
|
+
items: [
|
|
23
|
+
Card({
|
|
24
|
+
title: Heading({
|
|
25
|
+
title: "Tile 1",
|
|
26
|
+
as: HeadingTypes.THREE,
|
|
27
|
+
}),
|
|
28
|
+
link: Link({
|
|
29
|
+
href: "#",
|
|
30
|
+
title: "Find out more",
|
|
31
|
+
more: true,
|
|
32
|
+
}),
|
|
33
|
+
content: "<p>Tiles are just block cards without an image.</p>",
|
|
34
|
+
background: BackgroundStyles.BOX,
|
|
35
|
+
modifiers: [ListItemModifiers.BLOCK],
|
|
36
|
+
}),
|
|
37
|
+
Card({
|
|
38
|
+
title: Heading({
|
|
39
|
+
title: "Tile 2",
|
|
40
|
+
as: HeadingTypes.THREE,
|
|
41
|
+
}),
|
|
42
|
+
link: Link({
|
|
43
|
+
href: "#",
|
|
44
|
+
title: "Find out more",
|
|
45
|
+
more: true,
|
|
46
|
+
}),
|
|
47
|
+
content: "<p>Tiles are just block cards without an image.</p>",
|
|
48
|
+
background: BackgroundStyles.BOX,
|
|
49
|
+
modifiers: [ListItemModifiers.BLOCK],
|
|
50
|
+
}),
|
|
51
|
+
Card({
|
|
52
|
+
title: Heading({
|
|
53
|
+
title: "Tile 3",
|
|
54
|
+
as: HeadingTypes.THREE,
|
|
55
|
+
}),
|
|
56
|
+
link: Link({
|
|
57
|
+
href: "#",
|
|
58
|
+
title: "Find out more",
|
|
59
|
+
more: true,
|
|
60
|
+
}),
|
|
61
|
+
content: "<p>Tiles are just block cards without an image.</p>",
|
|
62
|
+
background: BackgroundStyles.BOX,
|
|
63
|
+
modifiers: [ListItemModifiers.BLOCK],
|
|
64
|
+
}),
|
|
65
|
+
Card({
|
|
66
|
+
title: Heading({
|
|
67
|
+
title: "Tile 4",
|
|
68
|
+
as: HeadingTypes.THREE,
|
|
69
|
+
}),
|
|
70
|
+
link: Link({
|
|
71
|
+
href: "#",
|
|
72
|
+
title: "Find out more",
|
|
73
|
+
more: true,
|
|
74
|
+
}),
|
|
75
|
+
content: "<p>Tiles are just block cards without an image.</p>",
|
|
76
|
+
background: BackgroundStyles.BOX,
|
|
77
|
+
modifiers: [ListItemModifiers.BLOCK],
|
|
78
|
+
}),
|
|
79
|
+
Card({
|
|
80
|
+
title: Heading({
|
|
81
|
+
title: "Tile 5",
|
|
82
|
+
as: HeadingTypes.THREE,
|
|
83
|
+
}),
|
|
84
|
+
link: Link({
|
|
85
|
+
href: "#",
|
|
86
|
+
title: "Find out more",
|
|
87
|
+
more: true,
|
|
88
|
+
}),
|
|
89
|
+
content:
|
|
90
|
+
"<p>Tiles are just block cards without an image but may have longer text and trigger height changes..</p>",
|
|
91
|
+
background: BackgroundStyles.BOX,
|
|
92
|
+
modifiers: [ListItemModifiers.BLOCK],
|
|
93
|
+
}),
|
|
94
|
+
Card({
|
|
95
|
+
title: Heading({
|
|
96
|
+
title: "Tile 6",
|
|
97
|
+
as: HeadingTypes.THREE,
|
|
98
|
+
}),
|
|
99
|
+
link: Link({
|
|
100
|
+
href: "#",
|
|
101
|
+
title: "Find out more",
|
|
102
|
+
more: true,
|
|
103
|
+
}),
|
|
104
|
+
content: "<p>Tiles are just block cards without an image.</p>",
|
|
105
|
+
background: BackgroundStyles.BOX,
|
|
106
|
+
modifiers: [ListItemModifiers.BLOCK],
|
|
107
|
+
}),
|
|
108
|
+
Card({
|
|
109
|
+
title: Heading({
|
|
110
|
+
title: "Tile 7",
|
|
111
|
+
as: HeadingTypes.THREE,
|
|
112
|
+
}),
|
|
113
|
+
link: Link({
|
|
114
|
+
href: "#",
|
|
115
|
+
title: "Find out more",
|
|
116
|
+
more: true,
|
|
117
|
+
}),
|
|
118
|
+
content: "<p>Tiles are just block cards without an image.</p>",
|
|
119
|
+
background: BackgroundStyles.BOX,
|
|
120
|
+
modifiers: [ListItemModifiers.BLOCK],
|
|
121
|
+
}),
|
|
122
|
+
Card({
|
|
123
|
+
title: Heading({
|
|
124
|
+
title: "Tile 8",
|
|
125
|
+
as: HeadingTypes.THREE,
|
|
126
|
+
}),
|
|
127
|
+
link: Link({
|
|
128
|
+
href: "#",
|
|
129
|
+
title: "Find out more",
|
|
130
|
+
more: true,
|
|
131
|
+
}),
|
|
132
|
+
content: "<p>Tiles are just block cards without an image.</p>",
|
|
133
|
+
background: BackgroundStyles.BOX,
|
|
134
|
+
modifiers: [ListItemModifiers.BLOCK],
|
|
135
|
+
}),
|
|
136
|
+
Card({
|
|
137
|
+
title: Heading({
|
|
138
|
+
title: "Tile 9",
|
|
139
|
+
as: HeadingTypes.THREE,
|
|
140
|
+
}),
|
|
141
|
+
link: Link({
|
|
142
|
+
href: "#",
|
|
143
|
+
title: "Find out more",
|
|
144
|
+
more: true,
|
|
145
|
+
}),
|
|
146
|
+
content: "<p>Tiles are just block cards without an image.</p>",
|
|
147
|
+
background: BackgroundStyles.BOX,
|
|
148
|
+
modifiers: [ListItemModifiers.BLOCK],
|
|
149
|
+
}),
|
|
150
|
+
Card({
|
|
151
|
+
title: Heading({
|
|
152
|
+
title: "Tile 10",
|
|
153
|
+
as: HeadingTypes.THREE,
|
|
154
|
+
}),
|
|
155
|
+
link: Link({
|
|
156
|
+
href: "#",
|
|
157
|
+
title: "Find out more",
|
|
158
|
+
more: true,
|
|
159
|
+
}),
|
|
160
|
+
content: "<p>Tiles are just block cards without an image.</p>",
|
|
161
|
+
background: BackgroundStyles.BOX,
|
|
162
|
+
modifiers: [ListItemModifiers.BLOCK],
|
|
163
|
+
}),
|
|
164
|
+
Card({
|
|
165
|
+
title: Heading({
|
|
166
|
+
title: "Tile 11",
|
|
167
|
+
as: HeadingTypes.THREE,
|
|
168
|
+
}),
|
|
169
|
+
link: Link({
|
|
170
|
+
href: "#",
|
|
171
|
+
title: "Find out more",
|
|
172
|
+
more: true,
|
|
173
|
+
}),
|
|
174
|
+
content: "<p>Tiles are just block cards without an image.</p>",
|
|
175
|
+
background: BackgroundStyles.BOX,
|
|
176
|
+
modifiers: [ListItemModifiers.BLOCK],
|
|
177
|
+
}),
|
|
178
|
+
],
|
|
179
|
+
loop: false,
|
|
180
|
+
pagination: false,
|
|
181
|
+
counter: false,
|
|
182
|
+
},
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
export default meta
|
|
186
|
+
type Story = StoryObj<CarouselType>
|
|
187
|
+
|
|
188
|
+
export const Carousel: Story = {}
|
|
189
|
+
|
|
190
|
+
export const Counters: Story = {
|
|
191
|
+
args: {
|
|
192
|
+
counter: true,
|
|
193
|
+
},
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
export const Paginated: Story = {
|
|
197
|
+
args: {
|
|
198
|
+
pagination: true,
|
|
199
|
+
loop: true,
|
|
200
|
+
},
|
|
201
|
+
}
|
|
@@ -0,0 +1,241 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Carousel
|
|
3
|
+
* @file Support scrolling with buttons.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import { createElement } from "../../../Utility/utilities"
|
|
7
|
+
|
|
8
|
+
export default class Carousel extends HTMLElement {
|
|
9
|
+
internals_: ElementInternals
|
|
10
|
+
controller: AbortController
|
|
11
|
+
debounced: ReturnType<typeof setTimeout>
|
|
12
|
+
loop?: boolean
|
|
13
|
+
paginationType?: "pagination" | "counter"
|
|
14
|
+
activePage?: number
|
|
15
|
+
itemMap?: Map<HTMLLIElement, boolean>
|
|
16
|
+
|
|
17
|
+
constructor() {
|
|
18
|
+
super()
|
|
19
|
+
this.internals_ = this.attachInternals()
|
|
20
|
+
this.controller = new AbortController()
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
connectedCallback(): void {
|
|
24
|
+
if (!this.list) return
|
|
25
|
+
if (this.buttons) this.buttons.hidden = false
|
|
26
|
+
|
|
27
|
+
this.activePage = 0
|
|
28
|
+
this.list.scrollLeft = 0
|
|
29
|
+
this.debounced = null
|
|
30
|
+
this.loop = this.hasAttribute("loop")
|
|
31
|
+
|
|
32
|
+
const { signal }: AbortController = this.controller
|
|
33
|
+
if (this.prev) {
|
|
34
|
+
this.prev.disabled = true
|
|
35
|
+
this.prev.addEventListener(
|
|
36
|
+
"click",
|
|
37
|
+
() => this.handleNavigation(this.activePage - 1),
|
|
38
|
+
{ signal },
|
|
39
|
+
)
|
|
40
|
+
}
|
|
41
|
+
if (this.next)
|
|
42
|
+
this.next.addEventListener(
|
|
43
|
+
"click",
|
|
44
|
+
() => this.handleNavigation(this.activePage + 1),
|
|
45
|
+
{ signal },
|
|
46
|
+
)
|
|
47
|
+
this.list.addEventListener("scroll", this.handleScroll, { signal })
|
|
48
|
+
|
|
49
|
+
if (this.pagination) {
|
|
50
|
+
this.paginationType = this.pagination.getAttribute("data-pagination") as
|
|
51
|
+
| "pagination"
|
|
52
|
+
| "counter"
|
|
53
|
+
|
|
54
|
+
this.pagination.addEventListener("click", this.handlePagination, {
|
|
55
|
+
signal,
|
|
56
|
+
})
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
const items: NodeListOf<HTMLLIElement> =
|
|
60
|
+
this.list.querySelectorAll(":scope > li")
|
|
61
|
+
this.itemMap = new Map()
|
|
62
|
+
const iO = new IntersectionObserver(
|
|
63
|
+
entries => {
|
|
64
|
+
entries.forEach(({ target, intersectionRatio }) => {
|
|
65
|
+
const li = target as HTMLLIElement
|
|
66
|
+
if (intersectionRatio > 0.5) {
|
|
67
|
+
li.removeAttribute("inert")
|
|
68
|
+
this.itemMap.set(li, true)
|
|
69
|
+
} else {
|
|
70
|
+
li.setAttribute("inert", "")
|
|
71
|
+
this.itemMap.set(li, false)
|
|
72
|
+
}
|
|
73
|
+
})
|
|
74
|
+
},
|
|
75
|
+
{
|
|
76
|
+
root: this.list,
|
|
77
|
+
threshold: 0.5,
|
|
78
|
+
},
|
|
79
|
+
)
|
|
80
|
+
items.forEach(item => iO.observe(item))
|
|
81
|
+
|
|
82
|
+
const rO = new ResizeObserver(entries => {
|
|
83
|
+
entries.forEach(() => this.handleOverflow())
|
|
84
|
+
})
|
|
85
|
+
rO.observe(this.list)
|
|
86
|
+
|
|
87
|
+
const mO = new MutationObserver(entries => {
|
|
88
|
+
entries.forEach(() => this.handleOverflow())
|
|
89
|
+
})
|
|
90
|
+
mO.observe(this.list, { childList: true })
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
disconnectedCallback(): void {
|
|
94
|
+
this.controller.abort()
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
handleNavigation = (page: number, type: "arrow" | "pagination" = "arrow") => {
|
|
98
|
+
const goesForward = page > this.activePage
|
|
99
|
+
const hasRestart = this.loop && this.next.hasAttribute("data-restart")
|
|
100
|
+
if (!this.pagination) this.activePage = page
|
|
101
|
+
if (page === 0 || (hasRestart && goesForward && type === "arrow")) {
|
|
102
|
+
// Scroll to the start.
|
|
103
|
+
this.items[0].scrollIntoView({ inline: "start", block: "center" })
|
|
104
|
+
this.next.removeAttribute("data-restart")
|
|
105
|
+
return
|
|
106
|
+
}
|
|
107
|
+
// Scroll to the first item of a page.
|
|
108
|
+
this.items[this.visibleCount * page].scrollIntoView({
|
|
109
|
+
inline: "start",
|
|
110
|
+
block: "center",
|
|
111
|
+
})
|
|
112
|
+
if (hasRestart && !goesForward) this.next.removeAttribute("data-restart")
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
handleDisabled = () => {
|
|
116
|
+
let isEnd = false
|
|
117
|
+
if (this.prev) this.prev.disabled = this.list.scrollLeft < 1
|
|
118
|
+
if (this.next || this.pagination) {
|
|
119
|
+
isEnd =
|
|
120
|
+
this.list.scrollLeft === this.list.scrollWidth - this.list.offsetWidth
|
|
121
|
+
}
|
|
122
|
+
if (this.next) {
|
|
123
|
+
if (!this.loop) {
|
|
124
|
+
this.next.disabled = isEnd
|
|
125
|
+
} else if (isEnd) {
|
|
126
|
+
this.next.setAttribute("data-restart", "")
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
if (this.pagination) {
|
|
130
|
+
// Set the activePage based on scroll.
|
|
131
|
+
const startPosition = this.list.offsetLeft + this.list.scrollLeft
|
|
132
|
+
if (isEnd) {
|
|
133
|
+
// If it's the end, the last page is active.
|
|
134
|
+
this.activePage = this.pageStartItems.length - 1
|
|
135
|
+
} else {
|
|
136
|
+
// Otherwise when the start of a page reaches the start of it's container, then set it to the active page.
|
|
137
|
+
this.pageStartItems.forEach((item, index) => {
|
|
138
|
+
if (item.offsetLeft === startPosition) this.activePage = index
|
|
139
|
+
})
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
this.pagination.querySelectorAll("button").forEach(button => {
|
|
143
|
+
const index = button.getAttribute("data-index")
|
|
144
|
+
if (!index) return
|
|
145
|
+
const page = parseInt(index, 10)
|
|
146
|
+
button.disabled = page === this.activePage
|
|
147
|
+
})
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
handleScroll = () => {
|
|
152
|
+
window.clearTimeout(this.debounced)
|
|
153
|
+
this.debounced = setTimeout(
|
|
154
|
+
this.handleDisabled,
|
|
155
|
+
this.pagination ? 100 : 200,
|
|
156
|
+
)
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
handleOverflow = () => {
|
|
160
|
+
const { scrollWidth, clientWidth } = this.list
|
|
161
|
+
const hasOverflow = scrollWidth > clientWidth
|
|
162
|
+
this.list.classList.toggle("overflowing", hasOverflow)
|
|
163
|
+
if (this.pagination && hasOverflow) {
|
|
164
|
+
// Timeout needed for this.itemMap to get populated by i0.
|
|
165
|
+
setTimeout(this.buildPagination, 200)
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
buildPagination = () => {
|
|
170
|
+
if (!this.pagination.hidden) {
|
|
171
|
+
// Existing pagination
|
|
172
|
+
const currentPages = this.pagination.querySelectorAll(":scope > li")
|
|
173
|
+
if (currentPages.length === this.pageStartItems.length) return
|
|
174
|
+
// If the number of pages changes, remove current ones so it can be rebuilt.
|
|
175
|
+
currentPages.forEach(li => li.remove())
|
|
176
|
+
}
|
|
177
|
+
const pages = new Array(this.pageStartItems.length).fill(null)
|
|
178
|
+
pages.forEach((_, index) => {
|
|
179
|
+
const li = createElement(
|
|
180
|
+
`<li><button type="button" data-index="${index}">${index + 1}</button>`,
|
|
181
|
+
)
|
|
182
|
+
this.pagination.append(li)
|
|
183
|
+
pages[index] = li
|
|
184
|
+
})
|
|
185
|
+
const firstPage = pages[0] as HTMLLIElement
|
|
186
|
+
firstPage.querySelector("button").disabled = true
|
|
187
|
+
this.pagination.hidden = false
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
handlePagination = (event: MouseEvent) => {
|
|
191
|
+
const target = event.target as HTMLButtonElement
|
|
192
|
+
const index = target.getAttribute("data-index")
|
|
193
|
+
if (!index) return
|
|
194
|
+
const page: number = parseInt(index, 10)
|
|
195
|
+
this.handleNavigation(page, "pagination")
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
get list(): HTMLUListElement | null {
|
|
199
|
+
const list: HTMLUListElement | null = this.querySelector(":scope > ul")
|
|
200
|
+
if (!list) {
|
|
201
|
+
throw new Error(`${this.localName} must contain a <ul> element.`)
|
|
202
|
+
}
|
|
203
|
+
return list
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
get buttons(): HTMLElement | null {
|
|
207
|
+
return this.querySelector("[data-buttons]")
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
get prev(): HTMLButtonElement | null {
|
|
211
|
+
return this.buttons.querySelector(".mx-carousel__prev")
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
get next(): HTMLButtonElement | null {
|
|
215
|
+
return this.buttons.querySelector(".mx-carousel__next")
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
get pagination(): HTMLOListElement | null {
|
|
219
|
+
return this.querySelector("[data-pagination]")
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
get items(): HTMLLIElement[] {
|
|
223
|
+
return [...this.itemMap.keys()]
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
get visibleCount(): number {
|
|
227
|
+
return [...this.itemMap.values()].filter(visible => visible).length
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
get pageStartItems(): HTMLLIElement[] {
|
|
231
|
+
return [...this.items].filter((_, index) => index % this.visibleCount == 0)
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
customElements.define("mx-carousel", Carousel)
|
|
236
|
+
|
|
237
|
+
declare global {
|
|
238
|
+
interface HTMLElementTagNameMap {
|
|
239
|
+
"mx-carousel": Carousel
|
|
240
|
+
}
|
|
241
|
+
}
|