diff --git a/.changeset/vast-plums-fetch.md b/.changeset/vast-plums-fetch.md new file mode 100644 index 00000000..6b4479f5 --- /dev/null +++ b/.changeset/vast-plums-fetch.md @@ -0,0 +1,5 @@ +--- +'@devup-ui/components': patch +--- + +add loading prop in Button in @devup-ui/components diff --git a/packages/components/src/components/Button/Button.stories.tsx b/packages/components/src/components/Button/Button.stories.tsx index c4afa0f2..3b08e89e 100644 --- a/packages/components/src/components/Button/Button.stories.tsx +++ b/packages/components/src/components/Button/Button.stories.tsx @@ -108,4 +108,11 @@ export const WithForm: Story = { ], } +export const WithLoading: Story = { + args: { + children: 'Submit', + loading: true, + }, +} + export default meta diff --git a/packages/components/src/components/Button/IconSpinner.tsx b/packages/components/src/components/Button/IconSpinner.tsx new file mode 100644 index 00000000..b372ba4a --- /dev/null +++ b/packages/components/src/components/Button/IconSpinner.tsx @@ -0,0 +1,90 @@ +import { Box, keyframes } from '@devup-ui/react' +import { SVGProps } from 'react' + +const spin = keyframes({ + '0%': { + transform: 'rotateZ(0deg)', + }, + '100%': { + transform: 'rotateZ(360deg)', + }, +}) + +interface IconSpinnerProps extends SVGProps { + type?: 'whole' | 'partial' +} + +export function IconSpinner({ type = 'whole', ...props }: IconSpinnerProps) { + if (type === 'partial') { + return ( + + + + ) + } + return ( + + + + +
+
+
+
+ + + + + + +
+ ) +} diff --git a/packages/components/src/components/Button/__tests__/__snapshots__/index.browser.test.tsx.snap b/packages/components/src/components/Button/__tests__/__snapshots__/index.browser.test.tsx.snap index e2cb1745..768b1bc6 100644 --- a/packages/components/src/components/Button/__tests__/__snapshots__/index.browser.test.tsx.snap +++ b/packages/components/src/components/Button/__tests__/__snapshots__/index.browser.test.tsx.snap @@ -325,6 +325,174 @@ exports[`Button > should render icon when icon is provided 1`] = ` `; +exports[`Button > should render loading spinner when icon is provided and loading is true 1`] = ` +
+