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

Commit fc45b99

Browse files
committed
feat: cleanup playground
1 parent 8c4b1c4 commit fc45b99

File tree

5 files changed

+54
-70
lines changed

5 files changed

+54
-70
lines changed

packages/system/src/index.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ export const chakra: IChakraFactory = (
1818
componentName?: string
1919
): any => {
2020
// Increment ids
21-
id++
21+
++id
2222

2323
return defineComponent({
2424
inheritAttrs: false,
@@ -28,8 +28,9 @@ export const chakra: IChakraFactory = (
2828
const { styles, attrs: _attrs } = extractStyleAttrs(rest)
2929
const className = _css(css(styles)({ theme }))
3030

31-
const _componentName =
32-
`chakra-${componentName}` || `chakra-component-${id}`
31+
const _componentName = componentName
32+
? `chakra-${componentName}`
33+
: `chakra-component-${id}`
3334

3435
return () =>
3536
h(
@@ -54,3 +55,5 @@ type IChakraFactory = {
5455
domElements.forEach((tag) => {
5556
chakra[tag] = chakra(tag)
5657
})
58+
59+
export { domElements }

packages/system/src/system.utils.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ export const domElements = [
4040
'label',
4141
'li',
4242
'mark',
43+
'main',
4344
'nav',
4445
'ol',
4546
'p',

playground/src/App.vue

Lines changed: 10 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,15 @@
11
<template>
2-
<section class="root">
3-
<sidebar class="sidebar" :stories="routes" />
4-
<main class="main">
2+
<chakra.section d="flex" height="inherit" w="inherit">
3+
<sidebar :stories="routes" />
4+
<chakra.main w="full" border-left="1px solid" border-color="gray.400" padding="4">
55
<router-view />
6-
</main>
7-
</section>
6+
7+
<chakra.button :bg="['teal.500']" color="white" px="4" py="3">
8+
Button
9+
</chakra.button>
10+
11+
</chakra.main>
12+
</chakra.section>
813
</template>
914

1015
<script lang="ts">
@@ -42,29 +47,3 @@ html {
4247
width: inherit;
4348
}
4449
</style>
45-
46-
<style scoped>
47-
.root {
48-
display: flex;
49-
height: inherit;
50-
width: inherit;
51-
}
52-
53-
.sidebar {
54-
height: 100%;
55-
widows: 200px;
56-
margin: 0;
57-
list-style-type: none;
58-
padding: 1rem;
59-
box-shadow: rgba(0, 0, 0, 0.1) 0px 4px 6px -1px, rgba(0, 0, 0, 0.06) 0px 2px 4px -1px;
60-
}
61-
62-
a {
63-
color: black !important;
64-
}
65-
66-
.main {
67-
width: 100%;
68-
padding: 1rem;
69-
}
70-
</style>

playground/src/components/Sidebar.vue

Lines changed: 29 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,43 @@
11
<script>
2+
import { chakra } from '@chakra-ui/system-vue'
23
import { defineComponent, h } from 'vue'
34
import { RouterLink } from 'vue-router'
4-
import { routes } from '../router'
55
66
77
const Stories = defineComponent({
88
props: ['stories'],
9-
setup(props) {
9+
inheritAttrs: false,
10+
setup(props, { attrs }) {
1011
return () => {
11-
return h(
12-
'ul',
13-
props.stories
14-
.filter(story => story.path !== '/*')
15-
.map(story =>
16-
h(
17-
'li',
18-
{
19-
key: story.path
20-
},
21-
story.children
22-
? h('h3', story.name)
23-
: [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)],
24-
story.children && h(Stories, { stories: story.children })
25-
)
12+
return h(chakra.nav, [
13+
h(
14+
chakra.ul,
15+
{
16+
p: 0,
17+
h: '100%',
18+
m: 0,
19+
listStyleType: 'none',
20+
padding: 4,
21+
},
22+
props.stories
23+
.filter(story => story.path !== '/*')
24+
.map(story =>
25+
h(
26+
chakra.li,
27+
{
28+
pl: 4,
29+
key: story.path
30+
},
31+
story.children
32+
? h(chakra.h3, story.name)
33+
: [h(RouterLink, { to: story.path }, story.path === '/' ? () => [h(chakra.img, { w: '120px', src: 'https://res.cloudinary.com/xtellar/image/upload/v1584242872/chakra-ui/chakra-ui-vue.png' })] : () => story.name)],
34+
story.children && h(Stories, { stories: story.children })
35+
)
36+
),
2637
)
27-
)
38+
])
2839
}
2940
},
3041
})
31-
3242
export default Stories
3343
</script>
34-
35-
<style>
36-
ul {
37-
/* list-style-type: none; */
38-
padding: 0;
39-
}
40-
41-
li > ul {
42-
padding-left: 1rem;
43-
}
44-
45-
.logo {
46-
width: 120px;
47-
}
48-
</style>

playground/src/main.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,15 @@
11
import { createApp } from 'vue'
22
import ChakraUIVuePlugin from '@chakra-ui/vue-next'
3+
import { domElements, chakra } from '@chakra-ui/system-vue'
34
import App from './App.vue'
45
import router from './router'
56

6-
createApp(App)
7+
const app = createApp(App)
78
.use(router)
89
.use(ChakraUIVuePlugin, {})
9-
.mount('#app')
10+
11+
domElements.forEach((tag) => {
12+
app.component(`chakra.${tag}`, chakra(tag))
13+
})
14+
15+
app.mount('#app')

0 commit comments

Comments
 (0)