Skip to content

Commit

Permalink
chore(playground): feat auto import playground component (#391)
Browse files Browse the repository at this point in the history
* feat: auto generate playground

* chore: add scripts

* fix: auto import

* fix: nuxt
  • Loading branch information
productdevbook committed Sep 29, 2023
1 parent 471f442 commit 1aebd09
Show file tree
Hide file tree
Showing 77 changed files with 1,089 additions and 1,367 deletions.
1 change: 1 addition & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ pnpm test testfilename # Run a specific test file name
pnpm play # Run the playground
pnpm play:vue # Run the playground with Vue
pnpm play:nuxt # Run the playground with Nuxt
pnpm play:gencomponents # Run the playground with GenComponents

pnpm clean: all # Clean all node_modules
pnpm clean:dist # Clean dist folder in all packages
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
"play:vue": "pnpm clean:dts && pnpm --filter=vue3 p:dev",
"play:nuxt": "pnpm clean:dts && pnpm --filter=nuxt3 p:dev",
"play": "pnpm clean:dts && pnpm --filter='./playground/**' p:dev",
"play:gencomponents": "pnpm jiti ./scripts/playground-generator.ts",
"postinstall": "simple-git-hooks",
"test": "vitest run",
"test:watch": "vitest --watch",
Expand Down
16 changes: 15 additions & 1 deletion playground/nuxt3/app.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,19 @@
<template>
<div class="w-full h-full p-4">
<div class="home">
<NuxtPage />
</div>
</template>

<style>
html, body {
margin: 0;
padding: 0;
font-family: sans-serif;
width: 100%;
height: 100%;
}
.home {
padding: 20px;
}
</style>
126 changes: 126 additions & 0 deletions playground/nuxt3/components.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
[
{
"name": "AccordionDemo",
"path": "/accordion"
},
{
"name": "AlertDialogDemo",
"path": "/alert-dialog"
},
{
"name": "AspectRatioDemo",
"path": "/aspect-ratio"
},
{
"name": "AvatarDemo",
"path": "/avatar"
},
{
"name": "CheckboxDemo",
"path": "/checkbox"
},
{
"name": "CollapsibleDemo",
"path": "/collapsible"
},
{
"name": "DialogDemo",
"path": "/dialog"
},
{
"name": "HoverCardDemo",
"path": "/hover-card"
},
{
"name": "LabelDemo",
"path": "/label"
},
{
"name": "PopoverDemo",
"path": "/popover"
},
{
"name": "ProgressDemo",
"path": "/progress"
},
{
"name": "RadioGroupDemo",
"path": "/radio-group"
},
{
"name": "SeparatorDemo",
"path": "/separator"
},
{
"name": "SliderDemo",
"path": "/slider"
},
{
"name": "SwitchDemo",
"path": "/switch"
},
{
"name": "TabsDemo",
"path": "/tabs"
},
{
"name": "ToastDemo",
"path": "/toast"
},
{
"name": "ToggleDemo",
"path": "/toggle"
},
{
"name": "ToggleGroupDemo",
"path": "/toggle-group"
},
{
"name": "ToolbarDemo",
"path": "/toolbar"
},
{
"name": "TooltipDemo",
"path": "/tooltip"
},
{
"name": "ArrowDemo",
"path": "/arrow"
},
{
"name": "CollectionDemo",
"path": "/collection"
},
{
"name": "DismissableLayerDemo",
"path": "/dismissable-layer"
},
{
"name": "FocusScopeDemo",
"path": "/focus-scope"
},
{
"name": "PopperDemo",
"path": "/popper"
},
{
"name": "PortalDemo",
"path": "/portal"
},
{
"name": "PresenceDemo",
"path": "/presence"
},
{
"name": "RovingFocusDemo",
"path": "/roving-focus"
},
{
"name": "SlotDemo",
"path": "/slot"
},
{
"name": "VisuallyHiddenDemo",
"path": "/visually-hidden"
}
]
20 changes: 17 additions & 3 deletions playground/nuxt3/nuxt.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,27 @@ import { resolve } from 'pathe'
// https://nuxt.com/docs/api/configuration/nuxt-config
export default defineNuxtConfig({
modules: [
'@nuxtjs/tailwindcss',
async () => {
const components = globbySync('../../packages/components/**/src/stories/*.@(vue)')
const components = globbySync('../../packages/components/**/src/stories/*Demo.vue', {
ignore: ['**/node_modules/**', '**/dist/**', '**/node_modules/@oku-ui/**'],
deep: 4,
})
if (components.length > 0) {
components.forEach((component) => {
// LabelDemo.vue -> LabelDemo
addComponent({ filePath: resolve(component), name: component.split('/').pop()!.replace('.vue', '') })
addComponent({ filePath: resolve(component), name: component.split('/').pop()!.replace('.vue', ''), priority: 1 })
})
}

const core = globbySync('../../packages/core/**/src/stories/*Demo.vue', {
ignore: ['**/node_modules/**', '**/dist/**', '**/node_modules/@oku-ui/**'],
deep: 4,
})

if (core.length > 0) {
core.forEach((component) => {
// LabelDemo.vue -> LabelDemo
addComponent({ filePath: resolve(component), name: component.split('/').pop()!.replace('.vue', ''), priority: 2 })
})
}
},
Expand Down
22 changes: 19 additions & 3 deletions playground/nuxt3/package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"name": "nuxt3-playground",
"type": "module",
"private": true,
"scripts": {
"p:build": "nuxt build",
Expand All @@ -11,14 +12,26 @@
"lint:fix": "eslint . --fix"
},
"dependencies": {
"@oku-ui/accordion": "workspace:^",
"@oku-ui/alert-dialog": "workspace:^",
"@oku-ui/arrow": "workspace:^",
"@oku-ui/aspect-ratio": "workspace:^",
"@oku-ui/avatar": "workspace:^",
"@oku-ui/checkbox": "workspace:^",
"@oku-ui/collapsible": "workspace:^",
"@oku-ui/collection": "workspace:^",
"@oku-ui/dialog": "workspace:^",
"@oku-ui/dismissable-layer": "workspace:^",
"@oku-ui/focus-scope": "workspace:^",
"@oku-ui/hover-card": "workspace:^",
"@oku-ui/label": "workspace:^",
"@oku-ui/popover": "workspace:^",
"@oku-ui/popper": "workspace:^",
"@oku-ui/portal": "workspace:^",
"@oku-ui/presence": "workspace:^",
"@oku-ui/primitives": "workspace:^",
"@oku-ui/progress": "workspace:^",
"@oku-ui/radio-group": "workspace:^",
"@oku-ui/roving-focus": "workspace:^",
"@oku-ui/scroll-area": "workspace:^",
"@oku-ui/separator": "workspace:^",
Expand All @@ -27,11 +40,14 @@
"@oku-ui/switch": "workspace:^",
"@oku-ui/tabs": "workspace:^",
"@oku-ui/toast": "workspace:^",
"@oku-ui/toggle": "workspace:^",
"@oku-ui/toggle-group": "workspace:^",
"@oku-ui/toolbar": "workspace:^",
"@oku-ui/tooltip": "workspace:^",
"@oku-ui/visually-hidden": "workspace:^"
},
"devDependencies": {
"@nuxtjs/tailwindcss": "^6.8.0",
"@types/node": "^18.17.17",
"nuxt": "^3.7.3"
"@types/node": "^20.7.0",
"nuxt": "^3.7.4"
}
}
3 changes: 3 additions & 0 deletions playground/nuxt3/pages/accordion.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<template>
<div><AccordionDemo allshow /></div>
</template>
3 changes: 3 additions & 0 deletions playground/nuxt3/pages/alert-dialog.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<template>
<div><AlertDialogDemo allshow /></div>
</template>
7 changes: 1 addition & 6 deletions playground/nuxt3/pages/arrow.vue
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
<script setup lang="ts">
</script>

<template>
<div>
<ArrowDemo :allshow="true" />
</div>
<div><ArrowDemo allshow /></div>
</template>
7 changes: 1 addition & 6 deletions playground/nuxt3/pages/aspect-ratio.vue
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
<script setup lang="ts">
</script>

<template>
<div>
<AspectRatioDemo :allshow="true" />
</div>
<div><AspectRatioDemo allshow /></div>
</template>
7 changes: 1 addition & 6 deletions playground/nuxt3/pages/avatar.vue
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
<script setup lang="ts">
</script>

<template>
<div class="mt-4">
<AvatarDemo :allshow="true" />
</div>
<div><AvatarDemo allshow /></div>
</template>
6 changes: 1 addition & 5 deletions playground/nuxt3/pages/checkbox.vue
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
<script setup lang="ts">
</script>

<template>
<CheckboxDemo allshow />
<div><CheckboxDemo allshow /></div>
</template>
4 changes: 1 addition & 3 deletions playground/nuxt3/pages/collapsible.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
<template>
<div>
<CollapsibleDemo allshow />
</div>
<div><CollapsibleDemo allshow /></div>
</template>
4 changes: 1 addition & 3 deletions playground/nuxt3/pages/collection.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
<template>
<div>
<CollectionDemo allshow />
</div>
<div><CollectionDemo allshow /></div>
</template>
8 changes: 1 addition & 7 deletions playground/nuxt3/pages/dialog.vue
Original file line number Diff line number Diff line change
@@ -1,9 +1,3 @@
<script setup lang="ts">
</script>

<template>
<div>
<DialogDemo :allshow="true" />
</div>
<div><DialogDemo allshow /></div>
</template>
8 changes: 1 addition & 7 deletions playground/nuxt3/pages/dismissable-layer.vue
Original file line number Diff line number Diff line change
@@ -1,9 +1,3 @@
<script setup lang="ts">
</script>

<template>
<div>
<DismissableLayerDemo :allshow="true" />
</div>
<div><DismissableLayerDemo allshow /></div>
</template>
8 changes: 1 addition & 7 deletions playground/nuxt3/pages/focus-scope.vue
Original file line number Diff line number Diff line change
@@ -1,9 +1,3 @@
<script setup lang="ts">
</script>

<template>
<div>
<FocusScopeDemo :allshow="true" />
</div>
<div><FocusScopeDemo allshow /></div>
</template>
8 changes: 1 addition & 7 deletions playground/nuxt3/pages/hover-card.vue
Original file line number Diff line number Diff line change
@@ -1,9 +1,3 @@
<script setup lang="ts">
</script>

<template>
<div>
<HoverCardDemo :allshow="true" />
</div>
<div><HoverCardDemo allshow /></div>
</template>
Loading

0 comments on commit 1aebd09

Please sign in to comment.