diff --git a/.changeset/empty-boats-attack.md b/.changeset/empty-boats-attack.md new file mode 100644 index 00000000000..2235e1dfcac --- /dev/null +++ b/.changeset/empty-boats-attack.md @@ -0,0 +1,5 @@ +--- +"@kaizen/components": minor +--- + +Add `xs` size to LoadingSpinner diff --git a/packages/components/src/Loading/LoadingSpinner/LoadingSpinner.module.css b/packages/components/src/Loading/LoadingSpinner/LoadingSpinner.module.css new file mode 100644 index 00000000000..94ed6d66384 --- /dev/null +++ b/packages/components/src/Loading/LoadingSpinner/LoadingSpinner.module.css @@ -0,0 +1,32 @@ +.loadingSpinner { + --loading-spinner-size: 48px; + + display: flex; + width: var(--loading-spinner-size); + height: var(--loading-spinner-size); +} + +.xs { + --loading-spinner-size: 16px; +} + +.sm { + --loading-spinner-size: 24px; +} + +.md { + --loading-spinner-size: 48px; +} + +.spinner { + animation: spinner var(--animation-duration-deliberate) + var(--animation-easing-function-ease-in-out) infinite; + width: 100%; + height: 100%; +} + +@keyframes spinner { + 100% { + transform: rotate(360deg); + } +} diff --git a/packages/components/src/Loading/LoadingSpinner/LoadingSpinner.module.scss b/packages/components/src/Loading/LoadingSpinner/LoadingSpinner.module.scss deleted file mode 100644 index 0453ceeffb5..00000000000 --- a/packages/components/src/Loading/LoadingSpinner/LoadingSpinner.module.scss +++ /dev/null @@ -1,16 +0,0 @@ -@import "~@kaizen/design-tokens/sass/animation"; - -.loadingSpinner { - display: flex; -} - -.spinner { - animation: spinner $animation-duration-deliberate - $animation-easing-function-ease-in-out infinite; -} - -@keyframes spinner { - 100% { - transform: rotate(360deg); - } -} diff --git a/packages/components/src/Loading/LoadingSpinner/LoadingSpinner.tsx b/packages/components/src/Loading/LoadingSpinner/LoadingSpinner.tsx index f7316015ebe..042703b3d97 100644 --- a/packages/components/src/Loading/LoadingSpinner/LoadingSpinner.tsx +++ b/packages/components/src/Loading/LoadingSpinner/LoadingSpinner.tsx @@ -2,14 +2,15 @@ import React, { HTMLAttributes } from "react" import classnames from "classnames" import { VisuallyHidden } from "~components/VisuallyHidden" import { OverrideClassName } from "~components/types/OverrideClassName" -import styles from "./LoadingSpinner.module.scss" +import { SpinnerIcon } from "./subcomponents" +import styles from "./LoadingSpinner.module.css" export type LoadingSpinnerProps = { accessibilityLabel: string /** - * Generally use "md" unless spinner is inside a form field + * Generally use "md" unless spinner is inside a form field. @default "md" */ - size?: "sm" | "md" + size?: "xs" | "sm" | "md" } & OverrideClassName, "children">> /** @@ -23,61 +24,16 @@ export const LoadingSpinner = ({ ...props }: LoadingSpinnerProps): JSX.Element => (
{accessibilityLabel} - {size === "md" ? ( - - ) : ( - - )} +
) diff --git a/packages/components/src/Loading/LoadingSpinner/_docs/LoadingSpinner.mdx b/packages/components/src/Loading/LoadingSpinner/_docs/LoadingSpinner.mdx index d844a8a1677..d8ca623f94a 100644 --- a/packages/components/src/Loading/LoadingSpinner/_docs/LoadingSpinner.mdx +++ b/packages/components/src/Loading/LoadingSpinner/_docs/LoadingSpinner.mdx @@ -31,12 +31,17 @@ When inside a button, it is intended to have the same color as the label text. ### ClassNameOverride -Override styles such as the colour of the spinner using `classNameOverride`. +Override styles, such as the colour of the spinner using `classNameOverride`. +Below is an example of how to apply the current color tokens used in designs. + + + ### Size -Generally use `"md"` (default value) unless spinner is inside a form field. +Generally use `"md"` (default value) unless spinner is inside a form field, in which case use `sm`. The `xs` size is for buttons or content dense layouts. + diff --git a/packages/components/src/Loading/LoadingSpinner/_docs/LoadingSpinner.stickersheet.stories.tsx b/packages/components/src/Loading/LoadingSpinner/_docs/LoadingSpinner.stickersheet.stories.tsx index f66f6b95d3a..b582cfc8d47 100644 --- a/packages/components/src/Loading/LoadingSpinner/_docs/LoadingSpinner.stickersheet.stories.tsx +++ b/packages/components/src/Loading/LoadingSpinner/_docs/LoadingSpinner.stickersheet.stories.tsx @@ -18,10 +18,11 @@ const StickerSheetTemplate: StickerSheetStory = { render: ({ isReversed }) => ( + ( + <> + + + + + + ), + decorators: [ + Story => ( +
+ +
+ ), + ], +} + export const Size: Story = { render: args => ( <> + diff --git a/packages/components/src/Loading/LoadingSpinner/subcomponents/SpinnerIcon.tsx b/packages/components/src/Loading/LoadingSpinner/subcomponents/SpinnerIcon.tsx new file mode 100644 index 00000000000..e86e6ca61d5 --- /dev/null +++ b/packages/components/src/Loading/LoadingSpinner/subcomponents/SpinnerIcon.tsx @@ -0,0 +1,87 @@ +import React from "react" +import styles from "../LoadingSpinner.module.css" + +const SmallSpinnerIcon = (): JSX.Element => ( + +) + +const MediumSpinnerIcon = (): JSX.Element => ( + +) + +const ExtraSmallSpinnerIcon = (): JSX.Element => ( + + + + +) + +type SpinnerIconProps = { + size: "xs" | "sm" | "md" +} + +export const SpinnerIcon = ({ size }: SpinnerIconProps): JSX.Element => { + if (size === "xs") return + if (size === "sm") return + return +} diff --git a/packages/components/src/Loading/LoadingSpinner/subcomponents/index.ts b/packages/components/src/Loading/LoadingSpinner/subcomponents/index.ts new file mode 100644 index 00000000000..12a89c544bc --- /dev/null +++ b/packages/components/src/Loading/LoadingSpinner/subcomponents/index.ts @@ -0,0 +1 @@ +export * from "./SpinnerIcon" diff --git a/packages/components/src/__actions__/Button/v3/_docs/Button.stickersheet.stories.tsx b/packages/components/src/__actions__/Button/v3/_docs/Button.stickersheet.stories.tsx index dade476f541..0e415a67cd5 100644 --- a/packages/components/src/__actions__/Button/v3/_docs/Button.stickersheet.stories.tsx +++ b/packages/components/src/__actions__/Button/v3/_docs/Button.stickersheet.stories.tsx @@ -82,7 +82,7 @@ const StickerSheetTemplate: StickerSheetStory = {
@@ -93,7 +93,7 @@ const StickerSheetTemplate: StickerSheetStory = {