-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
18 changed files
with
231 additions
and
19 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
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 |
---|---|---|
@@ -1,12 +1,19 @@ | ||
<script lang="ts"> | ||
type Props = { count?: number }; | ||
const { count = 1 }: Props = $props(); | ||
const lorem = | ||
'Lorem ipsum dolor sit amet consectetur adipisicing elit. A ipsam tenetur accusantium impedit beatae omnis necessitatibus. Voluptatum blanditiis libero impedit, harum eius inventore nihil, officia voluptate dolorum error consequatur animi.'; | ||
const make = (value: number) => { | ||
let content = ''; | ||
for (let i = 0; i < value; i++) { | ||
content += lorem; | ||
} | ||
return content; | ||
}; | ||
const text = $derived(make(count)); | ||
</script> | ||
|
||
{#each Array(count) as i} | ||
<p data-index={i}> | ||
Lorem ipsum dolor sit amet consectetur adipisicing elit. A ipsam tenetur accusantium impedit | ||
beatae omnis necessitatibus. Voluptatum blanditiis libero impedit, harum eius inventore nihil, | ||
officia voluptate dolorum error consequatur animi. | ||
</p> | ||
{/each} | ||
{text} |
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
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,99 @@ | ||
<script lang="ts"> | ||
import { getFieldContext } from '$lib/common/context.svelte.js'; | ||
import type { Color } from '$lib/types.js'; | ||
import { cleanClass } from '$lib/utils.js'; | ||
import type { HTMLInputAttributes } from 'svelte/elements'; | ||
import { tv } from 'tailwind-variants'; | ||
type Props = { | ||
checked?: boolean; | ||
color?: Color; | ||
disabled?: boolean; | ||
class?: string; | ||
onToggle?: ((checked: boolean) => void) | undefined; | ||
} & HTMLInputAttributes; | ||
let { | ||
checked = $bindable(false), | ||
class: className, | ||
color = 'primary', | ||
onToggle = undefined, | ||
...restProps | ||
}: Props = $props(); | ||
const { | ||
label, | ||
readOnly = false, | ||
required = false, | ||
disabled = false, | ||
} = $derived(getFieldContext()); | ||
const enabled = $derived(checked && !disabled); | ||
const handleToggle = (event: Event) => onToggle?.((event.target as HTMLInputElement).checked); | ||
const wrapper = tv({ | ||
base: 'relative flex flex-col justify-center', | ||
variants: { | ||
disabled: { | ||
true: 'cursor-not-allowed', | ||
false: 'cursor-pointer', | ||
}, | ||
}, | ||
}); | ||
const bar = tv({ | ||
base: 'w-12 h-3 my-2 rounded-full border border-transparent', | ||
variants: { | ||
fillColor: { | ||
default: 'bg-gray-400', | ||
primary: 'bg-primary/50', | ||
secondary: 'bg-dark/50', | ||
success: 'bg-success/50', | ||
danger: 'bg-danger/50', | ||
warning: 'bg-warning/50', | ||
info: 'bg-info/50', | ||
}, | ||
}, | ||
}); | ||
const dot = tv({ | ||
base: 'absolute transition-colors h-6 w-6 rounded-full transition-transform duration-[400ms]', | ||
variants: { | ||
checked: { | ||
true: 'translate-x-6', | ||
false: '', | ||
}, | ||
fillColor: { | ||
default: 'bg-gray-600', | ||
primary: 'bg-primary', | ||
secondary: 'bg-dark', | ||
success: 'bg-success', | ||
danger: 'bg-danger', | ||
warning: 'bg-warning', | ||
info: 'bg-info', | ||
}, | ||
}, | ||
}); | ||
</script> | ||
|
||
<label class={cleanClass(className)}> | ||
{label} | ||
<span class={wrapper({ disabled })}> | ||
<input | ||
class="hidden" | ||
type="checkbox" | ||
bind:checked | ||
onclick={handleToggle} | ||
{required} | ||
aria-required={required} | ||
{disabled} | ||
aria-disabled={disabled} | ||
readonly={readOnly} | ||
aria-readonly={readOnly} | ||
{...restProps} | ||
/> | ||
<span class={bar({ fillColor: enabled ? color : 'default' })}> </span> | ||
<span class={dot({ checked: enabled, fillColor: enabled ? color : 'default' })}></span> | ||
</span> | ||
</label> |
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
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 |
---|---|---|
@@ -1,9 +1,12 @@ | ||
<script lang="ts"> | ||
import ExampleLayout from '$docs/components/ExampleLayout.svelte'; | ||
import { Text } from '@immich/ui'; | ||
import BasicExample from './BasicExample.svelte'; | ||
import basicExample from './BasicExample.svelte?raw'; | ||
const examples = [{ title: 'Basic', code: basicExample, component: BasicExample }]; | ||
</script> | ||
|
||
<ExampleLayout name="Field" {examples} /> | ||
<ExampleLayout name="Field" {examples}> | ||
<Text>A metadata component for tracking common form field information</Text> | ||
</ExampleLayout> |
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 |
---|---|---|
|
@@ -11,4 +11,4 @@ | |
]; | ||
</script> | ||
|
||
<ExampleLayout name="Basic" {examples} /> | ||
<ExampleLayout name="Navbar" {examples} /> |
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
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,9 @@ | ||
<script lang="ts"> | ||
import ExampleLayout from '$docs/components/ExampleLayout.svelte'; | ||
import BasicExample from './BasicExample.svelte'; | ||
import basicExample from './BasicExample.svelte?raw'; | ||
const examples = [{ title: 'Basic', code: basicExample, component: BasicExample }]; | ||
</script> | ||
|
||
<ExampleLayout name="Scrollable" {examples} /> |
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,22 @@ | ||
<script lang="ts"> | ||
import Lorem from '$docs/components/Lorem.svelte'; | ||
import { Heading, Scrollable, Stack, Text } from '@immich/ui'; | ||
</script> | ||
|
||
<Stack gap={4}> | ||
<Heading size="tiny">Vertical</Heading> | ||
<div class="h-64 w-32"> | ||
<Scrollable> | ||
<Text> | ||
<Lorem count={5} /> | ||
</Text> | ||
</Scrollable> | ||
</div> | ||
|
||
<Heading size="tiny">Horizontal</Heading> | ||
<Scrollable> | ||
<Text class="h-8 w-[2000px]"> | ||
<Lorem /> | ||
</Text> | ||
</Scrollable> | ||
</Stack> |
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,20 @@ | ||
<script lang="ts"> | ||
import ExampleLayout from '$docs/components/ExampleLayout.svelte'; | ||
import { Text } from '@immich/ui'; | ||
import BasicExample from './BasicExample.svelte'; | ||
import basicExample from './BasicExample.svelte?raw'; | ||
import ColorExample from './ColorExample.svelte'; | ||
import colorExample from './ColorExample.svelte?raw'; | ||
import FormExample from './FormExample.svelte'; | ||
import formExample from './FormExample.svelte?raw'; | ||
const examples = [ | ||
{ title: 'Basic', code: basicExample, component: BasicExample }, | ||
{ title: 'Colors', code: colorExample, component: ColorExample }, | ||
{ title: 'Form', code: formExample, component: FormExample }, | ||
]; | ||
</script> | ||
|
||
<ExampleLayout name="Switch" {examples}> | ||
<Text>A boolean input element</Text> | ||
</ExampleLayout> |
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,11 @@ | ||
<script> | ||
import { Field, Stack, Switch } from '@immich/ui'; | ||
</script> | ||
|
||
<Stack> | ||
<Switch /> | ||
<Switch checked /> | ||
<Field disabled> | ||
<Switch /> | ||
</Field> | ||
</Stack> |
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,12 @@ | ||
<script lang="ts"> | ||
import { Stack, Switch } from '@immich/ui'; | ||
</script> | ||
|
||
<Stack> | ||
<Switch color="primary" checked /> | ||
<Switch color="secondary" checked /> | ||
<Switch color="success" checked /> | ||
<Switch color="info" checked /> | ||
<Switch color="warning" checked /> | ||
<Switch color="danger" checked /> | ||
</Stack> |
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,17 @@ | ||
<script> | ||
import { Field, Stack, Switch, Text } from '@immich/ui'; | ||
</script> | ||
|
||
<Stack> | ||
<Field label="Support Immich"> | ||
<Switch class="flex justify-between" checked /> | ||
</Field> | ||
<Field label="Advanced features"> | ||
<Switch class="flex justify-between" /> | ||
</Field> | ||
<Field label="Sell my privacy" disabled> | ||
<Switch class="flex justify-between"> | ||
<Text>Disabled</Text> | ||
</Switch> | ||
</Field> | ||
</Stack> |