From 8e7f3b132535a087af0539f5ca54cfb04ad0c7d0 Mon Sep 17 00:00:00 2001 From: Hanbin Cho Date: Thu, 16 Oct 2025 14:26:15 +0900 Subject: [PATCH 1/4] Add loading state in Button in components --- .../src/components/Button/Button.stories.tsx | 7 + .../src/components/Button/IconSpinner.tsx | 96 ++++++++++ .../__snapshots__/index.browser.test.tsx.snap | 172 ++++++++++++++++++ .../Button/__tests__/index.browser.test.tsx | 27 +++ .../src/components/Button/index.tsx | 14 +- 5 files changed, 312 insertions(+), 4 deletions(-) create mode 100644 packages/components/src/components/Button/IconSpinner.tsx 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..a7020b05 --- /dev/null +++ b/packages/components/src/components/Button/IconSpinner.tsx @@ -0,0 +1,96 @@ +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..7761a54f 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,178 @@ 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`] = ` +
+