@pnx-mixtape/mxds 0.0.19 → 0.0.21

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (120) hide show
  1. package/README.md +18 -6
  2. package/dist/build/accordion.entry.js +2 -2
  3. package/dist/build/accordion.entry.js.map +1 -1
  4. package/dist/build/base.css +2 -1
  5. package/dist/build/button.css +4 -4
  6. package/dist/build/card.css +6 -5
  7. package/dist/build/chunks/{Accordion-deu4CCT-.js → Accordion-O-huO4At.js} +2 -2
  8. package/dist/build/chunks/{Accordion-deu4CCT-.js.map → Accordion-O-huO4At.js.map} +1 -1
  9. package/dist/build/chunks/{disclosure-widget-WwE5XplD.js → disclosure-widget-DVpnRsTI.js} +2 -2
  10. package/dist/build/chunks/{disclosure-widget-WwE5XplD.js.map → disclosure-widget-DVpnRsTI.js.map} +1 -1
  11. package/dist/build/chunks/{drop-menu.entry-e1iZ4ERw.js → drop-menu.entry-B4TtnC50.js} +2 -2
  12. package/dist/build/chunks/{drop-menu.entry-e1iZ4ERw.js.map → drop-menu.entry-B4TtnC50.js.map} +1 -1
  13. package/dist/build/chunks/{utilities-BeWkujCZ.js → utilities-DXELy_An.js} +91 -1
  14. package/dist/build/chunks/utilities-DXELy_An.js.map +1 -0
  15. package/dist/build/constants.css +6 -4
  16. package/dist/build/dialog.css +1 -9
  17. package/dist/build/dialog.entry.js +1 -1
  18. package/dist/build/drop-menu.entry.js +1 -1
  19. package/dist/build/filters.entry.js +1 -1
  20. package/dist/build/global-alert.entry.js +1 -1
  21. package/dist/build/header.css +49 -63
  22. package/dist/build/header.entry.js +1107 -21
  23. package/dist/build/header.entry.js.map +1 -1
  24. package/dist/build/hero-banner.css +12 -6
  25. package/dist/build/in-page-navigation.entry.js +1 -1
  26. package/dist/build/navigation.entry.js +2 -2
  27. package/dist/build/page.css +2 -2
  28. package/dist/build/pagination.css +15 -21
  29. package/dist/build/steps.css +11 -11
  30. package/dist/build/sticky.entry.js +1 -1
  31. package/dist/build/tabs.entry.js +2 -2
  32. package/dist/build/utilities.css +9 -1
  33. package/package.json +18 -29
  34. package/src/Atom/Button/_buttons-styles.css +3 -3
  35. package/src/Atom/Heading/Heading.tsx +1 -1
  36. package/src/Atom/Icon/Icon.tsx +1 -1
  37. package/src/Atom/Link/Link.stories.tsx +2 -6
  38. package/src/Atom/Link/Link.tsx +9 -4
  39. package/src/Atom/Link/_links.css +1 -0
  40. package/src/Component/Accordion/Accordion.stories.tsx +39 -9
  41. package/src/Component/Accordion/Accordion.tsx +28 -50
  42. package/src/Component/Accordion/Components/AccordionContent.tsx +24 -0
  43. package/src/Component/Accordion/Components/AccordionTitle.tsx +34 -0
  44. package/src/Component/Accordion/Components/AccordionTitleIcon.tsx +22 -0
  45. package/src/Component/Accordion/__snapshots__/Accordion.stories.tsx.snap +26 -0
  46. package/src/Component/Breadcrumb/Breadcrumb.tsx +8 -2
  47. package/src/Component/Breadcrumb/__snapshots__/Breadcrumb.stories.tsx.snap +7 -3
  48. package/src/Component/Card/Card.stories.tsx +22 -19
  49. package/src/Component/Card/Card.tsx +6 -28
  50. package/src/Component/Card/Components/CardContent.tsx +12 -0
  51. package/src/Component/Card/Components/CardMedia.tsx +17 -0
  52. package/src/Component/Card/__snapshots__/Card.stories.tsx.snap +9 -9
  53. package/src/Component/Card/card.css +3 -2
  54. package/src/Component/ContentBlock/Components/ContentBlockContent.tsx +14 -0
  55. package/src/Component/ContentBlock/Components/ContentBlockMedia.tsx +20 -0
  56. package/src/Component/ContentBlock/ContentBlock.stories.tsx +16 -13
  57. package/src/Component/ContentBlock/ContentBlock.tsx +5 -28
  58. package/src/Component/ContentBlock/__snapshots__/ContentBlock.stories.tsx.snap +0 -2
  59. package/src/Component/Dialog/Components/DialogCloseButton.tsx +18 -0
  60. package/src/Component/Dialog/Components/DialogContent.tsx +7 -0
  61. package/src/Component/Dialog/Dialog.stories.tsx +19 -24
  62. package/src/Component/Dialog/Dialog.tsx +31 -25
  63. package/src/Component/Dialog/__snapshots__/Dialog.stories.tsx.snap +14 -21
  64. package/src/Component/Dialog/dialog.css +0 -8
  65. package/src/Component/HeroBanner/HeroBanner.stories.ts +23 -12
  66. package/src/Component/HeroBanner/HeroBanner.stories.tsx +26 -7
  67. package/src/Component/HeroBanner/HeroBanner.tsx +2 -20
  68. package/src/Component/HeroBanner/__snapshots__/HeroBanner.stories.ts.snap +51 -3
  69. package/src/Component/HeroBanner/hero-banner.css +8 -4
  70. package/src/Component/HeroBanner/hero-banner.twig +2 -2
  71. package/src/Component/HeroSearch/HeroSearch.stories.ts +105 -0
  72. package/src/Component/HeroSearch/HeroSearch.stories.tsx +48 -0
  73. package/src/Component/HeroSearch/HeroSearch.tsx +32 -0
  74. package/src/Component/HeroSearch/__snapshots__/HeroSearch.stories.ts.snap +176 -0
  75. package/src/Component/HeroSearch/__snapshots__/HeroSearch.stories.tsx.snap +36 -0
  76. package/src/Component/HeroSearch/hero-search.twig +43 -0
  77. package/src/Component/InPageNavigation/InPageNavigation.stories.tsx +1 -1
  78. package/src/Component/InPageNavigation/InPageNavigation.tsx +1 -0
  79. package/src/Component/InPageNavigation/__snapshots__/InPageNavigation.stories.tsx.snap +1 -1
  80. package/src/Component/LinkList/LinkList.stories.ts +12 -0
  81. package/src/Component/LinkList/LinkList.stories.tsx +0 -6
  82. package/src/Component/LinkList/LinkList.tsx +5 -16
  83. package/src/Component/LinkList/__snapshots__/LinkList.stories.ts.snap +37 -0
  84. package/src/Component/LinkList/__snapshots__/LinkList.stories.tsx.snap +9 -29
  85. package/src/Component/LinkList/link-list.twig +1 -0
  86. package/src/Component/ListItem/Components/ListItemContent.tsx +12 -0
  87. package/src/Component/ListItem/Components/ListItemMedia.tsx +20 -0
  88. package/src/Component/ListItem/ListItem.stories.tsx +22 -19
  89. package/src/Component/ListItem/ListItem.tsx +3 -32
  90. package/src/Component/ListItem/__snapshots__/ListItem.stories.tsx.snap +3 -0
  91. package/src/Component/Pagination/Components/PaginationContext.tsx +10 -4
  92. package/src/Component/Pagination/Components/PaginationItem.tsx +10 -10
  93. package/src/Component/Pagination/Pagination.tsx +6 -2
  94. package/src/Component/Pagination/__snapshots__/Pagination.stories.tsx.snap +10 -4
  95. package/src/Component/Pagination/pagination.css +13 -18
  96. package/src/Component/Steps/__snapshots__/Steps.stories.ts.snap +12 -12
  97. package/src/Component/Steps/step-item.twig +1 -1
  98. package/src/Component/Steps/steps.css +1 -2
  99. package/src/Component/Tabs/Components/TabPanel.tsx +1 -1
  100. package/src/Component/Tabs/__snapshots__/Tabs.stories.tsx.snap +2 -0
  101. package/src/Component/Tile/Tile.stories.tsx +20 -15
  102. package/src/Component/Tile/__snapshots__/Tile.stories.tsx.snap +18 -23
  103. package/src/Layout/Header/Elements/GlobalToggle.ts +55 -21
  104. package/src/Layout/Header/__snapshots__/Header.stories.ts.snap +14 -14
  105. package/src/Layout/Header/__snapshots__/Header.stories.tsx.snap +2 -2
  106. package/src/Layout/Header/_header.css +2 -47
  107. package/src/Layout/Header/_toggles.css +37 -1
  108. package/src/Layout/Header/header.twig +5 -5
  109. package/src/Layout/Page/Page.stories.tsx +13 -4
  110. package/src/Layout/Page/__snapshots__/Page.stories.tsx.snap +2 -2
  111. package/src/Layout/Page/page.css +1 -1
  112. package/src/Layout/Section/__snapshots__/Section.stories.tsx.snap +3 -3
  113. package/src/Layout/Section/__snapshots__/SectionGrid.stories.tsx.snap +2 -2
  114. package/src/Layout/Sidebar/__snapshots__/Sidebar.stories.tsx.snap +3 -3
  115. package/src/Utility/utilities.css +8 -0
  116. package/src/constants.css +5 -3
  117. package/src/react.ts +30 -7
  118. package/src/tokens.js +3 -1
  119. package/dist/build/chunks/utilities-BeWkujCZ.js.map +0 -1
  120. package/src/Component/Tile/Tile.tsx +0 -53
