-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Co-authored-by: Davis SHYAKA <[email protected]>
- Loading branch information
1 parent
bff2a5f
commit 64514fe
Showing
15 changed files
with
160 additions
and
8 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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,35 @@ | ||
<script lang="ts"> | ||
import { Icons } from '$lib/assets/icons/index.js'; | ||
import { cn } from '$lib/utils.js'; | ||
import { Link } from '../link/index.js'; | ||
import { type Props, error_variants } from './index.js'; | ||
type $$Props = Props; | ||
let class_name: string | undefined | null = undefined; | ||
export let size: $$Props['size'] = 'md'; | ||
export let label: $$Props['label'] = undefined; | ||
export let error: $$Props['error'] = undefined; | ||
export { class_name as class }; | ||
</script> | ||
|
||
<p class={cn(error_variants({ size, className: class_name }))} {...$$restProps}> | ||
<Icons.Stop aria-hidden="true" class="size-4" /> | ||
{#if error} | ||
<span>{error.message}</span> | ||
<span> | ||
<Link | ||
href={error.link} | ||
external={error.link.startsWith('https')} | ||
class="font-medium underline underline-offset-4 hover:opacity-70" | ||
> | ||
{error.action} | ||
</Link> | ||
</span> | ||
{:else} | ||
{#if label} | ||
<b>{label}:</b> | ||
{/if} | ||
<slot></slot> | ||
{/if} | ||
</p> |
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,29 @@ | ||
import { type VariantProps, tv } from 'tailwind-variants'; | ||
|
||
export { default as Error } from './error.svelte'; | ||
|
||
export const error_variants = tv({ | ||
base: 'inline-flex items-center gap-2 break-words text-red-900', | ||
variants: { | ||
size: { | ||
sm: 'text-[13px] font-normal', | ||
md: 'text-sm font-normal', | ||
lg: 'text-base font-medium' | ||
} | ||
}, | ||
defaultVariants: { | ||
size: 'md' | ||
} | ||
}); | ||
|
||
type Size = VariantProps<typeof error_variants>['size']; | ||
|
||
export type Props = { | ||
size?: Size; | ||
label?: string; | ||
error?: { | ||
message: string; | ||
action: string; | ||
link: string; | ||
}; | ||
}; |
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 +1,32 @@ | ||
<h1>error</h1> | ||
<script lang="ts"> | ||
import Demo from '$lib/components/shared/demo.svelte'; | ||
import PageWrapper from '$lib/components/shared/page-wrapper.svelte'; | ||
import CustomLabel from './custom-label.svelte'; | ||
import custom_label_code from './custom-label.svelte?raw'; | ||
import Default from './default.svelte'; | ||
import default_code from './default.svelte?raw'; | ||
import Sizes from './sizes.svelte'; | ||
import sizes_code from './sizes.svelte?raw'; | ||
import WithAnErrorProperty from './with-an-error-property.svelte'; | ||
import with_an_error_property_code from './with-an-error-property.svelte?raw'; | ||
export let data; | ||
</script> | ||
|
||
<PageWrapper title={data.title} description={data.description}> | ||
<Demo id="default" code={default_code}> | ||
<Default /> | ||
</Demo> | ||
|
||
<Demo id="custom-label" code={custom_label_code}> | ||
<CustomLabel /> | ||
</Demo> | ||
|
||
<Demo id="sizes" code={sizes_code}> | ||
<Sizes /> | ||
</Demo> | ||
|
||
<Demo id="with-an-error-property" code={with_an_error_property_code}> | ||
<WithAnErrorProperty /> | ||
</Demo> | ||
</PageWrapper> |
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 @@ | ||
import type { MetaTagsProps } from 'svelte-meta-tags'; | ||
|
||
export function load() { | ||
const title = 'Error'; | ||
const description = | ||
'Good error design is clear, useful, and friendly. Designing concise and accurate error messages unblocks users and builds trust by meeting people where they are.'; | ||
|
||
const pageMetaTags = Object.freeze({ | ||
title, | ||
description, | ||
openGraph: { | ||
title, | ||
description | ||
} | ||
}) satisfies MetaTagsProps; | ||
|
||
return { | ||
pageMetaTags, | ||
title, | ||
description | ||
}; | ||
} |
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 { Error } from '$lib/components/ui/error'; | ||
</script> | ||
|
||
<Error label="Email Error">This email address is already in use.</Error> |
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 { Error } from '$lib/components/ui/error'; | ||
</script> | ||
|
||
<Error>This email address is already in use.</Error> |
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 { Error } from '$lib/components/ui/error'; | ||
</script> | ||
|
||
<div class="flex items-center gap-4"> | ||
<Error size="sm">This email is in use.</Error> | ||
<Error>This email is in use.</Error> | ||
<Error size="lg">This email is in use.</Error> | ||
</div> |
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 lang="ts"> | ||
import { Error } from '$lib/components/ui/error'; | ||
</script> | ||
|
||
<Error | ||
error={{ | ||
message: 'The request failed.', | ||
action: 'Contact Us', | ||
link: 'https://shyakadavis.me' | ||
}} | ||
/> |