-
Notifications
You must be signed in to change notification settings - Fork 40
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #238 from appwrite/feat-skeleton-loader
Add skeleton loader
- Loading branch information
Showing
5 changed files
with
84 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
<script lang="ts"> | ||
type $$Props = { variant: 'circle' | 'square' | 'line'; width: number; height?: number }; | ||
export let variant: $$Props['variant'] = 'circle'; | ||
export let width: $$Props['width'] = 44; | ||
export let height: $$Props['height'] = 100; | ||
</script> | ||
|
||
<div | ||
class="skeleton" | ||
style="width: {width}px; {variant === 'line' && `height: ${height}px;`}" | ||
class:circle={variant === 'circle'} | ||
class:square={variant === 'square'} | ||
/> | ||
|
||
<style> | ||
.skeleton { | ||
background-color: var(--color-bgcolor-neutral-tertiary); | ||
background-image: linear-gradient( | ||
90deg, | ||
var(--color-bgcolor-neutral-tertiary) 25%, | ||
var(--color-overlay-skeleton) 50%, | ||
var(--color-bgcolor-neutral-tertiary) 75% | ||
); | ||
background-size: 200% 100%; | ||
animation: loading 2s linear infinite; | ||
border-radius: var(--border-radius-xs, 6px); | ||
} | ||
.circle { | ||
border-radius: 50%; | ||
} | ||
.circle, | ||
.square { | ||
aspect-ratio: 1/1; | ||
} | ||
@keyframes loading { | ||
0% { | ||
background-position: 200% 0; | ||
} | ||
100% { | ||
background-position: -200% 0; | ||
} | ||
} | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
<script context="module" lang="ts"> | ||
import { Skeleton } from '$lib/index.js'; | ||
import type { MetaProps } from '@storybook/addon-svelte-csf'; | ||
import { Story } from '@storybook/addon-svelte-csf'; | ||
export const meta: MetaProps = { | ||
title: 'Components/Skeleton', | ||
component: Skeleton, | ||
args: { | ||
variant: 'circle', | ||
width: 44, | ||
height: 12 | ||
}, | ||
argTypes: { | ||
variant: { | ||
options: ['circle', 'square', 'line'], | ||
control: { type: 'select' } | ||
} | ||
} | ||
}; | ||
</script> | ||
|
||
<div class="wrapper"> | ||
<Story name="Default" let:args> | ||
<Skeleton {...args} /> | ||
</Story> | ||
</div> | ||
|
||
<style> | ||
.wrapper { | ||
margin: 100px auto; | ||
width: 400px; | ||
} | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters