diff --git a/src/examples/popover/ButtonClosePopover.tsx b/src/examples/popover/ButtonClosePopover.tsx new file mode 100644 index 000000000..8fa94ebbe --- /dev/null +++ b/src/examples/popover/ButtonClosePopover.tsx @@ -0,0 +1,94 @@ +import { Sandbox } from "@components/sandbox"; +import { CodeSnippet } from "@components/code-snippet/CodeSnippet.tsx"; +import { GoabBlock, GoabButton, GoabPopover } from "@abgov/react-components"; +import { LanguageVersionContext } from "@contexts/LanguageVersionContext.tsx"; +import { useContext } from "react"; + +export const ButtonClosePopover = () => { + const { version } = useContext(LanguageVersionContext); + + const popoverTargetWithClose = ( + + Click to open + + ); + + return ( + + {/* React Code Snippets */} + {version === "new" && ( + + Click to open + + ); + `} + /> + )} + + {version === "new" && ( + +

This popover has a close button inside

+

Click the button below to close this popover.

+ + Close Popover + + + `} + /> + )} + + {/* Angular Code Snippets */} + {version === "new" && ( + +

This popover has a close button inside

+

Click the button below to close this popover.

+ + Close Popover + + + + + Click to open + + + + `} + /> + )} + + {/* Sandbox Example */} + + +

This popover has a close button inside

+

Click the button below to close this popover.

+ + Close Popover + +
+
+
+ ); +}; diff --git a/src/examples/popover/IconButtonClosePopover.tsx b/src/examples/popover/IconButtonClosePopover.tsx new file mode 100644 index 000000000..4d75a6053 --- /dev/null +++ b/src/examples/popover/IconButtonClosePopover.tsx @@ -0,0 +1,97 @@ +import { Sandbox } from "@components/sandbox"; +import { CodeSnippet } from "@components/code-snippet/CodeSnippet.tsx"; +import { GoabBlock, GoabButton, GoabIconButton, GoabPopover } from "@abgov/react-components"; +import { LanguageVersionContext } from "@contexts/LanguageVersionContext.tsx"; +import { useContext } from "react"; + +export const IconButtonClosePopover = () => { + const { version } = useContext(LanguageVersionContext); + + const popoverTargetWithClose = ( + + Click to open + + ); + + return ( + + {/* React Code Snippets */} + {version === "new" && ( + + Click to open + + ); + `} + /> + )} + + {version === "new" && ( + + + + +

This popover has a close icon button inside

+

Click the icon button above to close this popover.

+ + `} + /> + )} + + {/* Angular Code Snippets */} + {version === "new" && ( + + + + + +

This popover has a close icon button inside

+

Click the icon button above to close this popover.

+ + + + Click to open (with close icon button) + + + + `} + /> + )} + + {/* Sandbox Example */} + + + + + +

This popover has a close icon button inside

+

Click the icon button above to close this popover.

