Skip to content

Commit 7b2bfe5

Browse files
authored
Skeleton (#49)
1 parent 33642f8 commit 7b2bfe5

File tree

5 files changed

+23
-11
lines changed

5 files changed

+23
-11
lines changed
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1+
import {Skeleton} from '@/components/ui/Skeleton';
12
import {MidiSelectorContainer} from './MidiSelectorContainer';
23

34
export function MidiSelectorSkeleton() {
45
return (
56
<MidiSelectorContainer status='disabled'>
6-
<div className='absolute h-full w-full bg-gray-3 motion-safe:animate-pulse' />
7+
<Skeleton />
78
</MidiSelectorContainer>
89
);
910
}

src/components/ui/InteractionArea.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import clsx from 'clsx';
22
import {type ComponentProps} from 'react';
3+
import {Skeleton} from './Skeleton';
34

45
type DivProps = ComponentProps<'div'>;
56

@@ -24,7 +25,7 @@ export function InteractionArea({icon, title, ...rest}: InteractionAreaProps) {
2425
export function InteractionAreaSkeleton() {
2526
return (
2627
<div className={baseClass}>
27-
<div className='h-full w-full bg-gray-5 motion-safe:animate-pulse' />
28+
<Skeleton />
2829
</div>
2930
);
3031
}

src/components/ui/KnobSkeleton.tsx

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,14 @@
11
import clsx from 'clsx';
2+
import {Skeleton} from './Skeleton';
23

34
type KnobSkeletonProps = {
45
isLarge?: boolean;
56
};
67

78
export function KnobSkeleton({isLarge = false}: KnobSkeletonProps) {
89
return (
9-
<div
10-
className={clsx(
11-
'bg-gray-3 motion-safe:animate-pulse',
12-
isLarge ? 'h-24 w-20' : 'h-20 w-16',
13-
)}
14-
/>
10+
<div className={clsx(isLarge ? 'h-24 w-20' : 'h-20 w-16')}>
11+
<Skeleton />
12+
</div>
1513
);
1614
}

src/components/ui/Meter.tsx

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,20 @@
11
import clsx from 'clsx';
22
import {forwardRef} from 'react';
3+
import {Skeleton} from './Skeleton';
34

45
type CanvasNativeProps = React.ComponentProps<'canvas'>;
56
type MeterProps = Omit<CanvasNativeProps, 'className'>;
67

7-
const baseClass = clsx('absolute h-full w-full bg-gray-3');
8+
const baseClass = clsx('absolute h-full w-full');
89

910
export const Meter = forwardRef<HTMLCanvasElement, MeterProps>((props, ref) => (
10-
<canvas ref={ref} className={baseClass} {...props} />
11+
<canvas ref={ref} className={clsx(baseClass, 'bg-gray-3')} {...props} />
1112
));
1213

1314
export function MeterSkeleton() {
14-
return <div className={clsx(baseClass, 'motion-safe:animate-pulse')} />;
15+
return (
16+
<div className={baseClass}>
17+
<Skeleton />
18+
</div>
19+
);
1520
}

src/components/ui/Skeleton.tsx

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
/**
2+
* Skeleton component with animation.
3+
* Takes up the full width and height of its parent.
4+
*/
5+
export function Skeleton() {
6+
return <div className='h-full w-full bg-gray-3 motion-safe:animate-pulse' />;
7+
}

0 commit comments

Comments
 (0)