Skip to content

Commit 04dbe1d

Browse files
committed
add SfLoaderLinear
1 parent 909d356 commit 04dbe1d

File tree

3 files changed

+52
-0
lines changed

3 files changed

+52
-0
lines changed
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
import { component$ } from '@builder.io/qwik';
2+
import { SfLoaderLinearProps, SfLoaderLinearSize } from './types';
3+
import { SfLoaderSize } from '../../shared/SfLoader';
4+
5+
const sizeClasses = {
6+
[SfLoaderLinearSize.minimal]: 'h-1',
7+
[SfLoaderSize.xs]: 'h-4',
8+
[SfLoaderSize.sm]: 'h-5',
9+
[SfLoaderSize.base]: 'h-6',
10+
[SfLoaderSize.lg]: 'h-7',
11+
[SfLoaderSize.xl]: 'h-10',
12+
[SfLoaderSize['2xl']]: 'h-14',
13+
[SfLoaderSize['3xl']]: 'h-24',
14+
[SfLoaderSize['4xl']]: 'h-48',
15+
};
16+
17+
export const SfLoaderLinear = component$<SfLoaderLinearProps>(
18+
({
19+
size = SfLoaderSize.base,
20+
ariaLabel = 'loading',
21+
class: _class,
22+
...attributes
23+
}) => {
24+
return (
25+
<span
26+
class={`
27+
relative inline-block overflow-hidden bg-neutral-300 text-primary-700 after:absolute after:w-2.5 after:h-full after:animate-line after:bg-current after:block
28+
${sizeClasses[size]}
29+
${_class}
30+
`}
31+
aria-live="polite"
32+
aria-label={ariaLabel}
33+
data-testid="loader-linear"
34+
{...attributes}
35+
/>
36+
);
37+
}
38+
);
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 { SfLoaderLinear } from './SfLoaderLinear';
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import { SfLoaderSize } from '../../shared/SfLoader';
2+
3+
export enum SfLoaderLinearSize {
4+
minimal = 'minimal',
5+
}
6+
7+
export type SfLoaderLinearProps = {
8+
class?: string;
9+
size?: `${SfLoaderSize | SfLoaderLinearSize}`;
10+
ariaLabel?: string;
11+
};

0 commit comments

Comments
 (0)