-
-
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
10 changed files
with
75 additions
and
9 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 |
---|---|---|
@@ -1,9 +1,23 @@ | ||
<script lang="ts"> | ||
import IconButton from '$lib/components/IconButton/IconButton.svelte'; | ||
import { t } from '$lib/services/translation.svelte.js'; | ||
import type { CloseButtonProps } from '$lib/types.js'; | ||
import { mdiClose } from '@mdi/js'; | ||
const { size = 'medium', variant = 'ghost', ...restProps }: CloseButtonProps = $props(); | ||
const { | ||
size = 'medium', | ||
variant = 'ghost', | ||
translations, | ||
...restProps | ||
}: CloseButtonProps = $props(); | ||
</script> | ||
|
||
<IconButton {...restProps} icon={mdiClose} shape="round" {variant} {size} color="secondary" /> | ||
<IconButton | ||
{...restProps} | ||
icon={mdiClose} | ||
shape="round" | ||
{variant} | ||
{size} | ||
color="secondary" | ||
title={t('close', translations)} | ||
/> |
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,20 @@ | ||
import type { TranslationProps } from '$lib/types.js'; | ||
|
||
const defaultTranslations = { | ||
close: 'Close', | ||
showPassword: 'Show password', | ||
hidePassword: 'Hide password', | ||
}; | ||
|
||
export type Translations = typeof defaultTranslations; | ||
|
||
let translations = $state<Translations>(defaultTranslations); | ||
|
||
export const translate = <T extends keyof Translations>( | ||
key: T, | ||
overrides?: TranslationProps<T>, | ||
): string => overrides?.[key] ?? translations[key]; | ||
export const t = translate; | ||
export const setTranslations = (newTranslations: Partial<Translations>) => { | ||
translations = { ...defaultTranslations, ...newTranslations }; | ||
}; |
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,5 @@ | ||
<script lang="ts"> | ||
import { CloseButton } from '@immich/ui'; | ||
</script> | ||
|
||
<CloseButton translations={{ close: 'Close me' }} /> |
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,14 @@ | ||
<script lang="ts"> | ||
import { Stack, Field, PasswordInput } from '@immich/ui'; | ||
import { Field, PasswordInput, Stack } from '@immich/ui'; | ||
let value = $state('super-secret-password'); | ||
</script> | ||
|
||
<Stack gap={4}> | ||
<Field label="Empty"> | ||
<PasswordInput /> | ||
</Field> | ||
<Field label="Password"> | ||
<PasswordInput value="super-secret-password" /> | ||
<PasswordInput bind:value /> | ||
</Field> | ||
</Stack> |
15 changes: 15 additions & 0 deletions
15
src/routes/components/password-input/TranslationExample.svelte
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,15 @@ | ||
<script lang="ts"> | ||
import { Field, PasswordInput, Stack } from '@immich/ui'; | ||
</script> | ||
|
||
<Stack gap={4}> | ||
<Field label="Api Key"> | ||
<PasswordInput | ||
value="super-secret-password" | ||
translations={{ | ||
showPassword: 'Show Api key', | ||
hidePassword: 'Hide Api key', | ||
}} | ||
/> | ||
</Field> | ||
</Stack> |