Browse Source

navigation & source link

dependabot/npm_and_yarn/webpack-bundle-analyzer-3.6.0
Alexey Velikiy 8 years ago
parent
commit
6f58abfc75
  1. 8
      src/App.vue
  2. 90
      src/components/demos-navigation.vue
  3. 15
      src/components/index.vue
  4. 3
      src/config.json
  5. 18
      src/d3-components/2-circle-render.vue
  6. 6
      src/main.js
  7. 15
      src/router/demos.js
  8. 2
      src/router/index.js

8
src/App.vue

@ -1,13 +1,19 @@
<template> <template>
<div id="app"> <div id="app">
<a href='#/'> <h1> D3.js vs Vue.js examples </h1> </a> <a href='#/'> <h1> D3.js vs Vue.js examples </h1> </a>
<h2>{{ $route.name }}</h2>
<topNav />
<router-view></router-view> <router-view></router-view>
</div> </div>
</template> </template>
<script> <script>
import topNav from './components/demos-navigation'
export default { export default {
name: 'app' name: 'app',
components: { topNav }
} }
</script> </script>

90
src/components/demos-navigation.vue

@ -1,22 +1,96 @@
<template> <template>
<div id="holder"> <div id="holder">
<div> <div class="links">
<a :href="prev.path"> < previous </a> <a v-if="prev" :href="prev.href" class="prev"> < previous </a>
<!-- TODO: source code link --> <a :href="sourceHref" class="source"> source </a>
<a :href="next.path"> next > </a> <a v-if="next" :href="next.href" class="next"> next > </a>
</div> </div>
</div> </div>
</template> </template>
<script> <script>
import { routes } from 'router/demos';
const config = require('config.json');
export default { export default {
data () { computed: {
console.log(this.$route); prev: function() {
return {} var index = this.findIndex();
if(index == -1) {
return undefined;
}
return index > 0 ? routes[index - 1] : undefined;
},
next: function() {
var index = this.findIndex();
if(index == -1) {
return undefined;
}
return index + 1 < routes.length ? routes[index + 1] : undefined;
},
sourceHref: function() {
var index = this.findIndex();
if(index == -1) {
return config.githubLink;
}
return routes[index].source;
}
},
methods: {
findIndex: function() {
var me = this.$route.path;
return routes.findIndex(r => r.path === me);
}
} }
} }
</script> </script>
<style> <style scoped>
#links {
display: block;
width: 300px;
height: 40px;
position: relative;
}
a {
display: block;
position: absolute;
width: 100px;
text-decoration: none;
font-weight: bold;
color: blue;
}
a:hover {
text-decoration: underline;
}
.prev {
left: 0px;
}
.source {
left:100px;
text-align: center;
}
.next {
right: 0px;
text-align: right;
}
#holder {
width: 300px;
margin: auto;
position: relative;
height: 30px;
/*border-top: 1px dashed gray;*/
border-bottom: 1px dashed gray;
padding-top: 10px;
margin-top: 10px;
margin-bottom: 10px;
}
</style> </style>

15
src/components/index.vue

@ -1,8 +1,8 @@
<template> <template>
<div class="hello"> <div class="hello">
<ul> <ul>
<li v-for="item in itemz"> <li v-for="item in items">
<a :href="item.path | hashed">{{ item.name }}</a> <a :href="item.href">{{ item.name }}</a>
</li> </li>
</ul> </ul>
</div> </div>
@ -10,23 +10,16 @@
<script> <script>
import { routes } from 'router/demos' import { routes } from 'router/demos'
export default { export default {
name: 'hello',
data () { data () {
return { return {
itemz: routes items: routes
}
},
filters: {
hashed: function (value) {
if (!value) return ''
return '#' + value;
} }
} }
} }
</script> </script>
<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped> <style scoped>
h1, h2 { h1, h2 {
font-weight: normal; font-weight: normal;

3
src/config.json

@ -0,0 +1,3 @@
{
"githubLink": "https://github.com/corpglory/d3vue/"
}

18
src/d3-components/2-circle-render.vue

@ -0,0 +1,18 @@
<template>
<div>
<svg width="500" height="300"></svg>
</div>
</template>
<script>
const d3 = require('d3');
export default {
data () {
console.log(this.$route);
return {}
}
}
</script>
<style>
</style>

6
src/main.js

@ -1,13 +1,13 @@
// The Vue build version to load with the `import` command // The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias. // (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import Vue from 'vue' import Vue from 'vue'
import App from './app' import app from './app'
import router from './router' import router from './router'
/* eslint-disable no-new */ /* eslint-disable no-new */
new Vue({ new Vue({
el: '#app', el: '#app',
router, router,
template: '<App/>', template: '<app/>',
components: { App } components: { app }
}) })

15
src/router/demos.js

@ -1,8 +1,21 @@
const config = require('config.json');
export const routes = [ export const routes = [
{ {
name: 'Circle mount', name: 'Circle mount',
path: '/1-circle-mount', path: '/1-circle-mount',
component: require('d3-components/1-circle-mount') component: require('d3-components/1-circle-mount')
},
{
name: 'Circle render',
path: '/2-circle-mount',
component: require('d3-components/2-circle-render')
} }
] ].map(r => {
var res = r;
res.href = "#" + r.path;
res.source = config.githubLink +
'tree/master/src/d3-components' +
r.path + '.vue'
return res;
})

2
src/router/index.js

@ -9,7 +9,7 @@ export default new Router({
routes: [ routes: [
{ {
path: '/', path: '/',
name: 'Index', name: 'Menu',
component: Index component: Index
}, ... demoRoutes }, ... demoRoutes

Loading…
Cancel
Save