Skip to content

Commit

Permalink
feat(vue): add stater with vuejs
Browse files Browse the repository at this point in the history
  • Loading branch information
johancs.mm@gmail.com committed May 3, 2024
1 parent 64665bd commit 34c2ae6
Show file tree
Hide file tree
Showing 39 changed files with 861 additions and 13 deletions.
1 change: 1 addition & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ export default eslint({
formatters: true,
markdown: true,
typescript: true,
vue: true,
})
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
"lint": "eslint . --fix",
"clean-node-modules": "rimraf ./docs/**/node_modules && rimraf ./packages/**/**/node_modules && rimraf ./node_modules",
"prepare": "husky",
"dev-playground": "turbo dev --filter=@openui-org/playground",
"dev-playground-next": "turbo dev --filter=@openui-org/playground-next",
"dev-playground-vue": "turbo dev --filter=@openui-org/playground-vue",
"dev-docs": "turbo dev --filter=@openui-org/docs",
"sb": "pnpm --filter @openui-org/storybook dev",
"clean": "rm -rf .turbo node_modules pnpm-lock.yaml",
Expand Down
6 changes: 6 additions & 0 deletions packages/components/vue/.npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
*
!package.json
!dist/**/*
!CHANGELOG.md
!README.md
!LICENSE
22 changes: 22 additions & 0 deletions packages/components/vue/button/button.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<script setup lang="ts">
import { button, cn } from '@openui-org/theme'
interface Props {
variant?: NonNullable<Parameters<typeof button>[0]>['variant']
size?: NonNullable<Parameters<typeof button>[0]>['size']
as?: string
}
withDefaults(defineProps<Props>(), {
as: 'button',
})
</script>

<template>
<component
:is="as"
:class="cn(button({ variant, size }), $attrs.class ?? '')"
>
<slot />
</component>
</template>
1 change: 1 addition & 0 deletions packages/components/vue/button/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { default as Button } from './button.vue'
1 change: 1 addition & 0 deletions packages/components/vue/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './button'
40 changes: 33 additions & 7 deletions packages/components/vue/package.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,38 @@
{
"name": "@openui-org/vue",
"version": "1.0.0",
"description": "",
"author": "",
"license": "ISC",
"keywords": [],
"main": "index.js",
"type": "module",
"version": "0.1.0",
"description": "Open UI. OpenLand's official framework design system 🎨",
"author": "Open Lab",
"license": "MIT",
"homepage": "https://github.com/open-land/openui#readme",
"repository": {
"type": "git",
"url": "git+https://github.com/open-land/openui.git"
},
"bugs": {
"url": "https://github.com/open-land/openui/issues"
},
"keywords": [
"ui",
"design system",
"open"
],
"sideEffects": false,
"main": "./dist/index.es.js",
"module": "./dist/index.es.js",
"types": "./dist/types/index.d.ts",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
"build": "vue-tsc && vite build",
"clean": "rm -rf .turbo node_modules dist"
},
"dependencies": {
"@openui-org/theme": "workspace:*",
"vue": "^3.4.26"
},
"devDependencies": {
"@vitejs/plugin-vue": "^5.0.4",
"vite": "^4.4.7",
"vue-tsc": "^2.0.16"
}
}
34 changes: 34 additions & 0 deletions packages/components/vue/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{
"compilerOptions": {
"target": "ES2020",
"jsx": "preserve",
"lib": ["ES2020", "DOM", "DOM.Iterable"],
"useDefineForClassFields": true,

"baseUrl": ".",
"module": "ESNext",

/* Bundler mode */
"moduleResolution": "bundler",
"paths": {
"~/*": ["src/*"]
},
"resolveJsonModule": true,
"allowImportingTsExtensions": true,

/* Linting */
"strict": true,
"noFallthroughCasesInSwitch": true,
"noUnusedLocals": true,
"noUnusedParameters": true,

/* Build Declaration */
"declaration": true,
"declarationDir": "./dist/types",
"emitDeclarationOnly": true,
"isolatedModules": true,
"skipLibCheck": true
},
"references": [{ "path": "./tsconfig.node.json" }],
"include": ["*.ts", "*.tsx", "*.vue"]
}
10 changes: 10 additions & 0 deletions packages/components/vue/tsconfig.node.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"compilerOptions": {
"composite": true,
"module": "ESNext",
"moduleResolution": "bundler",
"allowSyntheticDefaultImports": true,
"skipLibCheck": true
},
"include": ["vite.config.ts"]
}
24 changes: 24 additions & 0 deletions packages/components/vue/vite.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'

