-
Notifications
You must be signed in to change notification settings - Fork 0
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
92 changed files
with
1,601 additions
and
140 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 |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# AlertDialog | ||
|
||
A component for displaying a modal dialog that requires user attention or confirmation. | ||
|
||
## Usage | ||
|
||
```svelte | ||
<script lang="ts"> | ||
import {AlertDialog} from 'ui-ingredients'; | ||
</script> | ||
<AlertDialog.Root> | ||
<AlertDialog.Trigger>Trigger</AlertDialog.Trigger> | ||
<AlertDialog.Backdrop /> | ||
<AlertDialog.Positioner> | ||
<AlertDialog.Content> | ||
<AlertDialog.Title>Title</AlertDialog.Title> | ||
<AlertDialog.Description>Description</AlertDialog.Description> | ||
<AlertDialog.CloseTrigger>Close</AlertDialog.CloseTrigger> | ||
</AlertDialog.Content> | ||
</AlertDialog.Positioner> | ||
</AlertDialog.Root> | ||
``` |
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 @@ | ||
# Alert | ||
|
||
A component for displaying important messages or notifications. | ||
|
||
## Usage | ||
|
||
```svelte | ||
<script> | ||
import {Alert} from 'ui-ingredients'; | ||
import {AlertCircleIcon} from '$lib/icons'; | ||
</script> | ||
<Alert.Root> | ||
<Alert.Indicator> | ||
<AlertCircleIcon /> | ||
</Alert.Indicator> | ||
<Alert.Title>Title</Alert.Title> | ||
<Alert.Description>Description</Alert.Description> | ||
</Alert.Root> | ||
``` |
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 @@ | ||
# Breadcrumbs | ||
|
||
A component for displaying the navigation path or hierarchy of a user's location within a site. | ||
|
||
## Usage | ||
|
||
```svelte | ||
<script> | ||
import {Breadcrumbs} from 'ui-ingredients'; | ||
import {ChevronRightIcon} from '$lib/icons'; | ||
</script> | ||
<Breadcrumbs.Root> | ||
<Breadcrumbs.List> | ||
<Breadcrumbs.Item> | ||
<Breadcrumbs.Link href="/">Home</Breadcrumbs.Link> | ||
<Breadcrumbs.Separator> | ||
<ChevronRightIcon /> | ||
</Breadcrumbs.Separator> | ||
</Breadcrumbs.Item> | ||
<Breadcrumbs.Item> | ||
<Breadcrumbs.Link href="/components">Components</Breadcrumbs.Link> | ||
<Breadcrumbs.Separator> | ||
<ChevronRightIcon /> | ||
</Breadcrumbs.Separator> | ||
</Breadcrumbs.Item> | ||
<Breadcrumbs.Item> | ||
<Breadcrumbs.Link href="/components/breadcrumbs" current> | ||
Breadcrumbs | ||
</Breadcrumbs.Link> | ||
</Breadcrumbs.Item> | ||
</Breadcrumbs.List> | ||
</Breadcrumbs.Root> | ||
``` |
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 @@ | ||
# Drawer | ||
|
||
A component that slides in from the edge of the screen to display additional content or navigation options. | ||
|
||
## Usage | ||
|
||
```svelte | ||
<script> | ||
import {Drawer} from 'ui-ingredients'; | ||
import {XCloseIcon} from '$lib/icons'; | ||
</script> | ||
<Drawer.Root> | ||
<Drawer.Trigger>Trigger</Drawer.Trigger> | ||
<Drawer.Backdrop /> | ||
<Drawer.Positioner> | ||
<Drawer.Content> | ||
<Drawer.Header> | ||
<Drawer.Title>Title</Drawer.Title> | ||
<Drawer.Description>Description</Drawer.Description> | ||
</Drawer.Header> | ||
<Drawer.Body>Body Content</Drawer.Body> | ||
<Drawer.Footer> | ||
<Drawer.CloseTrigger>Close</Drawer.CloseTrigger> | ||
</Drawer.Footer> | ||
</Drawer.Content> | ||
</Drawer.Positioner> | ||
</Drawer.Root> | ||
``` |
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,10 @@ | ||
import {createAnatomy} from '@zag-js/anatomy'; | ||
|
||
export const anatomy = createAnatomy('alert').parts( | ||
'root', | ||
'title', | ||
'description', | ||
'indicator', | ||
); | ||
|
||
export const parts = anatomy.build(); |
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 @@ | ||
import {createContext} from '$lib/create-context.svelte.js'; | ||
import type {CreateAlertReturn} from './create-alert.svelte.js'; | ||
|
||
export const [getAlertContext, setAlertContext] = | ||
createContext<CreateAlertReturn>('Alert'); |
25 changes: 25 additions & 0 deletions
25
packages/ui-ingredients/src/lib/alert/alert-description.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,25 @@ | ||
<script lang="ts" module> | ||
import type {HtmlIngredientProps} from '$lib/types.js'; | ||
export interface AlertDescriptionProps | ||
extends HtmlIngredientProps<'p', HTMLParagraphElement> {} | ||
</script> | ||
|
||
<script lang="ts"> | ||
import {mergeProps} from '$lib/merge-props.js'; | ||
import {getAlertContext} from './alert-context.js'; | ||
let {ref, asChild, children, ...props}: AlertDescriptionProps = $props(); | ||
let alert = getAlertContext(); | ||
let attrs = $derived(mergeProps(alert.getDescriptionProps(), props)); | ||
</script> | ||
|
||
{#if asChild} | ||
{@render asChild(attrs)} | ||
{:else} | ||
<p bind:this={ref} {...attrs}> | ||
{@render children?.()} | ||
</p> | ||
{/if} |
25 changes: 25 additions & 0 deletions
25
packages/ui-ingredients/src/lib/alert/alert-indicator.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,25 @@ | ||
<script lang="ts" module> | ||
import type {HtmlIngredientProps} from '$lib/types.js'; | ||
export interface AlertIndicatorProps | ||
extends HtmlIngredientProps<'span', HTMLSpanElement> {} | ||
</script> | ||
|
||
<script lang="ts"> | ||
import {mergeProps} from '$lib/merge-props.js'; | ||
import {getAlertContext} from './alert-context.js'; | ||
let {ref, asChild, children, ...props}: AlertIndicatorProps = $props(); | ||
let alert = getAlertContext(); | ||
let attrs = $derived(mergeProps(alert.getIndicatorProps(), props)); | ||
</script> | ||
|
||
{#if asChild} | ||
{@render asChild(attrs)} | ||
{:else} | ||
<span bind:this={ref} {...attrs}> | ||
{@render children?.()} | ||
</span> | ||
{/if} |
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 @@ | ||
<script lang="ts" module> | ||
import type {HtmlIngredientProps} from '$lib/types.js'; | ||
import type {CreateAlertReturn} from './create-alert.svelte.js'; | ||
export interface AlertProps | ||
extends HtmlIngredientProps<'div', HTMLDivElement, CreateAlertReturn> {} | ||
</script> | ||
|
||
<script lang="ts"> | ||
import {mergeProps} from '$lib/merge-props.js'; | ||
import {setAlertContext} from './alert-context.js'; | ||
import {createAlert} from './create-alert.svelte.js'; | ||
let {ref, asChild, children, ...props}: AlertProps = $props(); | ||
let alert = createAlert(); | ||
let attrs = $derived(mergeProps(alert.getRootProps(), props)); | ||
setAlertContext(alert); | ||
</script> | ||
|
||
{#if asChild} | ||
{@render asChild(attrs, alert)} | ||
{:else} | ||
<div bind:this={ref} {...attrs}> | ||
{@render children?.(alert)} | ||
</div> | ||
{/if} |
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,25 @@ | ||
<script lang="ts" module> | ||
import type {HtmlIngredientProps} from '$lib/types.js'; | ||
export interface AlertTitleProps | ||
extends HtmlIngredientProps<'h2', HTMLHeadingElement> {} | ||
</script> | ||
|
||
<script lang="ts"> | ||
import {mergeProps} from '$lib/merge-props.js'; | ||
import {getAlertContext} from './alert-context.js'; | ||
let {ref, asChild, children, ...props}: AlertTitleProps = $props(); | ||
let alert = getAlertContext(); | ||
let attrs = $derived(mergeProps(alert.getTitleProps(), props)); | ||
</script> | ||
|
||
{#if asChild} | ||
{@render asChild(attrs)} | ||
{:else} | ||
<h2 bind:this={ref} {...attrs}> | ||
{@render children?.()} | ||
</h2> | ||
{/if} |
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,4 @@ | ||
export {default as Description} from './alert-description.svelte'; | ||
export {default as Indicator} from './alert-indicator.svelte'; | ||
export {default as Root} from './alert-root.svelte'; | ||
export {default as Title} from './alert-title.svelte'; |
44 changes: 44 additions & 0 deletions
44
packages/ui-ingredients/src/lib/alert/create-alert.svelte.ts
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,44 @@ | ||
import type {HTMLAttributes} from 'svelte/elements'; | ||
import {parts} from './alert-anatomy.js'; | ||
|
||
export interface CreateAlertReturn { | ||
getRootProps(): HTMLAttributes<HTMLElement>; | ||
getTitleProps(): HTMLAttributes<HTMLElement>; | ||
getDescriptionProps(): HTMLAttributes<HTMLElement>; | ||
getIndicatorProps(): HTMLAttributes<HTMLElement>; | ||
} | ||
|
||
export function createAlert(): CreateAlertReturn { | ||
function getRootProps(): HTMLAttributes<HTMLElement> { | ||
return { | ||
role: 'alert', | ||
...parts.root.attrs, | ||
}; | ||
} | ||
|
||
function getTitleProps(): HTMLAttributes<HTMLElement> { | ||
return { | ||
...parts.title.attrs, | ||
}; | ||
} | ||
|
||
function getDescriptionProps(): HTMLAttributes<HTMLElement> { | ||
return { | ||
...parts.description.attrs, | ||
}; | ||
} | ||
|
||
function getIndicatorProps(): HTMLAttributes<HTMLElement> { | ||
return { | ||
'aria-hidden': true, | ||
...parts.indicator.attrs, | ||
}; | ||
} | ||
|
||
return { | ||
getRootProps, | ||
getTitleProps, | ||
getDescriptionProps, | ||
getIndicatorProps, | ||
}; | ||
} |
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 @@ | ||
export * as Alert from './alert.js'; | ||
|
||
export type {AlertDescriptionProps} from './alert-description.svelte'; | ||
export type {AlertIndicatorProps} from './alert-indicator.svelte'; | ||
export type {AlertProps} from './alert-root.svelte'; | ||
export type {AlertTitleProps} from './alert-title.svelte'; | ||
|
||
export {anatomy as alertAnatomy} from './alert-anatomy.js'; | ||
export {getAlertContext} from './alert-context.js'; |
11 changes: 11 additions & 0 deletions
11
packages/ui-ingredients/src/lib/breadcrumbs/breadcrumbs-anatomy.ts
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 @@ | ||
import {createAnatomy} from '@zag-js/anatomy'; | ||
|
||
export const anatomy = createAnatomy('breadcrumbs').parts( | ||
'root', | ||
'list', | ||
'item', | ||
'link', | ||
'separator', | ||
); | ||
|
||
export const parts = anatomy.build(); |
5 changes: 5 additions & 0 deletions
5
packages/ui-ingredients/src/lib/breadcrumbs/breadcrumbs-context.svelte.ts
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 @@ | ||
import {createContext} from '$lib/create-context.svelte.js'; | ||
import type {CreateBreadcrumbsReturn} from './create-breadcrumbs.js'; | ||
|
||
export const [getBreadcrumbsContext, setBreadcrumbsContext] = | ||
createContext<CreateBreadcrumbsReturn>('Breadcrumbs'); |
Oops, something went wrong.