diff --git a/docs/stories/04-components/Loader.stories.tsx b/docs/stories/04-components/Loader.stories.tsx index 34ffa5d27..ff79d5833 100644 --- a/docs/stories/04-components/Loader.stories.tsx +++ b/docs/stories/04-components/Loader.stories.tsx @@ -1,5 +1,5 @@ import { Meta, StoryObj } from '@storybook/react-vite'; -import { Loader } from '@strapi/design-system'; +import { DesignSystemProvider, Loader, extendTheme, lightTheme } from '@strapi/design-system'; import { outdent } from 'outdent'; const meta: Meta = { @@ -38,3 +38,37 @@ export const Small = { }, }, } satisfies Story; + +const customTheme = extendTheme(lightTheme, { + colors: { + primary600: '#ff0000', + }, +}); + +export const CustomThemeColor = { + render: () => ( + + Loading content... + + ), + name: 'custom theme color', + parameters: { + docs: { + description: { + story: + 'The spinner respects the `primary600` theme color. Here `primary600` is overridden to red (`#ff0000`) to verify the fix — without it the spinner would always appear purple.', + }, + source: { + code: outdent` + const customTheme = extendTheme(lightTheme, { + colors: { primary600: '#ff0000' }, + }); + + + Loading content... + + `, + }, + }, + }, +} satisfies Story; diff --git a/packages/design-system/src/components/Loader/Loader.tsx b/packages/design-system/src/components/Loader/Loader.tsx index c71ab812a..72fcc22a1 100644 --- a/packages/design-system/src/components/Loader/Loader.tsx +++ b/packages/design-system/src/components/Loader/Loader.tsx @@ -15,7 +15,7 @@ export const Loader = React.forwardRef(({ children, return (
{children} - +
); }); @@ -29,7 +29,16 @@ const rotation = keyframes` } `; -const LoaderImg = styled.img>>>` +const LoaderImg = styled.div>>>` + width: 63px; + height: 63px; + background-color: ${({ theme }) => theme.colors.primary600}; + mask-image: url(${loaderSvg}); + mask-size: contain; + mask-repeat: no-repeat; + -webkit-mask-image: url(${loaderSvg}); + -webkit-mask-size: contain; + -webkit-mask-repeat: no-repeat; animation: ${rotation} 1s infinite linear; will-change: transform; ${({ $small, theme }) => $small && `width: ${theme.spaces[6]}; height: ${theme.spaces[6]};`}