Skip to content

Commit 834b9ad

Browse files
author
Erik Hanchett
committed
first commit
1 parent 23b658c commit 834b9ad

17 files changed

+807
-170
lines changed

.eslintrc.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ module.exports = {
44
node: true
55
},
66
'extends': [
7-
'plugin:vue/essential',
7+
'plugin:vue/vue3-essential',
88
'eslint:recommended',
99
'@vue/typescript/recommended'
1010
],

package-lock.json

+648-38
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+7-5
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@
99
},
1010
"dependencies": {
1111
"core-js": "^3.6.5",
12-
"vue": "^2.6.11",
13-
"vue-router": "^3.2.0",
14-
"vuex": "^3.4.0"
12+
"vue": "^3.0.0-rc.4",
13+
"vue-router": "^4.0.0-beta.4",
14+
"vuex": "^4.0.0-beta.4"
1515
},
1616
"devDependencies": {
1717
"@typescript-eslint/eslint-plugin": "^2.33.0",
@@ -22,10 +22,12 @@
2222
"@vue/cli-plugin-typescript": "~4.4.0",
2323
"@vue/cli-plugin-vuex": "~4.4.0",
2424
"@vue/cli-service": "~4.4.0",
25+
"@vue/compiler-sfc": "^3.0.0-beta.1",
2526
"@vue/eslint-config-typescript": "^5.0.2",
2627
"eslint": "^6.7.2",
27-
"eslint-plugin-vue": "^6.2.2",
28+
"eslint-plugin-vue": "^7.0.0-alpha.0",
2829
"typescript": "~3.9.3",
29-
"vue-template-compiler": "^2.6.11"
30+
"vue-cli-plugin-tailwind": "~1.4.1",
31+
"vue-cli-plugin-vue-next": "~0.1.3"
3032
}
3133
}

postcss.config.js

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
module.exports = {
2+
plugins: {
3+
tailwindcss: {},
4+
'vue-cli-plugin-tailwind/purgecss': {},
5+
autoprefixer: {}
6+
}
7+
}

src/App.vue

+10-3
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,16 @@
11
<template>
2-
<div id="app">
2+
<div id="app" class="mt-20">
3+
<router-view />
34
<div id="nav">
4-
<router-link to="/">Home</router-link> |
5+
<router-link to="/">Home</router-link>|
56
<router-link to="/about">About</router-link>
67
</div>
7-
<router-view/>
88
</div>
99
</template>
1010

1111
<style>
1212
#app {
13+
text-align: center;
1314
font-family: Avenir, Helvetica, Arial, sans-serif;
1415
-webkit-font-smoothing: antialiased;
1516
-moz-osx-font-smoothing: grayscale;
@@ -18,7 +19,13 @@
1819
}
1920
2021
#nav {
22+
position: absolute;
23+
left: 0;
24+
right: 0;
25+
margin: auto;
26+
bottom: 0;
2127
padding: 30px;
28+
text-align: center;
2229
}
2330
2431
#nav a {

src/assets/tailwind.css

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
@tailwind base;
2+
3+
@tailwind components;
4+
5+
@tailwind utilities;

src/components/Counter.vue

+55
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
<template>
2+
<div class="hello">
3+
<div class="bg-gray-300 h-64 w-4/6 mx-auto shadow-md flex flex-col justify-center items-center">
4+
<h3 class="text-xl font-semibold">Increment Counter</h3>
5+
<button
6+
class="bg-red-500 text-blue-900 border rounded-lg px-8 m-4 h-10 text-2xl font-bold focus:outline-none"
7+
@click="inc()"
8+
>Press Me</button>
9+
<h5 class="text-3xl">Counter: {{count.counter}}</h5>
10+
</div>
11+
</div>
12+
</template>
13+
14+
<script lang="ts">
15+
import { defineComponent, ref } from "vue";
16+
import { useStore } from "vuex";
17+
18+
export default defineComponent({
19+
setup() {
20+
const store = useStore();
21+
const count = ref(store.state);
22+
const inc = () => {
23+
store.commit("increment");
24+
};
25+
26+
return {
27+
count,
28+
inc,
29+
};
30+
},
31+
name: "HelloWorld",
32+
props: {
33+
msg: String,
34+
},
35+
methods: {},
36+
});
37+
</script>
38+
39+
<!-- Add "scoped" attribute to limit CSS to this component only -->
40+
<style scoped>
41+
h3 {
42+
margin: 40px 0 0;
43+
}
44+
ul {
45+
list-style-type: none;
46+
padding: 0;
47+
}
48+
li {
49+
display: inline-block;
50+
margin: 0 10px;
51+
}
52+
a {
53+
color: #42b983;
54+
}
55+
</style>

src/components/HelloWorld.vue

