Skip to content

Commit

Permalink
Feat/vue init (#100)
Browse files Browse the repository at this point in the history
* feat: 🎸 vue init

* chore: 🤖 added changeset

* fix: 🐛 removed build from example

* fix: 🐛 ci issue

* fix: 🐛 types and example-vue

* fix: 🐛 pnpm-lock

* fix: 🐛 pr review comments

* fix: 🐛 readme example

* fix: 🐛 typo in readme
  • Loading branch information
afsalz authored Jan 12, 2024
1 parent 4bbb729 commit 079cc00
Show file tree
Hide file tree
Showing 25 changed files with 1,369 additions and 29 deletions.
5 changes: 5 additions & 0 deletions .changeset/soft-seas-wink.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@lottiefiles/dotlottie-vue': minor
---

feat: dotlottie-vue init release
6 changes: 6 additions & 0 deletions .size-limit.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,12 @@ module.exports = [
import: '*',
modifyWebpackConfig,
},
{
name: '@lottiefiles/dotlottie-vue',
path: 'packages/vue/dist/index.js',
import: '*',
modifyWebpackConfig,
},
{
name: '@lottiefiles/dotlottie-wc',
path: 'packages/wc/dist/index.js',
Expand Down
14 changes: 14 additions & 0 deletions apps/dotlottie-vue-example/.eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
module.exports = {
root: true,
parser: 'vue-eslint-parser',
parserOptions: {
parser: '@typescript-eslint/parser',
},
extends: ['plugin:vue/strongly-recommended', 'eslint:recommended', '@vue/typescript/recommended', 'prettier'],
plugins: ['@typescript-eslint', 'prettier'],
rules: {
'prettier/prettier': 'error',
// not needed for vue 3
'vue/no-multiple-template-root': 'off',
},
};
24 changes: 24 additions & 0 deletions apps/dotlottie-vue-example/.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?
3 changes: 3 additions & 0 deletions apps/dotlottie-vue-example/.vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"recommendations": ["Vue.volar", "Vue.vscode-typescript-vue-plugin"]
}
13 changes: 13 additions & 0 deletions apps/dotlottie-vue-example/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>
30 changes: 30 additions & 0 deletions apps/dotlottie-vue-example/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{
"name": "dotlottie-vue-example",
"version": "0.0.0",
"type": "module",
"private": true,
"scripts": {
"build": "vue-tsc && vite build",
"dev": "vite",
"lint": "eslint . --ext ts,tsx --report-unused-disable-directives --max-warnings 0",
"preview": "vite preview"
},
"dependencies": {
"@lottiefiles/dotlottie-vue": "workspace:*",
"vue": "^3.3.11"
},
"devDependencies": {
"@typescript-eslint/eslint-plugin": "^6.10.0",
"@typescript-eslint/parser": "^6.10.0",
"@vitejs/plugin-vue": "^4.5.2",
"@vue/eslint-config-typescript": "^12.0.0",
"eslint": "^8.56.0",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-prettier": "^5.1.3",
"eslint-plugin-vue": "^9.20.0",
"typescript": "^5.2.2",
"vite": "^5.0.8",
"vue-eslint-parser": "^9.4.0",
"vue-tsc": "^1.8.25"
}
}
1 change: 1 addition & 0 deletions apps/dotlottie-vue-example/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.
67 changes: 67 additions & 0 deletions apps/dotlottie-vue-example/src/App.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
<script setup lang="ts">
import { Ref, onMounted, ref } from 'vue';
import { DotLottieVue } from '@lottiefiles/dotlottie-vue';
const player: Ref<typeof DotLottieVue | null> = ref(null);
function toggleLoop() {
const dotLottie = player.value?.getDotLottieInstance();
dotLottie.setLoop(!dotLottie.loop);
}
function play() {
player.value?.getDotLottieInstance().play();
}
function pause() {
player.value?.getDotLottieInstance().pause();
}
function stop() {
player.value?.getDotLottieInstance().stop();
}
onMounted(() => {
if (player.value) {
const dotLottie = player.value?.getDotLottieInstance();
dotLottie.addEventListener('play', () => {
console.log('play');
});
dotLottie.addEventListener('stop', () => {
console.log('stop');
});
dotLottie.addEventListener('pause', () => {
console.log('paused');
});
// dotLottie.addEventListener('frame', ({currentFrame}) => {
// console.log('Frame:', currentFrame)
// });
dotLottie.addEventListener('complete', () => {
console.log('completed');
});
}
});
</script>

<template>
<DotLottieVue
background-color="#222"
style="height: 500px; width: 500px"
autoplay
loop
ref="player"
src="https://lottie.host/5525262b-4e57-4f0a-8103-cfdaa7c8969e/VCYIkooYX8.json"
/>
<div class="btn-group">
<button @click="toggleLoop">Toggle Loop</button>
<button @click="stop">Stop</button>
<button @click="pause">Pause</button>
<button @click="play">Play</button>
</div>
</template>

<style scoped>
.btn-group {
display: flex;
justify-content: center;
flex-wrap: wrap;
gap: 0.5rem;
}
</style>
1 change: 1 addition & 0 deletions apps/dotlottie-vue-example/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.
37 changes: 37 additions & 0 deletions apps/dotlottie-vue-example/src/components/HelloWorld.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<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 apps/dotlottie-vue-example/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');
79 changes: 79 additions & 0 deletions apps/dotlottie-vue-example/src/style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
:root {
font-family: Inter, system-ui, Avenir, Helvetica, Arial, sans-serif;
line-height: 1.5;
font-weight: 400;

color-scheme: light dark;
color: rgba(255, 255, 255, 0.87);
background-color: #242424;

font-synthesis: none;
text-rendering: optimizeLegibility;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}

a {
font-weight: 500;
color: #646cff;
text-decoration: inherit;
}
a:hover {
color: #535bf2;
}

body {
margin: 0;
display: flex;
place-items: center;
min-width: 320px;
min-height: 100vh;
}

h1 {
font-size: 3.2em;
line-height: 1.1;
}

button {
border-radius: 8px;
border: 1px solid transparent;
padding: 0.6em 1.2em;
font-size: 1em;
font-weight: 500;
font-family: inherit;
background-color: #1a1a1a;
cursor: pointer;
transition: border-color 0.25s;
}
button:hover {
border-color: #646cff;
}
button:focus,
button:focus-visible {
outline: 4px auto -webkit-focus-ring-color;
}

.card {
padding: 2em;
}

#app {
max-width: 1280px;
margin: 0 auto;
padding: 2rem;
text-align: center;
}

