Skip to content

Commit

Permalink
feat: add playground
Browse files Browse the repository at this point in the history
  • Loading branch information
zyyv committed Mar 4, 2024
1 parent 02f0105 commit a700366
Show file tree
Hide file tree
Showing 15 changed files with 2,239 additions and 54 deletions.
13 changes: 13 additions & 0 deletions playground/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Vite + Vue + TS</title>
</head>
<body>
<div id="app"></div>
<script type="module" src="/src/main.ts"></script>
</body>
</html>
26 changes: 26 additions & 0 deletions playground/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"name": "playground",
"type": "module",
"version": "0.0.0",
"private": true,
"scripts": {
"dev": "vite",
"build": "vue-tsc && vite build",
"preview": "vite preview"
},
"dependencies": {
"@vueuse/core": "^10.9.0",
"vue": "^3.4.19"
},
"devDependencies": {
"@vitejs/plugin-vue": "^5.0.4",
"magic-color": "workspace:*",
"typescript": "^5.2.2",
"unocss": "^0.58.5",
"unocss-preset-useful": "^0.4.1",
"unplugin-auto-import": "^0.17.5",
"unplugin-vue-components": "^0.26.0",
"vite": "^5.1.4",
"vue-tsc": "^2.0.4"
}
}
1 change: 1 addition & 0 deletions playground/public/vite.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
11 changes: 11 additions & 0 deletions playground/src/App.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<script setup lang="ts">
</script>

<template>
<Toggle />
</template>


845 changes: 845 additions & 0 deletions playground/src/auto-imports.d.ts

Large diffs are not rendered by default.

14 changes: 14 additions & 0 deletions playground/src/components.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/* eslint-disable */
/* prettier-ignore */
// @ts-nocheck
// Generated by unplugin-vue-components
// Read more: https://github.com/vuejs/core/pull/3399
export {}

declare module 'vue' {
export interface GlobalComponents {
Item: typeof import('./components/ListColor.vue')['default']
ListColor: typeof import('./components/ListColor.vue')['default']
Toggle: typeof import('./components/Toggle.vue')['default']
}
}
16 changes: 16 additions & 0 deletions playground/src/components/ListColor.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<script setup lang="ts">
import { theme as themes } from 'magic-color'
defineProps<{
theme: ReturnType<typeof themes>
}>()
</script>

<template>
<ul fcc text-white gap-8 mt-10>
<li fccc v-for="(v, k) in theme" :key="k">
<div w-10 h-10 :style="{ backgroundColor: v }"></div>
<span>{{ k }}</span>
</li>
</ul>
</template>
20 changes: 20 additions & 0 deletions playground/src/components/Toggle.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<script setup lang="ts">
import { theme } from 'magic-color'
const color = ref('#d6bbff')
const results = computed(() => {
try {
return theme(color.value)
} catch (e) {
return {} as any
}
})
</script>

<template>
<h1>Magic Color</h1>
<input type="text" v-model="color">

<ListColor :theme="results" />
</template>
6 changes: 6 additions & 0 deletions playground/src/main.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import { createApp } from 'vue'
import App from './App.vue'

Check failure on line 2 in playground/src/main.ts

View workflow job for this annotation

GitHub Actions / typecheck

Cannot find module './App.vue' or its corresponding type declarations.
import 'uno.css'
import './style.css'

createApp(App).mount('#app')
3 changes: 3 additions & 0 deletions playground/src/style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
html,body{
background: #222;
}
9 changes: 9 additions & 0 deletions playground/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"extends": "../tsconfig.json",
"compilerOptions": {
"lib": ["esnext", "dom"],
"types": [
"vite/client"
]
}
}
8 changes: 8 additions & 0 deletions playground/uno.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { defineConfig } from 'unocss'
import { presetUseful } from 'unocss-preset-useful'

export default defineConfig({
presets: [
presetUseful(),
],
})
27 changes: 27 additions & 0 deletions playground/vite.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import UnoCSS from 'unocss/vite'
import Components from 'unplugin-vue-components/vite'
import AutoImport from 'unplugin-auto-import/vite'

// https://vitejs.dev/config/
export default defineConfig({
plugins: [
vue(),
UnoCSS(),
AutoImport({
imports: [
'vue',
'@vueuse/core',
],
dirs: [
'src/composables',
],
vueTemplate: true,
dts: 'src/auto-imports.d.ts',
}),
Components({
dts: 'src/components.d.ts',
}),
],
})

0 comments on commit a700366

Please sign in to comment.