Switch to custom spinner with color tweaks
This commit is contained in:
parent
838fd24033
commit
f36e1def5f
@ -30,7 +30,6 @@
|
|||||||
"react": "18.2.0",
|
"react": "18.2.0",
|
||||||
"react-dom": "18.2.0",
|
"react-dom": "18.2.0",
|
||||||
"react-icons": "^4.11.0",
|
"react-icons": "^4.11.0",
|
||||||
"react-spinners": "^0.13.8",
|
|
||||||
"short-uuid": "^4.2.2",
|
"short-uuid": "^4.2.2",
|
||||||
"sonner": "^0.7.1",
|
"sonner": "^0.7.1",
|
||||||
"tailwindcss": "3.3.3",
|
"tailwindcss": "3.3.3",
|
||||||
|
|||||||
12
pnpm-lock.yaml
generated
12
pnpm-lock.yaml
generated
@ -24,7 +24,6 @@ specifiers:
|
|||||||
react: 18.2.0
|
react: 18.2.0
|
||||||
react-dom: 18.2.0
|
react-dom: 18.2.0
|
||||||
react-icons: ^4.11.0
|
react-icons: ^4.11.0
|
||||||
react-spinners: ^0.13.8
|
|
||||||
short-uuid: ^4.2.2
|
short-uuid: ^4.2.2
|
||||||
sonner: ^0.7.1
|
sonner: ^0.7.1
|
||||||
tailwindcss: 3.3.3
|
tailwindcss: 3.3.3
|
||||||
@ -55,7 +54,6 @@ dependencies:
|
|||||||
react: 18.2.0
|
react: 18.2.0
|
||||||
react-dom: 18.2.0_react@18.2.0
|
react-dom: 18.2.0_react@18.2.0
|
||||||
react-icons: 4.11.0_react@18.2.0
|
react-icons: 4.11.0_react@18.2.0
|
||||||
react-spinners: 0.13.8_biqbaboplfbrettd7655fr4n2y
|
|
||||||
short-uuid: 4.2.2
|
short-uuid: 4.2.2
|
||||||
sonner: 0.7.1_biqbaboplfbrettd7655fr4n2y
|
sonner: 0.7.1_biqbaboplfbrettd7655fr4n2y
|
||||||
tailwindcss: 3.3.3
|
tailwindcss: 3.3.3
|
||||||
@ -2983,16 +2981,6 @@ packages:
|
|||||||
resolution: {integrity: sha512-xWGDIW6x921xtzPkhiULtthJHoJvBbF3q26fzloPCK0hsvxtPVelvftw3zjbHWSkR2km9Z+4uxbDDK/6Zw9B8w==}
|
resolution: {integrity: sha512-xWGDIW6x921xtzPkhiULtthJHoJvBbF3q26fzloPCK0hsvxtPVelvftw3zjbHWSkR2km9Z+4uxbDDK/6Zw9B8w==}
|
||||||
dev: false
|
dev: false
|
||||||
|
|
||||||
/react-spinners/0.13.8_biqbaboplfbrettd7655fr4n2y:
|
|
||||||
resolution: {integrity: sha512-3e+k56lUkPj0vb5NDXPVFAOkPC//XyhKPJjvcGjyMNPWsBKpplfeyialP74G7H7+It7KzhtET+MvGqbKgAqpZA==}
|
|
||||||
peerDependencies:
|
|
||||||
react: ^16.0.0 || ^17.0.0 || ^18.0.0
|
|
||||||
react-dom: ^16.0.0 || ^17.0.0 || ^18.0.0
|
|
||||||
dependencies:
|
|
||||||
react: 18.2.0
|
|
||||||
react-dom: 18.2.0_react@18.2.0
|
|
||||||
dev: false
|
|
||||||
|
|
||||||
/react/18.2.0:
|
/react/18.2.0:
|
||||||
resolution: {integrity: sha512-/3IjMdb2L9QbBdWiW5e3P2/npwMBaU9mHCSCUzNln0ZCYbcfTsGbTJrU/kGemdH2IWmB2ioZ+zkxtmq6g09fGQ==}
|
resolution: {integrity: sha512-/3IjMdb2L9QbBdWiW5e3P2/npwMBaU9mHCSCUzNln0ZCYbcfTsGbTJrU/kGemdH2IWmB2ioZ+zkxtmq6g09fGQ==}
|
||||||
engines: {node: '>=0.10.0'}
|
engines: {node: '>=0.10.0'}
|
||||||
|
|||||||
@ -1,18 +1,22 @@
|
|||||||
'use client';
|
'use client';
|
||||||
|
|
||||||
import { cc } from '@/utility/css';
|
import { cc } from '@/utility/css';
|
||||||
import Spinner from './Spinner';
|
import Spinner, { SpinnerColor } from './Spinner';
|
||||||
|
|
||||||
export default function IconButton({
|
export default function IconButton({
|
||||||
children,
|
children,
|
||||||
onClick,
|
onClick,
|
||||||
isLoading,
|
isLoading,
|
||||||
className,
|
className,
|
||||||
|
spinnerColor,
|
||||||
|
spinnerSize,
|
||||||
}: {
|
}: {
|
||||||
children: React.ReactNode
|
children: React.ReactNode
|
||||||
onClick?: () => void
|
onClick?: () => void
|
||||||
isLoading?: boolean
|
isLoading?: boolean
|
||||||
className?: string
|
className?: string
|
||||||
|
spinnerColor?: SpinnerColor
|
||||||
|
spinnerSize?: number
|
||||||
}) {
|
}) {
|
||||||
return (
|
return (
|
||||||
<span className={cc(
|
<span className={cc(
|
||||||
@ -33,7 +37,10 @@ export default function IconButton({
|
|||||||
: <span className={cc(
|
: <span className={cc(
|
||||||
'inline-block translate-y-[1.5px]',
|
'inline-block translate-y-[1.5px]',
|
||||||
)}>
|
)}>
|
||||||
<Spinner size={12} />
|
<Spinner
|
||||||
|
color={spinnerColor}
|
||||||
|
size={spinnerSize}
|
||||||
|
/>
|
||||||
</span>}
|
</span>}
|
||||||
</span>
|
</span>
|
||||||
);
|
);
|
||||||
|
|||||||
@ -1,21 +1,40 @@
|
|||||||
import { ClipLoader } from 'react-spinners';
|
const SIZE_DEFAULT = 12;
|
||||||
import resolveConfig from 'tailwindcss/resolveConfig';
|
|
||||||
import myConfig from '../../tailwind.config.js';
|
|
||||||
|
|
||||||
const TAILWIND_COLORS = resolveConfig(myConfig).theme?.colors as any;
|
export type SpinnerColor = 'text' | 'light-gray';
|
||||||
|
|
||||||
export default function Spinner({
|
export default function Spinner({
|
||||||
size = 35,
|
size = SIZE_DEFAULT,
|
||||||
className,
|
color = 'light-gray',
|
||||||
}: {
|
}: {
|
||||||
size?: number
|
size?: number
|
||||||
className?: string
|
color?: SpinnerColor
|
||||||
}) {
|
}) {
|
||||||
return (
|
return (
|
||||||
<ClipLoader {...{
|
<span {...{
|
||||||
size,
|
...color === 'light-gray' && {
|
||||||
className,
|
className: 'text-gray-300 dark:text-gray-600',
|
||||||
color: TAILWIND_COLORS.gray[300],
|
},
|
||||||
}} />
|
style: {
|
||||||
|
display: 'inline-flex',
|
||||||
|
width: size,
|
||||||
|
height: size,
|
||||||
|
},
|
||||||
|
}}>
|
||||||
|
<svg
|
||||||
|
width={size}
|
||||||
|
height={size}
|
||||||
|
viewBox="0 0 12 12"
|
||||||
|
fill="none"
|
||||||
|
stroke="currentColor"
|
||||||
|
stroke-width={SIZE_DEFAULT / size * 2}
|
||||||
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
|
className="animate-rotate-pulse"
|
||||||
|
>
|
||||||
|
<path
|
||||||
|
// eslint-disable-next-line max-len
|
||||||
|
d="M11 6C11 3.23858 8.76142 1 6 1C3.23858 1 1 3.23858 1 6C1 8.76142 3.23858 11 6 11"
|
||||||
|
/>
|
||||||
|
</svg>
|
||||||
|
</span>
|
||||||
);
|
);
|
||||||
};
|
}
|
||||||
|
|||||||
@ -24,7 +24,7 @@ export default function SubmitButtonWithStatus(props: Props) {
|
|||||||
return (
|
return (
|
||||||
<button
|
<button
|
||||||
type="submit"
|
type="submit"
|
||||||
disabled={disabled || pending}
|
disabled={disabled}
|
||||||
className={cc(
|
className={cc(
|
||||||
className,
|
className,
|
||||||
'inline-flex items-center gap-2',
|
'inline-flex items-center gap-2',
|
||||||
|
|||||||
@ -9,9 +9,9 @@ import {
|
|||||||
import { cc } from '@/utility/css';
|
import { cc } from '@/utility/css';
|
||||||
import Link from 'next/link';
|
import Link from 'next/link';
|
||||||
import { BiError } from 'react-icons/bi';
|
import { BiError } from 'react-icons/bi';
|
||||||
import Spinner from '@/components/Spinner';
|
|
||||||
import { IMAGE_OG_HEIGHT, IMAGE_OG_RATIO, IMAGE_OG_WIDTH } from '@/site';
|
import { IMAGE_OG_HEIGHT, IMAGE_OG_RATIO, IMAGE_OG_WIDTH } from '@/site';
|
||||||
import { absoluteRouteForPhotoImage, routeForPhoto } from '@/site/routes';
|
import { absoluteRouteForPhotoImage, routeForPhoto } from '@/site/routes';
|
||||||
|
import Spinner from '@/components/Spinner';
|
||||||
|
|
||||||
export type OGLoadingState = 'unloaded' | 'loading' | 'loaded' | 'failed';
|
export type OGLoadingState = 'unloaded' | 'loading' | 'loaded' | 'failed';
|
||||||
|
|
||||||
@ -64,7 +64,7 @@ export default function PhotoOGTile({
|
|||||||
'absolute top-0 left-0 right-0 bottom-0 z-10',
|
'absolute top-0 left-0 right-0 bottom-0 z-10',
|
||||||
'flex items-center justify-center',
|
'flex items-center justify-center',
|
||||||
)}>
|
)}>
|
||||||
<Spinner />
|
<Spinner size={40} />
|
||||||
</div>}
|
</div>}
|
||||||
{loadingState === 'failed' &&
|
{loadingState === 'failed' &&
|
||||||
<div className={cc(
|
<div className={cc(
|
||||||
|
|||||||
@ -38,6 +38,7 @@ export default function SharePhotoButton({
|
|||||||
'text-gray-500 active:text-gray-600',
|
'text-gray-500 active:text-gray-600',
|
||||||
'dark:text-gray-400 dark:active:text-gray-300',
|
'dark:text-gray-400 dark:active:text-gray-300',
|
||||||
)}
|
)}
|
||||||
|
spinnerColor="text"
|
||||||
>
|
>
|
||||||
<TbPhotoShare size={17} />
|
<TbPhotoShare size={17} />
|
||||||
</IconButton>
|
</IconButton>
|
||||||
|
|||||||
@ -153,6 +153,7 @@ export default function SiteChecklistClient({
|
|||||||
<IconButton
|
<IconButton
|
||||||
onClick={refreshSecret}
|
onClick={refreshSecret}
|
||||||
isLoading={isPendingSecret}
|
isLoading={isPendingSecret}
|
||||||
|
spinnerColor="text"
|
||||||
>
|
>
|
||||||
<BiRefresh size={18} />
|
<BiRefresh size={18} />
|
||||||
</IconButton>
|
</IconButton>
|
||||||
|
|||||||
@ -24,6 +24,17 @@ module.exports = {
|
|||||||
fontFamily: {
|
fontFamily: {
|
||||||
'mono': ['var(--font-ibm-plex-mono)', ...defaultTheme.fontFamily.mono],
|
'mono': ['var(--font-ibm-plex-mono)', ...defaultTheme.fontFamily.mono],
|
||||||
},
|
},
|
||||||
|
animation: {
|
||||||
|
'rotate-pulse':
|
||||||
|
'rotate-pulse 0.75s linear infinite normal both running',
|
||||||
|
},
|
||||||
|
keyframes: {
|
||||||
|
'rotate-pulse': {
|
||||||
|
'0%': { rotate: '0deg', scale: '1' },
|
||||||
|
'50%': { rotate: '180deg', scale: '0.8' },
|
||||||
|
'100%': { rotate: '360deg', scale: '1' },
|
||||||
|
},
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
plugins: [
|
plugins: [
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user