@media (prefers-color-scheme: light) {
:root {
color: #213547;
background-color: #ffffff;
}
a:hover {
color: #747bff;
}
button {
background-color: #f9f9f9;
}
}
1 change: 1 addition & 0 deletions apps/dotlottie-vue-example/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 apps/dotlottie-vue-example/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"compilerOptions": {
"target": "ES2020",
"useDefineForClassFields": true,
"module": "ESNext",
"lib": ["ES2020", "DOM", "DOM.Iterable"],
"skipLibCheck": true,

/* Bundler mode */
"moduleResolution": "bundler",
"allowImportingTsExtensions": true,
"resolveJsonModule": true,
"isolatedModules": true,
"noEmit": true,
"jsx": "preserve",

/* Linting */
"strict": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"noFallthroughCasesInSwitch": true
},
"include": ["src/**/*.ts", "src/**/*.tsx", "src/**/*.vue"],
"references": [{ "path": "./tsconfig.node.json" }]
}
10 changes: 10 additions & 0 deletions apps/dotlottie-vue-example/tsconfig.node.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"compilerOptions": {
"composite": true,
"skipLibCheck": true,
"module": "ESNext",
"moduleResolution": "bundler",
"allowSyntheticDefaultImports": true
},
"include": ["vite.config.ts"]
}
7 changes: 7 additions & 0 deletions apps/dotlottie-vue-example/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 079cc00

Please sign in to comment.