@@ -1,31 +1,20 @@
1
- import { JSX, ReactNode, PropsWithChildren } from "react"
1
+ import { JSX, PropsWithChildren } from "react"
2
2
  import classNames from "classnames"
3
- import Heading from "../../Atom/Heading/Heading"
4
- import { HeadingStyles, BackgroundStyles } from "../../enums"
5
- import { HeadingTypes, AsTypes } from "@pnx-mixtape/ids-shape"
3
+ import { BackgroundStyles } from "../../enums"
4
+ import { AsTypes } from "@pnx-mixtape/ids-shape"
6
5
 
7
6
  type CardProps = PropsWithChildren & {
8
- title: string
9
- image?: ReactNode
10
- intro?: ReactNode
11
7
  reversed?: boolean
12
8
  block?: boolean
13
- headingLevel?: HeadingTypes
14
- headingModifier?: HeadingStyles
15
9
  as?: AsTypes
16
10
  background?: BackgroundStyles
17
11
  className?: string
18
12
  }
19
13
 
20
14
  const Card = ({
21
- title,
22
15
  children,
23
16
  reversed = null,
24
17
  block = false,
25
- image = null,
26
- intro = null,
27
- headingLevel = HeadingTypes.THREE,
28
- headingModifier = null,
29
18
  as = AsTypes.DIV,
30
19
  background = null,
31
20
  className = null,
@@ -34,24 +23,13 @@ const Card = ({
34
23
  return (
35
24
  <Tag className="mx-container">
36
25
  <article
37
- className={classNames("mx-card", background, className, {
26
+ className={classNames("mx-card", className, {
38
27
  "mx-card--reversed": reversed,
39
28
  "mx-card--block": block,
29
+ [`mx-background--${background}`]: background,
40
30
  })}
41
31
  >
42
- {image && (
43
- <figure className={classNames("mx-card__media", "stack")}>
44
- <div className="mx-skeleton mx-skeleton--bg"></div>
45
- {image}
46
- </figure>
47
- )}
48
- <div className={classNames("mx-card__content", "mx-vertical-flow")}>
49
- {intro}
50
- <Heading as={headingLevel} modifier={headingModifier}>
51
- {title}
52
- </Heading>
53
- {children}
54
- </div>
32
+ {children}
55
33
  </article>
56
34
  </Tag>
57
35
  )
@@ -0,0 +1,12 @@
1
+ import { JSX, PropsWithChildren } from "react"
2
+ import classNames from "classnames"
3
+
4
+ const CardContent = ({ children }: PropsWithChildren): JSX.Element => {
5
+ return (
6
+ <div className={classNames("mx-card__content", "mx-vertical-flow")}>
7
+ {children}
8
+ </div>
9
+ )
10
+ }
11
+
12
+ export default CardContent
@@ -0,0 +1,17 @@
1
+ import { JSX, PropsWithChildren } from "react"
2
+ import classNames from "classnames"
3
+
4
+ type CardProps = PropsWithChildren & {
5
+ skeleton?: boolean
6
+ }
7
+
8
+ const CardMedia = ({ children, skeleton = false }: CardProps): JSX.Element => {
9
+ return (
10
+ <figure className={classNames("mx-card__media", "stack")}>
11
+ {skeleton && <div className="mx-skeleton mx-skeleton--bg"></div>}
12
+ {children}
13
+ </figure>
14
+ )
15
+ }
16
+
17
+ export default CardMedia
@@ -1,8 +1,8 @@
1
1
  // Jest Snapshot v1, https://goo.gl/fbAQLP
2
2
 
3
- exports[`Component/Card Card smoke-test 1`] = `
3
+ exports[`Component/Card BlockLink smoke-test 1`] = `
4
4
  <div class="mx-container">
5
- <article class="mx-card">
5
+ <article class="mx-card mx-card--block">
6
6
  <figure class="mx-card__media stack">
7
7
  <div class="mx-skeleton mx-skeleton--bg">
8
8
  </div>
@@ -11,11 +11,11 @@ exports[`Component/Card Card smoke-test 1`] = `
11
11
  >
12
12
  </figure>
13
13
  <div class="mx-card__content mx-vertical-flow">
14
- <h3 class
14
+ <h2 class
15
15
  id="key-feature-or-sectio"
16
16
  >
17
17
  Key feature or Section Name
18
- </h3>
18
+ </h2>
19
19
  <p class>
20
20
  A short description to help explain enough about the subject matter to encourage visitors to learn more.
21
21
  </p>
@@ -29,7 +29,7 @@ exports[`Component/Card Card smoke-test 1`] = `
29
29
  </div>
30
30
  `;
31
31
 
32
- exports[`Component/Card Linked smoke-test 1`] = `
32
+ exports[`Component/Card Card smoke-test 1`] = `
33
33
  <div class="mx-container">
34
34
  <article class="mx-card">
35
35
  <figure class="mx-card__media stack">
@@ -40,11 +40,11 @@ exports[`Component/Card Linked smoke-test 1`] = `
40
40
  >
41
41
  </figure>
42
42
  <div class="mx-card__content mx-vertical-flow">
43
- <h3 class
43
+ <h2 class
44
44
  id="key-feature-or-sectio"
45
45
  >
46
46
  Key feature or Section Name
47
- </h3>
47
+ </h2>
48
48
  <p class>
49
49
  A short description to help explain enough about the subject matter to encourage visitors to learn more.
50
50
  </p>
@@ -58,9 +58,9 @@ exports[`Component/Card Linked smoke-test 1`] = `
58
58
  </div>
59
59
  `;
60
60
 
61
- exports[`Component/Card Right smoke-test 1`] = `
61
+ exports[`Component/Card Reverse smoke-test 1`] = `
62
62
  <div class="mx-container">
63
- <article class="mx-card">
63
+ <article class="mx-card mx-card--reversed">
64
64
  <figure class="mx-card__media stack">
65
65
  <div class="mx-skeleton mx-skeleton--bg">
66
66
  </div>
@@ -39,6 +39,7 @@
39
39
 
40
40
  @container (min-width: token("breakpoint.contentCard")) {
41
41
  --card-gap: var(--gap-l);
42
+ --card-alignment: center;
42
43
 
43
44
  grid-template: "media content" 1fr / var(--media-col, 1fr) var(
44
45
  --content-col,
@@ -73,12 +74,12 @@
73
74
 
74
75
  & .mx-card__content {
75
76
  grid-area: content;
76
- align-self: var(--align-content, center);
77
+ align-self: var(--align-content, var(--card-alignment, stretch));
77
78
  }
78
79
 
79
80
  & .mx-card__media {
80
81
  grid-area: media;
81
- align-self: var(--align-media, center);
82
+ align-self: var(--align-media, var(--card-alignment, stretch));
82
83
  inline-size: 100%;
83
84
 
84
85
  & img {
@@ -0,0 +1,14 @@
1
+ import { JSX, PropsWithChildren } from "react"
2
+ import classNames from "classnames"
3
+
4
+ const ContentBlockContent = ({ children }: PropsWithChildren): JSX.Element => {
5
+ return (
6
+ <div
7
+ className={classNames("mx-content-block__content", "mx-vertical-flow")}
8
+ >
9
+ {children}
10
+ </div>
11
+ )
12
+ }
13
+
14
+ export default ContentBlockContent
@@ -0,0 +1,20 @@
1
+ import { JSX, PropsWithChildren } from "react"
2
+ import classNames from "classnames"
3
+
4
+ type CardProps = PropsWithChildren & {
5
+ skeleton?: boolean
6
+ }
7
+
8
+ const ContentBlockMedia = ({
9
+ children,
10
+ skeleton = false,
11
+ }: CardProps): JSX.Element => {
12
+ return (
13
+ <figure className={classNames("mx-content-block__media", "stack")}>
14
+ {skeleton && <div className="mx-skeleton mx-skeleton--bg"></div>}
15
+ {children}
16
+ </figure>
17
+ )
18
+ }
19
+
20
+ export default ContentBlockMedia
@@ -1,10 +1,12 @@
1
1
  import { Meta, StoryObj } from "@storybook/react-vite"
2
2
  import Component from "./ContentBlock"
3
+ import ContentBlockContent from "./Components/ContentBlockContent"
4
+ import ContentBlockMedia from "./Components/ContentBlockMedia"
5
+ import Heading from "../../Atom/Heading/Heading"
3
6
  import Link from "../../Atom/Link/Link"
4
7
  import Text from "../../Atom/Text/Text"
5
8
  import Media from "../../Atom/Media/Media"
6
9
  import "./content-block.css"
7
- import { HeadingStyles, LinkStyles } from "../../enums"
8
10
  import { AsTypes, HeadingTypes } from "@pnx-mixtape/ids-shape"
9
11
 
10
12
  const meta: Meta<typeof Component> = {
@@ -12,25 +14,26 @@ const meta: Meta<typeof Component> = {
12
14
  component: Component,
13
15
  argTypes: {
14
16
  children: { table: { disable: true } },
15
- image: { table: { disable: true } },
16
- headingLevel: { options: Object.values(HeadingTypes) },
17
- headingModifier: { options: Object.values(HeadingStyles) },
18
17
  as: { options: Object.values(AsTypes) },
19
18
  },
20
19
  args: {
21
- title: "Content block",
22
20
  children: (
23
21
  <>
24
- <Text>
25
- A short description to help explain enough about the subject matter to
26
- encourage visitors to learn more.
27
- </Text>
28
- <Link modifier={LinkStyles.MORE} to="http://example.com">
29
- Learn More
30
- </Link>
22
+ <ContentBlockMedia>
23
+ <Media src="https://picsum.photos/id/56/558/418?grayscale" alt="" />
24
+ </ContentBlockMedia>
25
+ <ContentBlockContent>
26
+ <Heading as={HeadingTypes.THREE}>Content block</Heading>
27
+ <Text>
28
+ A short description to help explain enough about the subject matter
29
+ to encourage visitors to learn more.
30
+ </Text>
31
+ <Link more to="http://example.com">
32
+ Learn More
33
+ </Link>
34
+ </ContentBlockContent>
31
35
  </>
32
36
  ),
33
- image: <Media src="https://picsum.photos/id/56/558/418?grayscale" alt="" />,
34
37
  },
35
38
  }
36
39
  export default meta
@@ -1,43 +1,20 @@
1
- import { JSX, PropsWithChildren, ReactNode } from "react"
1
+ import { JSX, PropsWithChildren } from "react"
2
2
  import classNames from "classnames"
3
- import { AsTags, HeadingStyles } from "../../enums"
4
- import Heading from "../../Atom/Heading/Heading"
5
- import { HeadingTypes } from "@pnx-mixtape/ids-shape"
3
+ import { AsTypes } from "@pnx-mixtape/ids-shape"
6
4
 
7
5
  type ContentBlockProps = PropsWithChildren & {
8
- title: string
9
- image?: ReactNode
10
- headingLevel?: HeadingTypes
11
- headingModifier?: HeadingStyles
12
- as?: AsTags
6
+ as?: AsTypes
13
7
  }
14
8
 
15
9
  const ContentBlock = ({
16
- title,
17
10
  children,
18
- image = null,
19
- headingLevel = HeadingTypes.THREE,
20
- headingModifier = null,
21
- as = AsTags.DIV,
11
+ as = AsTypes.DIV,
22
12
  ...props
23
13
  }: ContentBlockProps): JSX.Element => {
24
14
  const Tag: JSX.ElementType = `${as}` as unknown as JSX.ElementType
25
15
  return (
26
16
  <Tag className={classNames("mx-content-block")} {...props}>
27
- {image && (
28
- <figure className={classNames("mx-content-block__media", "stack")}>
29
- <div className="mx-skeleton mx-skeleton--bg"></div>
30
- {image}
31
- </figure>
32
- )}
33
- <div
34
- className={classNames("mx-content-block__content", "mx-vertical-flow")}
35
- >
36
- <Heading as={headingLevel} modifier={headingModifier}>
37
- {title}
38
- </Heading>
39
- {children}
40
- </div>
17
+ {children}
41
18
  </Tag>
42
19
  )
43
20
  }
@@ -3,8 +3,6 @@
3
3
  exports[`Component/ContentBlock ContentBlock smoke-test 1`] = `
4
4
  <div class="mx-content-block">
5
5
  <figure class="mx-content-block__media stack">
6
- <div class="mx-skeleton mx-skeleton--bg">
7
- </div>
8
6
  <img alt
9
7
  src="https://picsum.photos/id/56/558/418?grayscale"
10
8
  >
@@ -0,0 +1,18 @@
1
+ import { JSX } from "react"
2
+ import { useDialog } from "../Dialog"
3
+
4
+ const DialogCloseButton = (): JSX.Element => {
5
+ const { handleClose } = useDialog()
6
+ return (
7
+ <button
8
+ autoFocus
9
+ onClick={handleClose}
10
+ className="mx-button mx-button--icon-only mx-icon mx-icon--close"
11
+ type="button"
12
+ >
13
+ Close dialog
14
+ </button>
15
+ )
16
+ }
17
+
18
+ export default DialogCloseButton
@@ -0,0 +1,7 @@
1
+ import { JSX, PropsWithChildren } from "react"
2
+
3
+ const DialogContent = ({ children }: PropsWithChildren): JSX.Element => {
4
+ return <div className="mx-dialog__content mx-vertical-flow">{children}</div>
5
+ }
6
+
7
+ export default DialogContent
@@ -1,9 +1,11 @@
1
1
  import { Meta, StoryObj } from "@storybook/react-vite"
2
2
  import Component from "./Dialog"
3
+ import DialogContent from "./Components/DialogContent"
4
+ import DialogCloseButton from "./Components/DialogCloseButton"
3
5
  import Heading from "../../Atom/Heading/Heading"
4
6
  import Text from "../../Atom/Text/Text"
5
7
  import "./dialog.css"
6
- import { DialogStyles, HeadingLevels } from "../../enums"
8
+ import { HeadingTypes } from "@pnx-mixtape/ids-shape"
7
9
 
8
10
  const meta: Meta<typeof Component> = {
9
11
  tags: ["autodocs"],
@@ -12,31 +14,24 @@ const meta: Meta<typeof Component> = {
12
14
  open: true,
13
15
  children: (
14
16
  <>
15
- <Heading level={HeadingLevels.THREE}>
16
- Thanks, you're almost done!
17
- </Heading>
18
- <Text>
19
- To finish the process, you will need to upload a few more documents.
20
- Please have your confirmation email ready before starting. Are you
21
- ready?
22
- </Text>
17
+ <DialogContent>
18
+ <Heading as={HeadingTypes.THREE}>Thanks, you're almost done!</Heading>
19
+ <Text>
20
+ To finish the process, you will need to upload a few more documents.
21
+ Please have your confirmation email ready before starting. Are you
22
+ ready?
23
+ </Text>
24
+ <form method="dialog">
25
+ <div className="mx-form-actions">
26
+ <button className="mx-button mx-button--primary" type="submit">
27
+ Let's get started
28
+ </button>
29
+ </div>
30
+ </form>
31
+ </DialogContent>
32
+ <DialogCloseButton />
23
33
  </>
24
34
  ),
25
- actions: (
26
- <form>
27
- <div className="form__actions">
28
- <button className="button button--primary" type="button">
29
- Let's get started
30
- </button>
31
- <button className="button" formMethod="dialog" type="button">
32
- Cancel
33
- </button>
34
- </div>
35
- </form>
36
- ),
37
- },
38
- argTypes: {
39
- modifier: { options: Object.values(DialogStyles), control: "radio" },
40
35
  },
41
36
  }
42
37
 
@@ -1,22 +1,31 @@
1
1
  import {
2
2
  JSX,
3
- ReactNode,
4
3
  PropsWithChildren,
5
4
  ComponentPropsWithoutRef,
6
5
  RefObject,
7
6
  useRef,
8
7
  useEffect,
9
8
  useCallback,
9
+ createContext,
10
+ use,
11
+ useMemo,
10
12
  } from "react"
11
13
  import classNames from "classnames"
12
- import { DialogStyles } from "../../enums"
14
+
15
+ type DialogContextValues = {
16
+ handleClose: () => void
17
+ ref: RefObject<HTMLDialogElement>
18
+ open: boolean
19
+ }
20
+
21
+ export const DialogContext = createContext<DialogContextValues>(null)
22
+ export const useDialog = () => use(DialogContext)
13
23
 
14
24
  type DialogProps = ComponentPropsWithoutRef<"dialog"> &
15
25
  PropsWithChildren & {
16
- modifier?: DialogStyles
17
- actions?: ReactNode
18
26
  className?: string
19
27
  modal?: boolean
28
+ fullscreen?: boolean
20
29
  onClose?: () => void
21
30
  }
22
31
 
@@ -24,11 +33,10 @@ const defaultOnClose = (): void => {}
24
33
 
25
34
  const Dialog = ({
26
35
  children,
27
- modifier,
28
- actions,
29
36
  open = false,
30
37
  onClose = defaultOnClose,
31
38
  modal = true,
39
+ fullscreen = false,
32
40
  ...props
33
41
  }: DialogProps): JSX.Element => {
34
42
  const dialogRef: RefObject<HTMLDialogElement> = useRef(null)
@@ -43,7 +51,7 @@ const Dialog = ({
43
51
  if (!dialogRef.current) return
44
52
 
45
53
  if (open) {
46
- if (modal) {
54
+ if (modal || fullscreen) {
47
55
  dialogRef.current.showModal()
48
56
  } else {
49
57
  dialogRef.current.show()
@@ -53,26 +61,24 @@ const Dialog = ({
53
61
  }
54
62
  }, [open, dialogRef])
55
63
 
64
+ const values = useMemo(
65
+ () => ({ handleClose, ref: dialogRef, open }),
66
+ [handleClose, dialogRef, open],
67
+ )
68
+
56
69
  return (
57
- <dialog
58
- ref={dialogRef}
59
- onClose={handleClose}
60
- className={classNames("dialog", {
61
- [`dialog--${modifier}`]: modifier,
62
- })}
63
- {...props}
64
- >
65
- <div className="dialog__content vertical-flow">{children}</div>
66
- {actions}
67
- <button
68
- autoFocus
69
- onClick={handleClose}
70
- className="button button--icon-only icon icon--close"
71
- type="button"
70
+ <DialogContext value={values}>
71
+ <dialog
72
+ ref={dialogRef}
73
+ onClose={handleClose}
74
+ className={classNames("mx-dialog", {
75
+ "mx-dialog--fullscreen": fullscreen,
76
+ })}
77
+ {...props}
72
78
  >
73
- Close dialog
74
- </button>
75
- </dialog>
79
+ {children}
80
+ </dialog>
81
+ </DialogContext>
76
82
  )
77
83
  }
78
84
 
@@ -1,36 +1,29 @@
1
1
  // Jest Snapshot v1, https://goo.gl/fbAQLP
2
2
 
3
3
  exports[`Component/Dialog Dialog smoke-test 1`] = `
4
- <dialog class="dialog"
4
+ <dialog class="mx-dialog"
5
5
  open
6
6
  >
7
- <div class="dialog__content vertical-flow">
8
- <h2 class
9
- level="h3"
7
+ <div class="mx-dialog__content mx-vertical-flow">
8
+ <h3 class
10
9
  id="thanks-youre-almost-d"
11
10
  >
12
11
  Thanks, you're almost done!
13
- </h2>
12
+ </h3>
14
13
  <p class>
15
14
  To finish the process, you will need to upload a few more documents. Please have your confirmation email ready before starting. Are you ready?
16
15
  </p>
16
+ <form method="dialog">
17
+ <div class="mx-form-actions">
18
+ <button class="mx-button mx-button--primary"
19
+ type="submit"
20
+ >
21
+ Let's get started
22
+ </button>
23
+ </div>
24
+ </form>
17
25
  </div>
18
- <form>
19
- <div class="form__actions">
20
- <button class="button button--primary"
21
- type="button"
22
- >
23
- Let's get started
24
- </button>
25
- <button class="button"
26
- formmethod="dialog"
27
- type="button"
28
- >
29
- Cancel
30
- </button>
31
- </div>
32
- </form>
33
- <button class="button button--icon-only icon icon--close"
26
+ <button class="mx-button mx-button--icon-only mx-icon mx-icon--close"
34
27
  type="button"
35
28
  >
36
29
  Close dialog
@@ -87,11 +87,3 @@
87
87
  }
88
88
  }
89
89
  }
90
-
91
- /* Prevent scrolling on the body. */
92
- .body--scroll-lock,
93
- .body-dialog--open {
94
- overflow: hidden;
95
- position: fixed;
96
- inline-size: 100vw;
97
- }
@@ -32,24 +32,12 @@ const meta: Meta<HeroBannerType> = {
32
32
  title: "Hero banner title",
33
33
  as: HeadingTypes.ONE,
34
34
  }),
35
- link: Link({
36
- href: "#",
37
- title: "Find out more",
38
- more: true,
39
- }),
40
35
  },
41
36
  argTypes: {
42
37
  modifiers: {
43
38
  options: Object.values(HeroBannerModifier),
44
39
  control: "multi-select",
45
40
  },
46
- // @ts-expect-error The controls follow the shape
47
- "image.src": { control: "text" },
48
- "image.alt": { control: "text" },
49
- "title.title": { control: "text" },
50
- "title.as": { options: Object.values(HeadingTypes), control: "select" },
51
- "link.href": { control: "text" },
52
- "link.title": { control: "text" },
53
41
  },
54
42
  decorators: [Page],
55
43
  }
@@ -59,10 +47,33 @@ type Story = StoryObj<HeroBannerType>
59
47
 
60
48
  export const HeroBanner: Story = {}
61
49
 
50
+ export const Highlight: Story = {
51
+ args: {
52
+ highlight: true,
53
+ modifiers: [HeroBannerModifier.LIGHT],
54
+ link: Link({
55
+ href: "#",
56
+ title: "Find out more",
57
+ more: true,
58
+ }),
59
+ },
60
+ }
61
+
62
+ export const WithoutImage: Story = {
63
+ args: {
64
+ image: null,
65
+ },
66
+ }
67
+
62
68
  export const WithLinkList: Story = {
63
69
  args: {
64
70
  link: null,
65
71
  linkList: LinkList({
72
+ title: Heading({
73
+ title: "Popular links",
74
+ as: HeadingTypes.TWO,
75
+ modifiers: [HeadingTypes.FOUR],
76
+ }),
66
77
  items: [
67
78
  Link({
68
79
  title: "Link one",