From 91ee30858298fb170da8a00c8c85a97f609787a5 Mon Sep 17 00:00:00 2001 From: syedszeeshan <47701214+syedszeeshan@users.noreply.github.com> Date: Mon, 16 Jun 2025 19:59:10 -0400 Subject: [PATCH 1/2] fix(#2714): docs popover examples --- src/examples/popover/ButtonClosePopover.tsx | 94 ++++++++++++++ .../popover/IconButtonClosePopover.tsx | 91 ++++++++++++++ src/examples/popover/LinkClosePopover.tsx | 87 +++++++++++++ src/examples/popover/PopoverExamples.tsx | 24 ++++ src/routes/components/Popover.tsx | 119 ++++++++++-------- 5 files changed, 364 insertions(+), 51 deletions(-) create mode 100644 src/examples/popover/ButtonClosePopover.tsx create mode 100644 src/examples/popover/IconButtonClosePopover.tsx create mode 100644 src/examples/popover/LinkClosePopover.tsx create mode 100644 src/examples/popover/PopoverExamples.tsx 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..d5c210ab0 --- /dev/null +++ b/src/examples/popover/IconButtonClosePopover.tsx @@ -0,0 +1,91 @@ +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 below to close this popover.

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

This popover has a close icon button inside

+

Click the icon button below 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..4e4882496 --- /dev/null +++ b/src/examples/popover/PopoverExamples.tsx @@ -0,0 +1,24 @@ +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"; + +export const PopoverExamples = () => { + return ( + <> + {/*Popover Example - close using a button*/} + + + + {/*Popover example - close using a link*/} + + + + {/*Popover example - close using an icon-button*/} + + + + ); +}; 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 - + - } - > - + }> + From 0e2a74814035ce04ad4a50429d2cd8463189ae30 Mon Sep 17 00:00:00 2001 From: syedszeeshan <47701214+syedszeeshan@users.noreply.github.com> Date: Tue, 24 Jun 2025 12:57:20 -0400 Subject: [PATCH 2/2] fix(#2714): docs popover examples --- .../popover/IconButtonClosePopover.tsx | 36 +++++++++++-------- src/examples/popover/PopoverExamples.tsx | 16 +++++++-- 2 files changed, 34 insertions(+), 18 deletions(-) diff --git a/src/examples/popover/IconButtonClosePopover.tsx b/src/examples/popover/IconButtonClosePopover.tsx index d5c210ab0..4d75a6053 100644 --- a/src/examples/popover/IconButtonClosePopover.tsx +++ b/src/examples/popover/IconButtonClosePopover.tsx @@ -38,14 +38,16 @@ export const IconButtonClosePopover = () => { allowCopy={true} code={` + + +

This popover has a close icon button inside

-

Click the icon button below to close this popover.

- +

Click the icon button above to close this popover.

`} /> @@ -59,14 +61,16 @@ export const IconButtonClosePopover = () => { allowCopy={true} code={` + + + +

This popover has a close icon button inside

-

Click the icon button below to close this popover.

- - +

Click the icon button above to close this popover.

@@ -81,7 +85,9 @@ export const IconButtonClosePopover = () => { {/* 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/PopoverExamples.tsx b/src/examples/popover/PopoverExamples.tsx index 4e4882496..719e77319 100644 --- a/src/examples/popover/PopoverExamples.tsx +++ b/src/examples/popover/PopoverExamples.tsx @@ -2,23 +2,33 @@ 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" && ( + + )} ); };