Skip to content

Commit

Permalink
✨ Updated to svelte 5 && reworked styling && skills list
Browse files Browse the repository at this point in the history
  • Loading branch information
nwrenger committed Nov 17, 2024
1 parent e8834bf commit d05a246
Show file tree
Hide file tree
Showing 32 changed files with 488 additions and 396 deletions.
Binary file modified bun.lockb
Binary file not shown.
9 changes: 6 additions & 3 deletions components.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"$schema": "https://shadcn-svelte.com/schema.json",
"$schema": "https://next.shadcn-svelte.com/schema.json",
"style": "default",
"tailwind": {
"config": "tailwind.config.js",
Expand All @@ -8,7 +8,10 @@
},
"aliases": {
"components": "$lib/components",
"utils": "$lib/utils"
"utils": "$lib/utils",
"ui": "$lib/components/ui",
"hooks": "$lib/hooks"
},
"typescript": true
"typescript": true,
"registry": "https://next.shadcn-svelte.com/registry"
}
44 changes: 21 additions & 23 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,32 +12,30 @@
"format": "prettier --write ."
},
"devDependencies": {
"@sveltejs/adapter-auto": "^3.2.4",
"@sveltejs/kit": "^2.5.25",
"@sveltejs/vite-plugin-svelte": "^3.1.2",
"@sveltejs/adapter-auto": "^3.3.1",
"@sveltejs/adapter-static": "^3.0.6",
"@sveltejs/kit": "^2.8.1",
"@sveltejs/vite-plugin-svelte": "^4.0.1",
"autoprefixer": "^10.4.20",
"postcss": "^8.4.41",
"postcss-load-config": "^5.1.0",
"prettier": "^3.3.3",
"prettier-plugin-svelte": "^3.2.6",
"prettier-plugin-tailwindcss": "^0.5.14",
"svelte": "^4.2.19",
"svelte-check": "^3.8.6",
"tailwindcss": "^3.4.10",
"tslib": "^2.7.0",
"typescript": "^5.5.4",
"vite": "^5.4.2"
},
"type": "module",
"dependencies": {
"@sveltejs/adapter-static": "^3.0.4",
"bits-ui": "^0.21.13",
"bits-ui": "^1.0.0-next.59",
"clsx": "^2.1.1",
"install": "^0.13.0",
"lucide-svelte": "^0.436.0",
"mode-watcher": "^0.3.1",
"tailwind-merge": "^2.5.2",
"tailwind-variants": "^0.2.1",
"vaul-svelte": "^0.3.2"
}
"prettier": "^3.3.3",
"prettier-plugin-svelte": "^3.2.8",
"prettier-plugin-tailwindcss": "^0.5.14",
"svelte": "^5.2.2",
"svelte-check": "^4.0.9",
"tailwind-merge": "^2.5.4",
"tailwind-variants": "^0.3.0",
"tailwindcss": "^3.4.15",
"tailwindcss-animate": "^1.0.7",
"tslib": "^2.8.1",
"typescript": "^5.6.3",
"vaul-svelte": "^0.3.2",
"vite": "^5.4.11"
},
"type": "module",
"dependencies": {}
}
File renamed without changes.
19 changes: 11 additions & 8 deletions src/lib/components/ui/alert/alert-description.svelte
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
<script lang="ts">
import type { HTMLAttributes } from 'svelte/elements';
import { cn } from '$lib/utils.js';
import type { WithElementRef } from "bits-ui";
import type { HTMLAttributes } from "svelte/elements";
import { cn } from "$lib/utils.js";
type $$Props = HTMLAttributes<HTMLDivElement>;
let className: $$Props['class'] = undefined;
export { className as class };
let {
ref = $bindable(null),
class: className,
children,
...restProps
}: WithElementRef<HTMLAttributes<HTMLDivElement>> = $props();
</script>

<div class={cn('text-sm [&_p]:leading-relaxed', className)} {...$$restProps}>
<slot />
<div bind:this={ref} class={cn("text-sm [&_p]:leading-relaxed", className)} {...restProps}>
{@render children?.()}
</div>
36 changes: 20 additions & 16 deletions src/lib/components/ui/alert/alert-title.svelte
Original file line number Diff line number Diff line change
@@ -1,21 +1,25 @@
<script lang="ts">
import type { HTMLAttributes } from 'svelte/elements';
import type { HeadingLevel } from './index.js';
import { cn } from '$lib/utils.js';
import type { HTMLAttributes } from "svelte/elements";
import type { WithElementRef } from "bits-ui";
import { cn } from "$lib/utils.js";
type $$Props = HTMLAttributes<HTMLHeadingElement> & {
level?: HeadingLevel;
};
let className: $$Props['class'] = undefined;
export let level: $$Props['level'] = 'h5';
export { className as class };
let {
ref = $bindable(null),
class: className,
level = 5,
children,
...restProps
}: WithElementRef<HTMLAttributes<HTMLDivElement>> & {
level?: 1 | 2 | 3 | 4 | 5 | 6;
} = $props();
</script>

