Skip to content
This repository was archived by the owner on Sep 20, 2024. It is now read-only.

Commit 73b807f

Browse files
committed
feat: added sidebar for components
1 parent 1733058 commit 73b807f

File tree

4 files changed

+76
-16
lines changed

4 files changed

+76
-16
lines changed

playground/src/App.vue

Lines changed: 46 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
<template>
2-
<sidebar :stories="stories" />
3-
<router-view />
2+
<section class="root">
3+
<sidebar class="sidebar" :stories="stories" />
4+
<router-view class="main" />
5+
</section>
46
</template>
57

68
<script lang="ts">
@@ -16,4 +18,45 @@ export default defineComponent({
1618
}
1719
},
1820
})
19-
</script>
21+
</script>
22+
23+
<style>
24+
html, body {
25+
margin: 0;
26+
height: 100vh;
27+
width: 100vw;
28+
}
29+
30+
html {
31+
line-height: 1.5;
32+
color: rgb(26, 32, 44);
33+
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol";
34+
}
35+
36+
#app {
37+
height: inherit;
38+
width: inherit;
39+
}
40+
</style>
41+
42+
<style scoped>
43+
.root {
44+
display: flex;
45+
height: inherit;
46+
width: inherit;
47+
}
48+
49+
.sidebar {
50+
height: 100%;
51+
widows: 200px;
52+
margin: 0;
53+
list-style-type: none;
54+
padding: 1rem;
55+
box-shadow: rgba(0, 0, 0, 0.1) 0px 4px 6px -1px, rgba(0, 0, 0, 0.06) 0px 2px 4px -1px;
56+
}
57+
58+
.main {
59+
width: 100%;
60+
padding: 1rem;
61+
}
62+
</style>

playground/src/components/Home.vue

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
11
<template>
2-
<sideBar :stories="stories" />
2+
<div></div>
33
</template>
44

55
<script>
66
import { defineComponent, h } from 'vue'
77
import { RouterLink } from 'vue-router'
88
import SideBar from './Sidebar.vue'
9-
import routes from '../.generated/routes.json'
9+
import routes from '../.generated/routes.json'
1010
1111
1212
export default defineComponent({
1313
components: { SideBar },
14-
setup() {
15-
return {
16-
stories: routes,
17-
}
18-
},
14+
mounted() {
15+
// Hard coded so we can push to the first component in the storybook
16+
// TODO: Find a way to locate the first child route
17+
this.$router.push('/c-alert/base-alert')
18+
}
1919
})
2020
</script>

playground/src/components/Sidebar.vue

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,17 @@ const Stories = defineComponent({
99
return () => {
1010
return h(
1111
'ul',
12-
props.stories.map(story =>
12+
props.stories
13+
.filter(story => story.path !== '/*')
14+
.map(story =>
1315
h(
1416
'li',
15-
{ key: story.path },
17+
{
18+
key: story.path
19+
},
1620
story.children
1721
? h('h3', story.name)
18-
: [h(RouterLink, { to: story.path }, () => story.name)],
22+
: [h(RouterLink, { to: story.path }, story.path === '/' ? () => [h('img', { class: ['logo'], src: 'https://res.cloudinary.com/xtellar/image/upload/v1584242872/chakra-ui/chakra-ui-vue.png' })] : () => story.name)],
1923
story.children && h(Stories, { stories: story.children })
2024
)
2125
)
@@ -25,4 +29,19 @@ const Stories = defineComponent({
2529
})
2630
2731
export default Stories
28-
</script>
32+
</script>
33+
34+
<style>
35+
ul {
36+
/* list-style-type: none; */
37+
padding: 0;
38+
}
39+
40+
li > ul {
41+
padding-left: 1rem;
42+
}
43+
44+
.logo {
45+
width: 120px;
46+
}
47+
</style>

playground/src/router.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,6 @@ function buildRoutes(routes) {
1919

2020
const routes = buildRoutes(generatedRoutes)
2121

22-
console.log(routes)
23-
2422
export default createRouter({
2523
history: createWebHistory(),
2624
routes,

0 commit comments

Comments
 (0)