diff --git a/packages/core/sds/src/components/Button/Button.tsx b/packages/core/sds/src/components/Button/Button.tsx index 0dc8b7e6..9540f1c7 100644 --- a/packages/core/sds/src/components/Button/Button.tsx +++ b/packages/core/sds/src/components/Button/Button.tsx @@ -1,12 +1,22 @@ import { ButtonHTMLAttributes, forwardRef, ReactNode } from 'react'; -import { buttonCss, buttonDisabledVariants, buttonSizeVariants, buttonVariantVariants, leftDecorCss } from './styles'; +import { Spinner } from '../Spinner/Spinner'; + +import { + buttonCss, + buttonDisabledVariants, + buttonSizeVariants, + buttonVariantVariants, + leftDecorCss, + spinnerCss, +} from './styles'; import { ButtonSize, ButtonVariant } from './types'; export interface ButtonProps extends ButtonHTMLAttributes { size?: ButtonSize; variant?: ButtonVariant; leftDecor?: ReactNode; + loading?: boolean; } export const Button = forwardRef((props, ref) => { @@ -16,6 +26,7 @@ export const Button = forwardRef((props, ref) => disabled = false, style: styleFromProps, leftDecor, + loading = false, children, ...restProps } = props; @@ -29,8 +40,9 @@ export const Button = forwardRef((props, ref) => return ( ); }); diff --git a/packages/core/sds/src/components/Button/styles.ts b/packages/core/sds/src/components/Button/styles.ts index 0c4e9d77..a3b90b83 100644 --- a/packages/core/sds/src/components/Button/styles.ts +++ b/packages/core/sds/src/components/Button/styles.ts @@ -112,3 +112,9 @@ export const leftDecorCss = css({ fill: `var(${buttonColorVar})`, }, }); + +export const spinnerCss = css({ + '& path': { + fill: `var(${buttonColorVar})`, + }, +}); diff --git a/packages/core/sds/src/components/Spinner/Spinner.tsx b/packages/core/sds/src/components/Spinner/Spinner.tsx new file mode 100644 index 00000000..d60fd461 --- /dev/null +++ b/packages/core/sds/src/components/Spinner/Spinner.tsx @@ -0,0 +1,34 @@ +import { forwardRef, HTMLAttributes } from 'react'; + +import { spinnerAnimationCss } from './styles.ts'; + +export interface SpinnerProps extends HTMLAttributes { + size?: number; + color?: string; +} + +export const Spinner = forwardRef((props, ref) => { + const { size = 20, color = '#8E8E8E', ...rest } = props; + + return ( + + + + ); +}); + +Spinner.displayName = 'Spinner'; diff --git a/packages/core/sds/src/components/Spinner/index.ts b/packages/core/sds/src/components/Spinner/index.ts new file mode 100644 index 00000000..b1a1e650 --- /dev/null +++ b/packages/core/sds/src/components/Spinner/index.ts @@ -0,0 +1,3 @@ +export { Spinner } from './Spinner'; + +export type { SpinnerProps } from './Spinner'; diff --git a/packages/core/sds/src/components/Spinner/styles.ts b/packages/core/sds/src/components/Spinner/styles.ts new file mode 100644 index 00000000..58161cc0 --- /dev/null +++ b/packages/core/sds/src/components/Spinner/styles.ts @@ -0,0 +1,11 @@ +import { keyframes } from '@emotion/react'; + +const rotate = keyframes` + 100% { + transform: rotate(360deg); + } +`; + +export const spinnerAnimationCss = { + animation: `${rotate} 0.8s linear infinite`, +}; diff --git a/packages/core/sds/src/components/index.ts b/packages/core/sds/src/components/index.ts index 35e50f8a..12632542 100644 --- a/packages/core/sds/src/components/index.ts +++ b/packages/core/sds/src/components/index.ts @@ -1,10 +1,11 @@ -export * from './Typography'; -export * from './Icon'; -export * from './Button'; -export * from './TextButton'; -export * from './Badge'; -export * from './SegmentedControl'; export * from './Accordion'; +export * from './Badge'; +export * from './Button'; +export * from './Checkbox'; +export * from './Icon'; export * from './Loader'; +export * from './SegmentedControl'; export * from './Skeleton'; -export * from './Checkbox'; +export * from './Spinner'; +export * from './TextButton'; +export * from './Typography';