-63
This file was deleted.

src/main.ts

+9-11
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
1-
import Vue from 'vue'
2-
import App from './App.vue'
3-
import router from './router'
4-
import store from './store'
1+
import { createApp } from "vue";
2+
import App from "./App.vue";
3+
import router from "./router";
4+
import { store } from "./store";
5+
import "./assets/tailwind.css";
56

6-
Vue.config.productionTip = false
7-
8-
new Vue({
9-
router,
10-
store,
11-
render: h => h(App)
12-
}).$mount('#app')
7+
createApp(App)
8+
.use(router)
9+
.use(store)
10+
.mount("#app");

src/router/index.ts

+14-17
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,26 @@
1-
import Vue from 'vue'
2-
import VueRouter, { RouteConfig } from 'vue-router'
3-
import Home from '../views/Home.vue'
1+
import { RouteRecordRaw, createRouter, createWebHistory } from "vue-router";
2+
import Home from "../views/Home.vue";
43

5-
Vue.use(VueRouter)
6-
7-
const routes: Array<RouteConfig> = [
4+
const routes: Array<RouteRecordRaw> = [
85
{
9-
path: '/',
10-
name: 'Home',
6+
path: "/",
7+
name: "Home",
118
component: Home
129
},
1310
{
14-
path: '/about',
15-
name: 'About',
11+
path: "/about",
12+
name: "About",
1613
// route level code-splitting
1714
// this generates a separate chunk (about.[hash].js) for this route
1815
// which is lazy-loaded when the route is visited.
19-
component: () => import(/* webpackChunkName: "about" */ '../views/About.vue')
16+
component: () =>
17+
import(/* webpackChunkName: "about" */ "../views/About.vue")
2018
}
21-
]
19+
];
2220

23-
const router = new VueRouter({
24-
mode: 'history',
25-
base: process.env.BASE_URL,
21+
const router = createRouter({
22+
history: createWebHistory(process.env.BASE_URL),
2623
routes
27-
})
24+
});
2825

29-
export default router
26+
export default router;

src/shims-tsx.d.ts

-13
This file was deleted.

src/shims-vue.d.ts

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
declare module '*.vue' {
2-
import Vue from 'vue'
3-
export default Vue
1+
declare module "*.vue" {
2+
import { ComponentOptions } from "vue";
3+
const component: ComponentOptions;
4+
export default component;
45
}

src/shims-vuex.d.ts

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import { Store } from "vuex";
2+
import { State } from "./store";
3+
4+
declare module "@vue/runtime-core" {
5+
interface ComponentCustomProperties {
6+
$store: Store<State>;
7+
}
8+
}
9+
10+
// [email protected] is missing the typing for `useStore`. See https://github.com/vuejs/vuex/issues/1736
11+
declare module "vuex" {
12+
export function useStore(key?: string): Store<State>;
13+
}

src/store/index.ts

+20-9
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,26 @@
1-
import Vue from 'vue'
2-
import Vuex from 'vuex'
1+
import { createStore } from "vuex";
32

4-
Vue.use(Vuex)
3+
export type State = { counter: number };
54

6-
export default new Vuex.Store({
7-
state: {
8-
},
5+
const state: State = { counter: 0 };
6+
7+
export const store = createStore({
8+
state,
99
mutations: {
10+
increment(state, payload) {
11+
state.counter++;
12+
}
1013
},
1114
actions: {
15+
increment({ commit }) {
16+
commit("increment");
17+
}
18+
},
19+
20+
getters: {
21+
counter(state) {
22+
return state.counter;
23+
}
1224
},
13-
modules: {
14-
}
15-
})
25+
modules: {}
26+
});

src/views/About.vue

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<template>
22
<div class="about">
3-
<h1>This is an about page</h1>
3+
<h1>Counter: {{$store.getters.counter}}</h1>
44
</div>
55
</template>

src/views/Home.vue

+5-6
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,17 @@
11
<template>
22
<div class="home">
3-
<img alt="Vue logo" src="../assets/logo.png">
4-
<HelloWorld msg="Welcome to Your Vue.js App"/>
3+
<Counter msg="Welcome to Your Vue.js App" />
54
</div>
65
</template>
76

87
<script>
98
// @ is an alias to /src
10-
import HelloWorld from '@/components/HelloWorld.vue'
9+
import Counter from "@/components/Counter.vue";
1110
1211
export default {
13-
name: 'Home',
12+
name: "Home",
1413
components: {
15-
HelloWorld
14+
Counter
1615
}
17-
}
16+
};
1817
</script>

tailwind.config.js

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
module.exports = {
2+
purge: [],
3+
theme: {
4+
extend: {},
5+
},
6+
variants: {},
7+
plugins: [],
8+
}

0 commit comments

Comments
 (0)