<svelte:element
this={level}
class={cn('mb-1 font-medium leading-none tracking-tight', className)}
{...$$restProps}
<div
role="heading"
aria-level={level}
bind:this={ref}
class={cn("mb-1 font-medium leading-none tracking-tight", className)}
{...restProps}
>
<slot />
</svelte:element>
{@render children?.()}
</div>
46 changes: 34 additions & 12 deletions src/lib/components/ui/alert/alert.svelte
Original file line number Diff line number Diff line change
@@ -1,17 +1,39 @@
<script lang="ts">
import type { HTMLAttributes } from 'svelte/elements';
import { type Variant, alertVariants } from './index.js';
import { cn } from '$lib/utils.js';
<script lang="ts" module>
import { type VariantProps, tv } from "tailwind-variants";
export const alertVariants = tv({
base: "[&>svg]:text-foreground relative w-full rounded-lg border p-4 [&>svg]:absolute [&>svg]:left-4 [&>svg]:top-4 [&>svg~*]:pl-7",
variants: {
variant: {
default: "bg-background text-foreground",
destructive:
"border-destructive/50 text-destructive dark:border-destructive [&>svg]:text-destructive",
},
},
defaultVariants: {
variant: "default",
},
});
type $$Props = HTMLAttributes<HTMLDivElement> & {
variant?: Variant;
};
export type AlertVariant = VariantProps<typeof alertVariants>["variant"];
</script>

<script lang="ts">
import type { HTMLAttributes } from "svelte/elements";
import type { WithElementRef } from "bits-ui";
import { cn } from "$lib/utils.js";
let className: $$Props['class'] = undefined;
export let variant: $$Props['variant'] = 'default';
export { className as class };
let {
ref = $bindable(null),
class: className,
variant = "default",
children,
...restProps
}: WithElementRef<HTMLAttributes<HTMLDivElement>> & {
variant?: AlertVariant;
} = $props();
</script>

<div class={cn(alertVariants({ variant }), className)} {...$$restProps} role="alert">
<slot />
<div bind:this={ref} class={cn(alertVariants({ variant }), className)} {...restProps} role="alert">
{@render children?.()}
</div>
29 changes: 5 additions & 24 deletions src/lib/components/ui/alert/index.ts
Original file line number Diff line number Diff line change
@@ -1,26 +1,7 @@
import { type VariantProps, tv } from 'tailwind-variants';

import Root from './alert.svelte';
import Description from './alert-description.svelte';
import Title from './alert-title.svelte';

export const alertVariants = tv({
base: '[&>svg]:text-foreground relative w-full rounded-lg border p-4 [&:has(svg)]:pl-11 [&>svg+div]:translate-y-[-3px] [&>svg]:absolute [&>svg]:left-4 [&>svg]:top-4',

variants: {
variant: {
default: 'bg-background text-foreground',
destructive:
'border-destructive/50 text-destructive text-destructive dark:border-destructive [&>svg]:text-destructive'
}
},
defaultVariants: {
variant: 'default'
}
});

export type Variant = VariantProps<typeof alertVariants>['variant'];
export type HeadingLevel = 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6';
import Root from "./alert.svelte";
import Description from "./alert-description.svelte";
import Title from "./alert-title.svelte";
export { alertVariants, type AlertVariant } from "./alert.svelte";

