From 29bde92912df33aac95b3ebad93eccdc7459ecd8 Mon Sep 17 00:00:00 2001 From: miguel-soco_goa Date: Tue, 17 Dec 2024 11:52:58 -0700 Subject: [PATCH 1/3] chore(#2125): tooltip - add in contextual example --- src/routes/components/Tooltip.tsx | 172 +++++++++++++++++++++++++++++- 1 file changed, 170 insertions(+), 2 deletions(-) diff --git a/src/routes/components/Tooltip.tsx b/src/routes/components/Tooltip.tsx index 117a9ca3f..14d0adecd 100644 --- a/src/routes/components/Tooltip.tsx +++ b/src/routes/components/Tooltip.tsx @@ -1,6 +1,7 @@ import { Category, ComponentHeader } from "@components/component-header/ComponentHeader.tsx"; -import { ComponentBinding, Sandbox } from "@components/sandbox"; -import { useState } from "react"; +import { ComponentBinding, Sandbox, DesignTokensLanguageContext } from "@components/sandbox"; +import { getCssVarValue } from "../../utils/styling"; +import { useState, useContext } from "react"; import { ComponentProperties, ComponentProperty, @@ -9,11 +10,16 @@ import { import { GoAIcon, GoABadge, + GoABlock, + GoAButtonGroup, + GoAContainer, + GoAIconButton, GoATab, GoATabs, GoATooltip, GoATooltipProps, } from "@abgov/react-components"; +import { CodeSnippet } from "@components/code-snippet/CodeSnippet.tsx"; import { ComponentContent } from "@components/component-content/ComponentContent"; // == Page props == @@ -90,6 +96,17 @@ export default function TEMPLATE_Page() { setComponentProps(props as CastingType); } + const [isCopied, setIsCopied] = useState(false); + const lang = useContext(DesignTokensLanguageContext); + + function copyCode() { + let codeToCopy = lang === "css" ? `--$goa-color-interactive-default` : `$$goa-color-interactive-default`; + navigator.clipboard.writeText(codeToCopy).then(() => { + setIsCopied(true); + setTimeout(() => setIsCopied(false), 1000); + }); + } + return ( <> + + + +

Use a tooltip to show a full date when shortened

+ + +
+ Joan Smith + + 4 hours ago + +
+

Hover on the time it was added to see the full date and time.

+ + `} + /> + Joan Smith 4 hours ago }> +

Hover on the time it was added to see the full date and time.

+ + `} + /> + + Joan Smith + + 4 hours ago + + }> +

Hover on the time it was added to see the full date and time.

+
+
+ +

Show a label on an icon only button

+ + + + + + + + + + + + + + +

Click to copy something to your clipboard

+ + a > span { + margin-top: 5px; + margin-left: 10px; + } + `} + /> + { + setIsCopied(true); + setTimeout(() => setIsCopied(false), 1000); + }); + } + `} + /> + +
+ + + `} + /> + +
+ + + Date: Wed, 18 Dec 2024 12:02:04 -0700 Subject: [PATCH 2/3] chore(#2125): tooltip - adjust contextual example --- src/routes/components/Tooltip.tsx | 94 +++++++++++++++++++------------ 1 file changed, 57 insertions(+), 37 deletions(-) diff --git a/src/routes/components/Tooltip.tsx b/src/routes/components/Tooltip.tsx index 14d0adecd..bce3da5cb 100644 --- a/src/routes/components/Tooltip.tsx +++ b/src/routes/components/Tooltip.tsx @@ -97,10 +97,9 @@ export default function TEMPLATE_Page() { } const [isCopied, setIsCopied] = useState(false); - const lang = useContext(DesignTokensLanguageContext); function copyCode() { - let codeToCopy = lang === "css" ? `--$goa-color-interactive-default` : `$$goa-color-interactive-default`; + const codeToCopy = "$goa-color-interactive-default"; navigator.clipboard.writeText(codeToCopy).then(() => { setIsCopied(true); setTimeout(() => setIsCopied(false), 1000); @@ -143,7 +142,7 @@ export default function TEMPLATE_Page() {
Joan Smith - 4 hours ago + 4 hours ago

Hover on the time it was added to see the full date and time.

@@ -158,7 +157,18 @@ export default function TEMPLATE_Page() { Joan Smith 4 hours ago }> + heading={ + + Joan Smith + + + 4 hours ago + + + + }>

Hover on the time it was added to see the full date and time.

`} @@ -204,23 +214,49 @@ export default function TEMPLATE_Page() { width: 24px; border-radius: var(--goa-border-radius-m); } + `} + /> + a > span { - margin-top: 5px; - margin-left: 10px; + copyCode() { + const codeToCopy = "$goa-color-interactive-default"; + navigator.clipboard.writeText(codeToCopy).then(() => { + this.isCopied = true; + setTimeout(() => this.isCopied = false, 1000); + }); } `} /> + +
+ + $goa-color-interactive-default + + + + + + `} + /> { setIsCopied(true); setTimeout(() => setIsCopied(false), 1000); @@ -235,20 +271,12 @@ export default function TEMPLATE_Page() { code={`
- + + $goa-color-interactive-default + + + + `} /> @@ -262,20 +290,12 @@ export default function TEMPLATE_Page() { borderRadius: getCssVarValue('--goa-border-radius-m') }} /> - + + $goa-color-interactive-default + + + + From 244b89dea459d6294230cc25726a6155bd1d51fd Mon Sep 17 00:00:00 2001 From: miguel-soco_goa Date: Wed, 18 Dec 2024 14:56:19 -0700 Subject: [PATCH 3/3] chore(#2125): tooltip - fix errors --- src/routes/components/Tooltip.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/routes/components/Tooltip.tsx b/src/routes/components/Tooltip.tsx index bce3da5cb..81800cf94 100644 --- a/src/routes/components/Tooltip.tsx +++ b/src/routes/components/Tooltip.tsx @@ -1,7 +1,7 @@ import { Category, ComponentHeader } from "@components/component-header/ComponentHeader.tsx"; -import { ComponentBinding, Sandbox, DesignTokensLanguageContext } from "@components/sandbox"; +import { ComponentBinding, Sandbox } from "@components/sandbox"; import { getCssVarValue } from "../../utils/styling"; -import { useState, useContext } from "react"; +import { useState } from "react"; import { ComponentProperties, ComponentProperty,