diff --git a/docs/examples/spinner/dontLabel.tsx b/docs/examples/spinner/dontLabel.tsx index 518e83f9ed..2398c9dbc7 100644 --- a/docs/examples/spinner/dontLabel.tsx +++ b/docs/examples/spinner/dontLabel.tsx @@ -1,12 +1,10 @@ -import { Flex, Spinner, Text } from 'gestalt'; +import { Flex, Spinner } from 'gestalt'; export default function Example() { return ( - - - Loading… + ); diff --git a/docs/examples/spinner/label.tsx b/docs/examples/spinner/label.tsx index 9f43757668..14e91944b8 100644 --- a/docs/examples/spinner/label.tsx +++ b/docs/examples/spinner/label.tsx @@ -5,7 +5,7 @@ export default function Example() { return ( - + ); diff --git a/packages/gestalt/src/Spinner.tsx b/packages/gestalt/src/Spinner.tsx index 92bee42d99..a46429ec53 100644 --- a/packages/gestalt/src/Spinner.tsx +++ b/packages/gestalt/src/Spinner.tsx @@ -1,3 +1,4 @@ +import { useId } from 'react'; import classnames from 'classnames'; import Box from './Box'; import { useDefaultLabelContext } from './contexts/DefaultLabelProvider'; @@ -56,6 +57,7 @@ export default function Spinner({ size = 'md', }: Props) { const { accessibilityLabel: accessibilityLabelDefault } = useDefaultLabelContext('Spinner'); + const id = useId(); const isInVRExperiment = useInExperiment({ webExperimentName: 'web_gestalt_visualRefresh', @@ -69,34 +71,37 @@ export default function Spinner({ // 'subtle' maps to 'default' as it is not a VR color variant color={color === 'subtle' ? 'default' : color} delay={delay} - show={show} + label={label} // 'md' maps to 'lg' as it doesn't exist in VR Spinner + show={show} size={size === 'md' ? 'lg' : size} /> ); } return show ? ( - - -
- -
-
- {label && ( - - - {label} - + + + +
+ +
- )} -
+ {label && ( + + + {label} + + + )} +
{' '} + ) : (
); diff --git a/packages/gestalt/src/Spinner/VRSpinner.tsx b/packages/gestalt/src/Spinner/VRSpinner.tsx index c7cad75b68..7615a12ba8 100644 --- a/packages/gestalt/src/Spinner/VRSpinner.tsx +++ b/packages/gestalt/src/Spinner/VRSpinner.tsx @@ -1,9 +1,11 @@ -import { useEffect, useState } from 'react'; +import { useEffect, useId, useState } from 'react'; import classnames from 'classnames'; import vrLightDesignTokens from 'gestalt-design-tokens/dist/json/vr-theme/variables-light.json'; import styles from './VRSpinner.css'; import Box from '../Box'; import { useDefaultLabelContext } from '../contexts/DefaultLabelProvider'; +import Flex from '../Flex'; +import TextUI from '../TextUI'; const SIZE_NAME_TO_PIXEL = { sm: 32, @@ -11,6 +13,7 @@ const SIZE_NAME_TO_PIXEL = { } as const; type SpinnerBodyProps = { + accessibilityDescribedby?: string; accessibilityLabel: string; delay: boolean; show: boolean; @@ -20,6 +23,7 @@ type SpinnerBodyProps = { }; function SpinnerBody({ + accessibilityDescribedby, accessibilityLabel, delay, show, @@ -39,7 +43,7 @@ function SpinnerBody({ : {}; return ( - +
{ if (!showProp) setShow(false); @@ -108,14 +115,26 @@ export default function Spinner({ if (!show) return null; return ( - + + + + {label && ( + + + {label} + + + )} + + ); } diff --git a/packages/gestalt/src/Text.tsx b/packages/gestalt/src/Text.tsx index cdb1b73129..378ab3b6af 100644 --- a/packages/gestalt/src/Text.tsx +++ b/packages/gestalt/src/Text.tsx @@ -42,6 +42,10 @@ type Props = { * Available for testing purposes, if needed. Consider [better queries](https://testing-library.com/docs/queries/about/#priority) before using this prop. */ dataTestId?: string; + /** + * A unique identifier for the element. + */ + id?: string; /** * Indicates how the text should flow with the surrounding content. See the [block vs inline variant](https://gestalt.pinterest.systems/web/text#Block-vs.-inline) for more details. */ @@ -92,6 +96,7 @@ const TextWithForwardRef = forwardRef(function Text( children, color = 'default', dataTestId, + id, inline = false, italic = false, lineClamp, @@ -170,6 +175,7 @@ const TextWithForwardRef = forwardRef(function Text( (function Text( overflow = 'breakWord', size = 'md', title, + id, }: Props, ref, ): ReactElement { @@ -148,6 +153,7 @@ const TextUIWithForwardRef = forwardRef(function Text( `; exports[`Spinner renders when passed show 1`] = `
- - - +
+
+ + + +
+
+
+
`; exports[`Spinner renders with medium size 1`] = `
- - - +
+
+ + + +
+
+
+
`; exports[`Spinner renders with no delay 1`] = `
- - - +
+
+ + + +
+
+
+ `; exports[`Spinner renders with small size 1`] = `
- - - +
+
+ + + +
+
+
+ `;