export default defineConfig({
plugins: [vue()],
build: {
lib: {
name: 'vue',
entry: './index.ts',
formats: ['es'],
fileName(entryName) {
return `index.${entryName}.js`
},
},
rollupOptions: {
external: ['vue'],
output: {
exports: 'named',
globals: { vue: 'Vue' },
},
},
emptyOutDir: false,
},
})
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "@openui-org/playground",
"name": "@openui-org/playground-next",
"version": "0.1.0",
"private": true,
"scripts": {
Expand Down
File renamed without changes.
24 changes: 24 additions & 0 deletions packages/utilities/playground/vue/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*
lerna-debug.log*

node_modules
dist
dist-ssr
*.local

# Editor directories and files
.vscode/*
!.vscode/extensions.json
.idea
.DS_Store
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?
9 changes: 9 additions & 0 deletions packages/utilities/playground/vue/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Vue 3 + TypeScript + Vite

This template should help get you started developing with Vue 3 and TypeScript in Vite. The template uses Vue 3 `<script setup>` SFCs, check out the [script setup docs](https://v3.vuejs.org/api/sfc-script-setup.html#sfc-script-setup) to learn more.

## Recommended Setup

- [VS Code](https://code.visualstudio.com/) + [Vue - Official](https://marketplace.visualstudio.com/items?itemName=Vue.volar) (previously Volar) and disable Vetur

- Use [vue-tsc](https://github.com/vuejs/language-tools/tree/master/packages/tsc) for performing the same type checking from the command line, or for generating d.ts files for SFCs.
13 changes: 13 additions & 0 deletions packages/utilities/playground/vue/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>
25 changes: 25 additions & 0 deletions packages/utilities/playground/vue/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"name": "@openui-org/playground-vue",
"type": "module",
"version": "0.1.0",
"private": true,
"scripts": {
"dev": "vite",
"build": "vue-tsc && vite build",
"preview": "vite preview"
},
"dependencies": {
"@openui-org/theme": "workspace:*",
"@openui-org/vue": "workspace:*",
"vue": "^3.4.21"
},
"devDependencies": {
"@vitejs/plugin-vue": "^5.0.4",
"autoprefixer": "10.4.19",
"postcss": "8.4.38",
"tailwindcss": "3.4.3",
"typescript": "^5.2.2",
"vite": "^5.2.0",
"vue-tsc": "^2.0.6"
}
}
6 changes: 6 additions & 0 deletions packages/utilities/playground/vue/postcss.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
export default {
plugins: {
tailwindcss: {},
autoprefixer: {},
},
}
1 change: 1 addition & 0 deletions packages/utilities/playground/vue/public/vite.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
34 changes: 34 additions & 0 deletions packages/utilities/playground/vue/src/App.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<script setup lang="ts">
import { Button } from '@openui-org/vue'
import HelloWorld from './components/HelloWorld.vue'
</script>

<template>
<div>
<a href="https://vitejs.dev" target="_blank">
<img src="/vite.svg" class="logo" alt="Vite logo">
</a>
<a href="https://vuejs.org/" target="_blank">
<img src="./assets/vue.svg" class="logo vue" alt="Vue logo">
</a>
</div>
<HelloWorld msg="Vite + Vue" />
<Button>
Hello vue
</Button>
</template>

<style scoped>
.logo {
height: 6em;
padding: 1.5em;
will-change: filter;
transition: filter 300ms;
}
.logo:hover {
filter: drop-shadow(0 0 2em #646cffaa);
}
.logo.vue:hover {
filter: drop-shadow(0 0 2em #42b883aa);
}
</style>
1 change: 1 addition & 0 deletions packages/utilities/playground/vue/src/assets/vue.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
40 changes: 40 additions & 0 deletions packages/utilities/playground/vue/src/components/HelloWorld.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<script setup lang="ts">
import { ref } from 'vue'
defineProps<{ msg: string }>()
const count = ref(0)
</script>

<template>
<h1>{{ msg }}</h1>

<div class="card">
<button type="button" @click="count++">
count is {{ count }}
</button>
<p>
Edit
<code>components/HelloWorld.vue</code> to test HMR
</p>
</div>

<p>
Check out
<a href="https://vuejs.org/guide/quick-start.html#local" target="_blank">create-vue</a>, the official Vue + Vite starter
</p>
<p>
Install
<a href="https://github.com/vuejs/language-tools" target="_blank">Volar</a>
in your IDE for a better DX
</p>
<p class="read-the-docs">
Click on the Vite and Vue logos to learn more
</p>
</template>

<style scoped>
.read-the-docs {
color: #888;
}
</style>
5 changes: 5 additions & 0 deletions packages/utilities/playground/vue/src/main.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { createApp } from 'vue'
import './style.css'
import App from './App.vue'

createApp(App).mount('#app')
3 changes: 3 additions & 0 deletions packages/utilities/playground/vue/src/style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
@tailwind base;
@tailwind components;
@tailwind utilities;
1 change: 1 addition & 0 deletions packages/utilities/playground/vue/src/vite-env.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/// <reference types="vite/client" />
25 changes: 25 additions & 0 deletions packages/utilities/playground/vue/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"compilerOptions": {
"target": "ES2020",
"jsx": "preserve",
"lib": ["ES2020", "DOM", "DOM.Iterable"],
"useDefineForClassFields": true,
"module": "ESNext",

/* Bundler mode */
"moduleResolution": "bundler",
"resolveJsonModule": true,
"allowImportingTsExtensions": true,

/* Linting */
"strict": true,
"noFallthroughCasesInSwitch": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"noEmit": true,
"isolatedModules": true,
"skipLibCheck": true
},
"references": [{ "path": "./tsconfig.node.json" }],
"include": ["src/**/*.ts", "src/**/*.tsx", "src/**/*.vue"]
}
11 changes: 11 additions & 0 deletions packages/utilities/playground/vue/tsconfig.node.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"compilerOptions": {
"composite": true,
"module": "ESNext",
"moduleResolution": "bundler",
"strict": true,
"allowSyntheticDefaultImports": true,
"skipLibCheck": true
},
"include": ["vite.config.ts"]
}
7 changes: 7 additions & 0 deletions packages/utilities/playground/vue/vite.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'

// https://vitejs.dev/config/
export default defineConfig({
plugins: [vue()],
})
Loading

0 comments on commit 34c2ae6

Please sign in to comment.