Skip to content

Commit 909d356

Browse files
committed
add SfLoaderCircular
1 parent f1ec9fb commit 909d356

File tree

3 files changed

+68
-0
lines changed

3 files changed

+68
-0
lines changed
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
import { component$ } from '@builder.io/qwik';
2+
import { SfLoaderSize } from '../../shared/SfLoader';
3+
import { SfLoaderCircularProps } from './types';
4+
5+
const sizeClasses = {
6+
[SfLoaderSize.xs]: 'h-4 w-4 ring-2',
7+
[SfLoaderSize.sm]: 'h-5 w-5 ring-2',
8+
[SfLoaderSize.base]: 'h-6 w-6 ring-2',
9+
[SfLoaderSize.lg]: 'h-8 w-8 ring-2',
10+
[SfLoaderSize.xl]: 'h-10 w-10 ring-2',
11+
[SfLoaderSize['2xl']]: 'h-14 w-14 ring-[3px]',
12+
[SfLoaderSize['3xl']]: 'h-24 w-24 ring-4',
13+
[SfLoaderSize['4xl']]: 'h-48 w-48 ring-8',
14+
};
15+
16+
const strokeSizeClass = {
17+
[SfLoaderSize.xs]: 'stroke-[10px]',
18+
[SfLoaderSize.sm]: 'stroke-[8px]',
19+
[SfLoaderSize.base]: 'stroke-[6px]',
20+
[SfLoaderSize.lg]: 'stroke-[4px]',
21+
[SfLoaderSize.xl]: 'stroke-[3px]',
22+
[SfLoaderSize['2xl']]: 'stroke-[3px]',
23+
[SfLoaderSize['3xl']]: 'stroke-2',
24+
[SfLoaderSize['4xl']]: 'stroke-2',
25+
};
26+
27+
export const SfLoaderCircular = component$<SfLoaderCircularProps>(
28+
({
29+
size = SfLoaderSize.base,
30+
ariaLabel = 'loading',
31+
class: _class,
32+
...attributes
33+
}) => {
34+
return (
35+
<svg
36+
class={`
37+
inline-block ring-inset ring-neutral-300 text-primary-700 rounded-full animate-spin-slow
38+
${sizeClasses[size]} ${_class}
39+
`}
40+
viewBox="25 25 50 50"
41+
aria-live="polite"
42+
aria-label={ariaLabel}
43+
data-testid="loader-circular"
44+
{...attributes}
45+
>
46+
<circle
47+
class={`
48+
fill-none stroke-2 stroke-current animate-stroke-loader-circular
49+
${strokeSizeClass[size]}
50+
`}
51+
cx="50"
52+
cy="50"
53+
r="24"
54+
/>
55+
</svg>
56+
);
57+
}
58+
);
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
export * from './types';
2+
3+
export { SfLoaderCircular } from './SfLoaderCircular';
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import { SfLoaderSize } from '../../shared/SfLoader';
2+
3+
export type SfLoaderCircularProps = {
4+
class?: string;
5+
size?: `${SfLoaderSize}`;
6+
ariaLabel?: string;
7+
};

0 commit comments

Comments
 (0)