+
+
+
+ ); +}; diff --git a/src/examples/popover/LinkClosePopover.tsx b/src/examples/popover/LinkClosePopover.tsx new file mode 100644 index 000000000..49d247aab --- /dev/null +++ b/src/examples/popover/LinkClosePopover.tsx @@ -0,0 +1,87 @@ +import { Sandbox } from "@components/sandbox"; +import { CodeSnippet } from "@components/code-snippet/CodeSnippet.tsx"; +import { GoabBlock, GoabButton, GoabLink, GoabPopover } from "@abgov/react-components"; +import { LanguageVersionContext } from "@contexts/LanguageVersionContext.tsx"; +import { useContext } from "react"; + +export const LinkClosePopover = () => { + const { version } = useContext(LanguageVersionContext); + + const popoverTargetWithClose = ( + + Click to open + + ); + + return ( + + {/* React Code Snippets */} + {version === "new" && ( + + Click to open + + ); + `} + /> + )} + + {version === "new" && ( + +

This popover has a close link inside

+

Click the link below to close this popover.

+ + Close Popover + + + `} + /> + )} + + {/* Angular Code Snippets */} + {version === "new" && ( + +

This popover has a close link inside

+

Click the link below to close this popover.

+ + Close Popover + + + + + Click to open + + + + `} + /> + )} + + {/* Sandbox Example */} + + +

This popover has a close link inside

+

Click the link below to close this popover.

+ + Close Popover + +
+
+
+ ); +}; diff --git a/src/examples/popover/PopoverExamples.tsx b/src/examples/popover/PopoverExamples.tsx new file mode 100644 index 000000000..719e77319 --- /dev/null +++ b/src/examples/popover/PopoverExamples.tsx @@ -0,0 +1,34 @@ +import { ButtonClosePopover } from "@examples/popover/ButtonClosePopover"; +import { LinkClosePopover } from "@examples/popover/LinkClosePopover"; +import { IconButtonClosePopover } from "@examples/popover/IconButtonClosePopover"; +import { SandboxHeader } from "@components/sandbox/sandbox-header/sandboxHeader.tsx"; +import { GoabSpacer } from "@abgov/react-components"; +import { OldComponentBanner } from "@components/old-component-banner/OldComponentBanner.tsx"; +import { useContext } from "react"; +import { LanguageVersionContext } from "@contexts/LanguageVersionContext.tsx"; + +export const PopoverExamples = () => { + const { version, language } = useContext(LanguageVersionContext); + return ( + <> + {/*Popover Example - close using a button*/} + + + + {/*Popover example - close using a link*/} + + + + {/*Popover example - close using an icon-button*/} + + + + + {version === "old" && ( + + )} + + ); +}; diff --git a/src/routes/components/Popover.tsx b/src/routes/components/Popover.tsx index f2e254328..33c5f6b9f 100644 --- a/src/routes/components/Popover.tsx +++ b/src/routes/components/Popover.tsx @@ -12,17 +12,20 @@ import { ComponentContent } from "@components/component-content/ComponentContent import { LanguageVersionContext } from "@contexts/LanguageVersionContext.tsx"; import { LegacyMarginProperty, - LegacyTestIdProperties, MarginProperty, - TestIdProperty + LegacyTestIdProperties, + MarginProperty, + TestIdProperty, } from "@components/component-properties/common-properties.ts"; import { DesignEmpty } from "@components/empty-states/design-empty/DesignEmpty.tsx"; import { AccessibilityEmpty } from "@components/empty-states/accessibility-empty/AccessibilityEmpty.tsx"; -import { ExamplesEmpty } from "@components/empty-states/examples-empty/ExamplesEmpty.tsx"; +//import { ExamplesEmpty } from "@components/empty-states/examples-empty/ExamplesEmpty.tsx"; +import { PopoverExamples } from "@examples/popover/PopoverExamples"; -const FIGMA_LINK = "https://www.figma.com/design/3pb2IK8s2QUqWieH79KdN7/%E2%9D%96-Component-library-%7C-DDD?node-id=27301-302109"; +const FIGMA_LINK = + "https://www.figma.com/design/3pb2IK8s2QUqWieH79KdN7/%E2%9D%96-Component-library-%7C-DDD?node-id=27301-302109"; export default function PopoverPage() { - const {version} = useContext(LanguageVersionContext); + const { version } = useContext(LanguageVersionContext); const [popoverProps, setPopoverProps] = useState({}); const [popoverBindings, setPopoverBindings] = useState([ { @@ -119,7 +122,7 @@ export default function PopoverPage() { name: "maxWidth", type: "string", description: "Sets the maximum width of the popover container.", - defaultValue: "320px" + defaultValue: "320px", }, { name: "minWidth", @@ -183,18 +186,20 @@ export default function PopoverPage() { /> - -

Playground

+

+ Playground +

{/*Must be skipRender because Sandbox doesn't support slot target*/} {/*Angular*/} - {version === "old" &&

This is a popover

It can be used for a number of different contexts. @@ -203,13 +208,15 @@ export default function PopoverPage() { `} - />} + /> + )} - {version === "new" &&

This is a popover

It can be used for a number of different contexts. @@ -218,58 +225,67 @@ export default function PopoverPage() { `} - />} + /> + )} {/*React*/} - {version === "old" && Click me ); `} - />} + /> + )} - {version === "new" && Click me ); `} - />} + /> + )} - {version === "old" &&

This is a popover

It can be used for a number of different contexts. `} - />} + /> + )} - {version === "new" &&

This is a popover

It can be used for a number of different contexts. `} - />} + /> + )} Click me - } - > + }>

This is a popover

It can be used for a number of different contexts.
- +
Examples - + - } - > - + }> +