Skip to content

Commit

Permalink
Merge pull request #14 from holaplex/anshul/spinner-update
Browse files Browse the repository at this point in the history
Spinner variants update
  • Loading branch information
alchemistgo87 authored Mar 29, 2023
2 parents f1c4619 + 1c5ca97 commit 291eb90
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 31 deletions.
6 changes: 5 additions & 1 deletion packages/@holaplexui-playground/pages/buttons.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,13 @@ export default function App() {
With Icon
</Button>

<Button spinner={<div>🔄</div>} border='rounded' loading>
<Button border='rounded' loading>
With Spinner
</Button>

<Button spinner={<div>🔄</div>} border='rounded' loading>
With Custom Spinner
</Button>
</div>
</div>
);
Expand Down
14 changes: 10 additions & 4 deletions packages/@holaplexui-playground/styles/globals.css
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,16 @@ a {
text-decoration: none;
}

.spinner-border {
vertical-align: -0.125em;
border: solid currentColor;
border-right-color: transparent;
.spinner {
@apply inline-block h-4 w-4 animate-spin rounded-full border-2 border-solid border-r-transparent border-current align-[-0.125em];
}

.spinner-primary {
@apply border-white border-r-transparent;
}

.spinner-secondary {
@apply border-black border-r-transparent;
}

.form-label {
Expand Down
2 changes: 1 addition & 1 deletion packages/@holaplexui-react/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@holaplex/ui-library-react",
"author": "Holaplex Inc.",
"version": "0.14.0",
"version": "0.15.0",
"description": "Holaplex react ui library components",
"private": false,
"files": [
Expand Down
21 changes: 8 additions & 13 deletions packages/@holaplexui-react/src/components/Button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,20 +46,20 @@ export const Button = ({
}
}, [size]);

const spinnerColor = useMemo(() => {
const spinnerVariant = useMemo(() => {
switch (variant) {
case 'primary':
return '#17161C';
return 'spinner-primary';
case 'secondary':
return '#bfbfc3';
return 'spinner-secondary';
case 'success':
return '#ffffff';
return 'spinner-success';
case 'failure':
return '#ffffff';
return 'spinner-failure';
case 'link':
return '#1f75cb';
return 'spinner-link';
default:
return '#ffffff';
return 'spinner-primary';
}
}, [variant]);

Expand Down Expand Up @@ -116,12 +116,7 @@ export const Button = ({
(spinner ? (
spinner
) : (
<Spinner
height={spinnerSize}
width={spinnerSize}
color={spinnerColor}
className="inline aspect-square"
/>
<Spinner variant={spinnerVariant} className="inline aspect-square" />
))}
{icon && icon}
{children && <span>{children}</span>}
Expand Down
15 changes: 3 additions & 12 deletions packages/@holaplexui-react/src/components/Spinner.tsx
Original file line number Diff line number Diff line change
@@ -1,23 +1,14 @@
import clsx from 'clsx';

interface SpinnerProps {
color?: string;
height?: string | number;
width?: string | number;
variant?: string;
className?: string;
}

export const Spinner = ({ color, height, width, className }: SpinnerProps): JSX.Element => {
export const Spinner = ({ variant, className }: SpinnerProps): JSX.Element => {
return (
<div className="flex items-center justify-center">
<div
className={clsx(clsx, className, 'spinner-border inline-block animate-spin rounded-full')}
style={{
width: width || 32,
height: height || 32,
color: color,
}}
></div>
<div className={clsx(clsx, className, variant, 'spinner')}></div>
</div>
);
};

0 comments on commit 291eb90

Please sign in to comment.