Skip to content

Commit

Permalink
fix(css,react): spinner with multiple colors
Browse files Browse the repository at this point in the history
  • Loading branch information
unekinn committed Oct 30, 2024
1 parent d05c7c4 commit 5bdd46f
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 20 deletions.
15 changes: 3 additions & 12 deletions packages/css/spinner.css
Original file line number Diff line number Diff line change
@@ -1,14 +1,6 @@
.ds-spinner {
--dsc-spinner-background: var(--ds-color-neutral-surface-default);
--dsc-spinner-stroke: var(--ds-color-neutral-border-default);

&[data-color] {
--dsc-spinner-stroke: var(--ds-color-border-default);
}

&[data-color='accent'] {
--dsc-spinner-stroke: var(--ds-color-accent-base-default);
}
--dsc-spinner-background: var(--ds-color-surface-default);
--dsc-spinner-stroke: var(--ds-color-border-default);

--dsc-spinner-animation-duration: 2s;

Expand Down Expand Up @@ -46,6 +38,7 @@

.ds-spinner__background {
stroke: var(--dsc-spinner-background);
/* opacity: 80%; */
}

.ds-spinner__circle {
Expand Down Expand Up @@ -83,12 +76,10 @@ but don't remove it since it is not decorative.
50% {
stroke-dasharray: 100px, 200px;
stroke-dashoffset: -15px;
transform: rotate(0deg);
}

100% {
stroke-dasharray: 1px, 200px;
stroke-dashoffset: -120px;
transform: rotate(15deg);
}
}
3 changes: 1 addition & 2 deletions packages/react/src/components/Button/Button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ export const Button = forwardRef<HTMLButtonElement, ButtonProps>(
ref,
) {
const Component = asChild ? Slot : 'button';
const spinnerColor = color === 'accent' ? color : 'neutral';

// Fallbacks to undefined to prevent rendering attribute="false"
return (
Expand All @@ -73,7 +72,7 @@ export const Button = forwardRef<HTMLButtonElement, ButtonProps>(
{...rest}
>
{loading === true ? (
<Spinner aria-hidden='true' color={spinnerColor} data-size='sm' />
<Spinner aria-hidden='true' data-size='sm' />
) : (
loading // Allow custom loading spinner
)}
Expand Down
7 changes: 1 addition & 6 deletions packages/react/src/components/loaders/Spinner/Spinner.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,7 @@ export type SpinnerProps = {

/** Spinner component used for indicating busy or indeterminate loading */
export const Spinner = forwardRef<SVGSVGElement, SpinnerProps>(function Spinner(
{
'aria-label': ariaLabel,
color = 'neutral',
className,
...rest
}: SpinnerProps,
{ 'aria-label': ariaLabel, color, className, ...rest }: SpinnerProps,
ref,
) {
const svgRef = useSynchronizedAnimation<SVGSVGElement>(
Expand Down

0 comments on commit 5bdd46f

Please sign in to comment.