-
Notifications
You must be signed in to change notification settings - Fork 373
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(module): auto inject
lib/utils
& refresh the playground (#528)
* chore: add dev:nuxt script * chore(module): add `.npmrc` to playground * chore: bump 'nuxtjs/tailwindcss' and add it to modules * chore: add schema to components.json * chore: bump playground deps * fix: add missing tailwind.css by the cli * chore: bump tailwind config * chore(playground): bump Button component * chore: add comments * refactor: simplify components registration * chore(module): bump deps * chore(module): remove `oxc-parser` * chore: dedupe * feat(module): auto generate `lib/utils` * feat(module): refresh playground style and dark mode * chore: revert components registration and link the comment * chore: readd oxc-parser * chore: bump vitest
- Loading branch information
1 parent
3dd2fbd
commit 631ffb8
Showing
12 changed files
with
385 additions
and
506 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 @@ | ||
shamefully-hoist=true |
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,11 +1,38 @@ | ||
<script setup> | ||
<script setup lang="ts"> | ||
import { MoonIcon, SunIcon } from '@radix-icons/vue' | ||
const isDark = ref(true) | ||
useHead({ htmlAttrs: { class: () => isDark.value ? 'dark' : '' } }) | ||
</script> | ||
|
||
<template> | ||
<div> | ||
<UiButton :variant="'destructive'"> | ||
hi | ||
</UiButton> | ||
Nuxt module playground! | ||
</div> | ||
<main class="flex flex-col min-h-dvh"> | ||
<header class="border-b py-1 "> | ||
<div class="container flex justify-between items-center "> | ||
<h1 class="font-medium"> | ||
shadcn-vue Playground | ||
</h1> | ||
|
||
<ClientOnly> | ||
<button | ||
class="p-2 hover:bg-gray-200 dark:hover:bg-gray-700 transition-colors rounded-md" | ||
aria-label="Toggle dark mode" | ||
@click="isDark = !isDark" | ||
> | ||
<component | ||
:is="isDark ? SunIcon : MoonIcon" | ||
class="size-5" | ||
/> | ||
</button> | ||
</ClientOnly> | ||
</div> | ||
</header> | ||
|
||
<!-- Try your components here --> | ||
<section class="container grow my-4 p-4 rounded-md border grid place-content-center"> | ||
<UiButton variant="destructive"> | ||
Hi | ||
</UiButton> | ||
</section> | ||
</main> | ||
</template> |
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,78 @@ | ||
@tailwind base; | ||
@tailwind components; | ||
@tailwind utilities; | ||
|
||
@layer base { | ||
:root { | ||
--background: 0 0% 100%; | ||
--foreground: 222.2 84% 4.9%; | ||
|
||
--muted: 210 40% 96.1%; | ||
--muted-foreground: 215.4 16.3% 46.9%; | ||
|
||
--popover: 0 0% 100%; | ||
--popover-foreground: 222.2 84% 4.9%; | ||
|
||
--card: 0 0% 100%; | ||
--card-foreground: 222.2 84% 4.9%; | ||
|
||
--border: 214.3 31.8% 91.4%; | ||
--input: 214.3 31.8% 91.4%; | ||
|
||
--primary: 222.2 47.4% 11.2%; | ||
--primary-foreground: 210 40% 98%; | ||
|
||
--secondary: 210 40% 96.1%; | ||
--secondary-foreground: 222.2 47.4% 11.2%; | ||
|
||
--accent: 210 40% 96.1%; | ||
--accent-foreground: 222.2 47.4% 11.2%; | ||
|
||
--destructive: 0 84.2% 60.2%; | ||
--destructive-foreground: 210 40% 98%; | ||
|
||
--ring: 222.2 84% 4.9%; | ||
|
||
--radius: 0.5rem; | ||
} | ||
|
||
.dark { | ||
--background: 222.2 84% 4.9%; | ||
--foreground: 210 40% 98%; | ||
|
||
--muted: 217.2 32.6% 17.5%; | ||
--muted-foreground: 215 20.2% 65.1%; | ||
|
||
--popover: 222.2 84% 4.9%; | ||
--popover-foreground: 210 40% 98%; | ||
|
||
--card: 222.2 84% 4.9%; | ||
--card-foreground: 210 40% 98%; | ||
|
||
--border: 217.2 32.6% 17.5%; | ||
--input: 217.2 32.6% 17.5%; | ||
|
||
--primary: 210 40% 98%; | ||
--primary-foreground: 222.2 47.4% 11.2%; | ||
|
||
--secondary: 217.2 32.6% 17.5%; | ||
--secondary-foreground: 210 40% 98%; | ||
|
||
--accent: 217.2 32.6% 17.5%; | ||
--accent-foreground: 210 40% 98%; | ||
|
||
--destructive: 0 62.8% 30.6%; | ||
--destructive-foreground: 210 40% 98%; | ||
|
||
--ring: 212.7 26.8% 83.9%; | ||
} | ||
} | ||
|
||
@layer base { | ||
* { | ||
@apply border-border; | ||
} | ||
body { | ||
@apply bg-background text-foreground; | ||
} | ||
} |
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,4 +1,5 @@ | ||
{ | ||
"$schema": "https://shadcn-vue.com/schema.json", | ||
"style": "default", | ||
"typescript": true, | ||
"tailwind": { | ||
|
23 changes: 13 additions & 10 deletions
23
packages/module/playground/components/ui/button/Button.vue
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,23 +1,26 @@ | ||
<script setup lang="ts"> | ||
import { buttonVariants } from '.' | ||
import type { HTMLAttributes } from 'vue' | ||
import { Primitive, type PrimitiveProps } from 'radix-vue' | ||
import { type ButtonVariants, buttonVariants } from '.' | ||
import { cn } from '@/lib/utils' | ||
interface Props { | ||
variant?: NonNullable<Parameters<typeof buttonVariants>[0]>['variant'] | ||
size?: NonNullable<Parameters<typeof buttonVariants>[0]>['size'] | ||
as?: string | ||
interface Props extends PrimitiveProps { | ||
variant?: ButtonVariants['variant'] | ||
size?: ButtonVariants['size'] | ||
class?: HTMLAttributes['class'] | ||
} | ||
withDefaults(defineProps<Props>(), { | ||
const props = withDefaults(defineProps<Props>(), { | ||
as: 'button', | ||
}) | ||
</script> | ||
|
||
<template> | ||
<component | ||
:is="as" | ||
:class="cn(buttonVariants({ variant, size }), $attrs.class ?? '')" | ||
<Primitive | ||
:as="as" | ||
:as-child="asChild" | ||
:class="cn(buttonVariants({ variant, size }), props.class)" | ||
> | ||
<slot /> | ||
</component> | ||
</Primitive> | ||
</template> |
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
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
Oops, something went wrong.