Skip to content

Commit 3ae3052

Browse files
committed
working on library card and data format
1 parent cecbcc6 commit 3ae3052

File tree

14 files changed

+470
-102
lines changed

14 files changed

+470
-102
lines changed

package-lock.json

Lines changed: 283 additions & 83 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,10 @@
99
},
1010
"dependencies": {
1111
"core-js": "^3.6.5",
12-
"vue": "^2.6.11"
12+
"tailwindcss": "^1.4.6",
13+
"vue": "^2.6.11",
14+
"vue-router": "^3.3.4",
15+
"vuex": "^3.5.1"
1316
},
1417
"devDependencies": {
1518
"@vue/cli-plugin-babel": "~4.4.0",

postcss.config.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
module.exports = {
2+
plugins: [
3+
// ...
4+
require('tailwindcss'),
5+
require('autoprefixer'),
6+
// ...
7+
]
8+
}

src/App.vue

Lines changed: 8 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,18 @@
11
<template>
2-
<div id="app">
3-
<img alt="Vue logo" src="./assets/logo.png">
4-
<HelloWorld msg="Welcome to Your Vue.js App"/>
2+
<div>
3+
<my-header></my-header>
4+
<router-view></router-view>
55
</div>
66
</template>
77

88
<script>
9-
import HelloWorld from './components/HelloWorld.vue'
10-
11-
export default {
12-
name: 'App',
13-
components: {
14-
HelloWorld
9+
import Header from "./components/Header.vue"
10+
export default {
11+
components: {
12+
myHeader: Header,
13+
}
1514
}
16-
}
1715
</script>
1816

1917
<style>
20-
#app {
21-
font-family: Avenir, Helvetica, Arial, sans-serif;
22-
-webkit-font-smoothing: antialiased;
23-
-moz-osx-font-smoothing: grayscale;
24-
text-align: center;
25-
color: #2c3e50;
26-
margin-top: 60px;
27-
}
2818
</style>

src/assets/css/tailwind.css

Lines changed: 5 additions & 0 deletions
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/Header.vue

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<template>
2+
<div class="p-5 bg-blue-100 flex justify-end">
3+
<ul class="flex">
4+
<li class="mr-6">
5+
<router-link to='/editor' class="text-blue-600 hover:text-blue-800" href="#">Editor</router-link>
6+
</li>
7+
<li class="mr-6">
8+
<router-link to='/library' class="text-blue-600 hover:text-blue-800" href="#">Library</router-link>
9+
</li>
10+
</ul>
11+
</div>
12+
</template>
13+
14+
<script>
15+
export default {
16+
}
17+
</script>
18+

src/components/editor/Editor.vue

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<template>
2+
<div>
3+
<p>This is an editor</p>
4+
</div>
5+
</template>
6+
7+
<script>
8+
export default {
9+
}
10+
</script>
11+

src/components/library/Doc.vue

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<template>
2+
3+
4+
<div class="max-w-sm rounded overflow-hidden shadow-lg object-center">
5+
<div class="px-6 py-4 mt-8 bg-gray-200 ">
6+
<div class="font-bold text-xl mb-2">
7+
<p>
8+
<span v-for="(text, index) in doc.queryList" :key=index :class="{'bg-blue-100': text.mutability}">{{text.text}} </span>
9+
</p>
10+
</div>
11+
<p class="text-gray-700 text-base">
12+
{{doc.description}}
13+
</p>
14+
</div>
15+
16+
</div>
17+
18+
</template>
19+
20+
<script>
21+
export default {
22+
props: ["doc"],
23+
}
24+
</script>
25+

src/components/library/Library.vue

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<template>
2+
<div class="object-center">
3+
<doc v-for="doc in docs" :key="doc.id" :doc="doc"></doc>
4+
</div>
5+
</template>
6+
7+
<script>
8+
import Doc from "./Doc.vue"
9+
export default {
10+
components: {
11+
doc: Doc
12+
},
13+
computed: {
14+
docs: function() {
15+
return this.$store.getters.docs;
16+
}
17+
}
18+
}
19+
</script>
20+

src/main.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,19 @@
11
import Vue from 'vue'
22
import App from './App.vue'
3+
import "./assets/css/tailwind.css"
4+
import VueRouter from 'vue-router'
5+
import {routes} from './route'
6+
import store from './store/store.js'
7+
Vue.use(VueRouter);
8+
const router = new VueRouter({
9+
mode: "history",
10+
routes
11+
})
312

413
Vue.config.productionTip = false
514

615
new Vue({
16+
router,
717
render: h => h(App),
18+
store,
819
}).$mount('#app')

src/route.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import Library from './components/library/Library.vue';
2+
import Editor from './components/editor/Editor.vue';
3+
export const routes = [
4+
{path: '/', component: Editor},
5+
{path: '/library', component: Library},
6+
{path: '/editor', component: Editor}
7+
]

src/store/modules/docs.js

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
const state = {
2+
docs: [{
3+
queryList: [{text:'sean', mutability:false}, {text:'yang', mutability:true}],
4+
description: 'this is something cool',
5+
id: 0,
6+
},
7+
{
8+
queryList: [{text:'sean2'}, {text:'yang2'}],
9+
description: 'this is something cool2',
10+
id: 1,
11+
}],
12+
queryId: 0,
13+
filter: null,
14+
}
15+
16+
const mutations = {
17+
'ADD_QUERY'(state, {newQuery}){
18+
state.push(newQuery);
19+
},
20+
}
21+
22+
const actions = {
23+
addQuery({commit}, newQuery) {
24+
commit('SELL_STOCK', newQuery);
25+
}
26+
}
27+
28+
const getters = {
29+
docs (state) {
30+
if (state.filter) {
31+
return state.docs.filter(doc=>{
32+
return state.filter(doc);
33+
})
34+
} else {
35+
return state.docs.map(doc=> doc);
36+
}
37+
},
38+
queryId(state) {
39+
return state.queryId;
40+
}
41+
}
42+
43+
export default {
44+
state,
45+
mutations,
46+
actions,
47+
getters
48+
49+
}

src/store/store.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import Vue from 'vue';
2+
import Vuex from 'vuex';
3+
4+
import docs from "./modules/docs";
5+
6+
7+
Vue.use(Vuex);
8+
9+
export default new Vuex.Store({
10+
modules: {
11+
docs
12+
}
13+
})

tailwind.config.js

Lines changed: 8 additions & 0 deletions
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)