Skip to content

Commit

Permalink
feat: close button (#19)
Browse files Browse the repository at this point in the history
  • Loading branch information
jrasm91 authored Nov 18, 2024
1 parent ae011d3 commit 188c1d8
Show file tree
Hide file tree
Showing 5 changed files with 59 additions and 4 deletions.
3 changes: 2 additions & 1 deletion src/docs/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,9 @@ type Route = { name: string; link: string };
export const routes: Route[] = [
{ name: 'Alert', link: '/examples/alert' },
{ name: 'Button', link: '/examples/button' },
{ name: 'Checkbox', link: '/examples/checkbox' },
{ name: 'Card', link: '/examples/card' },
{ name: 'Checkbox', link: '/examples/checkbox' },
{ name: 'CloseButton', link: '/examples/close-button' },
{ name: 'Heading', link: '/examples/heading' },
{ name: 'IconButton', link: '/examples/icon-button' },
{ name: 'Logo', link: '/examples/logo' },
Expand Down
9 changes: 9 additions & 0 deletions src/lib/components/CloseButton/CloseButton.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<script lang="ts">
import IconButton from '$lib/components/IconButton/IconButton.svelte';
import type { CloseButtonProps } from '$lib/types.js';
import { mdiClose } from '@mdi/js';
const { size = 'medium', variant = 'ghost' }: CloseButtonProps = $props();
</script>

<IconButton icon={mdiClose} color="secondary" shape="round" {variant} {size} />
1 change: 1 addition & 0 deletions src/lib/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ export { default as CardDescription } from '$lib/components/Card/CardDescription
export { default as CardFooter } from '$lib/components/Card/CardFooter.svelte';
export { default as CardHeader } from '$lib/components/Card/CardHeader.svelte';
export { default as CardTitle } from '$lib/components/Card/CardTitle.svelte';
export { default as CloseButton } from '$lib/components/CloseButton/CloseButton.svelte';
export { default as Checkbox } from '$lib/components/Form/Checkbox.svelte';
export { default as Input } from '$lib/components/Form/Input.svelte';
export { default as Label } from '$lib/components/Form/Label.svelte';
Expand Down
9 changes: 6 additions & 3 deletions src/lib/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,15 @@ type ButtonOrAnchor =
| ({ href?: never } & HTMLButtonAttributes)
| ({ href: string } & HTMLAnchorAttributes);

type ButtonBaseProps = {
export type CloseButtonProps = {
size?: Size;
variant?: Variants;
};

type ButtonBaseProps = CloseButtonProps & {
class?: string;
color?: Color;
size?: Size;
shape?: Shape;
variant?: Variants;
} & ButtonOrAnchor;

export type IconProps = {
Expand Down
41 changes: 41 additions & 0 deletions src/routes/examples/close-button/+page.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<script lang="ts">
import DualThemeLayout from '$docs/components/DualThemeLayout.svelte';
import { Card, CardBody, CardHeader, CardTitle, CloseButton, VStack } from '@immich/ui';
</script>

<DualThemeLayout name="CloseButton">
{#snippet component()}
<Card>
<CardHeader>
<CardTitle>Basic</CardTitle>
</CardHeader>
<CardBody>
<VStack>
<CloseButton />
</VStack>
</CardBody>
</Card>

<Card>
<CardHeader>
<CardTitle>Filled</CardTitle>
</CardHeader>
<CardBody>
<VStack>
<CloseButton variant="filled" />
</VStack>
</CardBody>
</Card>

<Card>
<CardHeader>
<CardTitle>Outline</CardTitle>
</CardHeader>
<CardBody>
<VStack>
<CloseButton variant="outline" />
</VStack>
</CardBody>
</Card>
{/snippet}
</DualThemeLayout>

0 comments on commit 188c1d8

Please sign in to comment.