export {
Root,
Expand All @@ -29,5 +10,5 @@ export {
//
Root as Alert,
Description as AlertDescription,
Title as AlertTitle
Title as AlertTitle,
};
22 changes: 11 additions & 11 deletions src/lib/components/ui/avatar/avatar-fallback.svelte
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
<script lang="ts">
import { Avatar as AvatarPrimitive } from 'bits-ui';
import { cn } from '$lib/utils.js';
import { Avatar as AvatarPrimitive } from "bits-ui";
import { cn } from "$lib/utils.js";
type $$Props = AvatarPrimitive.FallbackProps;
let className: $$Props['class'] = undefined;
export { className as class };
let {
ref = $bindable(null),
class: className,
...restProps
}: AvatarPrimitive.FallbackProps = $props();
</script>

<AvatarPrimitive.Fallback
class={cn('flex h-full w-full items-center justify-center rounded-full bg-muted', className)}
{...$$restProps}
>
<slot />
</AvatarPrimitive.Fallback>
bind:ref
class={cn("bg-muted flex h-full w-full items-center justify-center rounded-full", className)}
{...restProps}
/>
22 changes: 10 additions & 12 deletions src/lib/components/ui/avatar/avatar-image.svelte
Original file line number Diff line number Diff line change
@@ -1,18 +1,16 @@
<script lang="ts">
import { Avatar as AvatarPrimitive } from 'bits-ui';
import { cn } from '$lib/utils.js';
import { Avatar as AvatarPrimitive } from "bits-ui";
import { cn } from "$lib/utils.js";
type $$Props = AvatarPrimitive.ImageProps;
let className: $$Props['class'] = undefined;
export let src: $$Props['src'] = undefined;
export let alt: $$Props['alt'] = undefined;
export { className as class };
let {
ref = $bindable(null),
class: className,
...restProps
}: AvatarPrimitive.ImageProps = $props();
</script>

<AvatarPrimitive.Image
{src}
{alt}
class={cn('aspect-square h-full w-full', className)}
{...$$restProps}
bind:ref
class={cn("aspect-square h-full w-full", className)}
{...restProps}
/>
20 changes: 9 additions & 11 deletions src/lib/components/ui/avatar/avatar.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,15 @@
import { Avatar as AvatarPrimitive } from 'bits-ui';
import { cn } from '$lib/utils.js';
type $$Props = AvatarPrimitive.Props;
let className: $$Props['class'] = undefined;
export let delayMs: $$Props['delayMs'] = undefined;
export { className as class };
let {
ref = $bindable(null),
class: className,
...restProps
}: AvatarPrimitive.RootProps = $props();
</script>

<AvatarPrimitive.Root
{delayMs}
class={cn('relative flex h-10 w-10 shrink-0 overflow-hidden rounded-sm', className)}
{...$$restProps}
>
<slot />
</AvatarPrimitive.Root>
bind:ref
class={cn('relative flex size-10 shrink-0 overflow-hidden rounded-md', className)}
{...restProps}
/>
8 changes: 4 additions & 4 deletions src/lib/components/ui/avatar/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import Root from './avatar.svelte';
import Image from './avatar-image.svelte';
import Fallback from './avatar-fallback.svelte';
import Root from "./avatar.svelte";
import Image from "./avatar-image.svelte";
import Fallback from "./avatar-fallback.svelte";

export {
Root,
Expand All @@ -9,5 +9,5 @@ export {
//
Root as Avatar,
Image as AvatarImage,
Fallback as AvatarFallback
Fallback as AvatarFallback,
};
50 changes: 41 additions & 9 deletions src/lib/components/ui/badge/badge.svelte
Original file line number Diff line number Diff line change
@@ -1,18 +1,50 @@
<script lang="ts" module>
import { type VariantProps, tv } from "tailwind-variants";
export const badgeVariants = tv({
base: "focus:ring-ring inline-flex items-center rounded-full border px-2.5 py-0.5 text-xs font-semibold transition-colors focus:outline-none focus:ring-2 focus:ring-offset-2",
variants: {
variant: {
default:
"bg-primary text-primary-foreground hover:bg-primary/80 border-transparent",
secondary:
"bg-secondary text-secondary-foreground hover:bg-secondary/80 border-transparent",
destructive:
"bg-destructive text-destructive-foreground hover:bg-destructive/80 border-transparent",
outline: "text-foreground",
},
},
defaultVariants: {
variant: "default",
},
});
export type BadgeVariant = VariantProps<typeof badgeVariants>["variant"];
</script>

<script lang="ts">
import { type Variant, badgeVariants } from './index.js';
import { cn } from '$lib/utils.js';
import type { WithElementRef } from "bits-ui";
import type { HTMLAnchorAttributes } from "svelte/elements";
import { cn } from "$lib/utils.js";
let className: string | undefined | null = undefined;
export let href: string | undefined = undefined;
export let variant: Variant = 'default';
export { className as class };
let {
ref = $bindable(null),
href,
class: className,
variant = "default",
children,
...restProps
}: WithElementRef<HTMLAnchorAttributes> & {
variant?: BadgeVariant;
} = $props();
</script>

<svelte:element
this={href ? 'a' : 'span'}
this={href ? "a" : "span"}
bind:this={ref}
{href}
class={cn(badgeVariants({ variant, className }))}
{...$$restProps}
{...restProps}
>
<slot />
{@render children?.()}
</svelte:element>
Loading

0 comments on commit d05a246

Please sign in to comment.