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

Commit 5044a42

Browse files
committed
chore(hygen): added generator for components and hooks
1 parent 1457c82 commit 5044a42

File tree

9 files changed

+113
-2
lines changed

9 files changed

+113
-2
lines changed

.gitignore

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,2 @@
11
node_modules
2-
dist
3-
_templates
2+
dist
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
---
2+
to: packages/<%=h.changeCase.paramCase(name)%>/src/index.ts
3+
---
4+
5+
import { h, defineComponent } from 'vue'
6+
7+
const <%= h.changeCase.pascalCase(name) %> = defineComponent({
8+
props: {
9+
as: {
10+
type: Object as PropType<string>,
11+
default: 'div',
12+
},
13+
},
14+
setup(props, { slots, attrs }) {
15+
return h(props?.as, { ...attrs }, slots.default?.())
16+
},
17+
})
18+
19+
export default <%= h.changeCase.pascalCase(name) %>
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
---
2+
to: packages/<%=h.changeCase.paramCase(name)%>/package.json
3+
---
4+
5+
{
6+
"name": "<%= '@chakra-ui/' + h.changeCase.paramCase(name)%>",
7+
"version": "1.0.0",
8+
"main": "index.js",
9+
"description": "<%= 'Chakra UI Vue | ' + h.changeCase.pascalCase(name) + ' component'%>",
10+
"repository": "https://github.com/chakra-ui/chakra-ui-vue-next.git",
11+
"author": "codebender828 [email protected]",
12+
"license": "MIT",
13+
"scripts": {
14+
"build": "concurrently yarn:build:*",
15+
"build:esm": "cross-env swc src --out-dir dist/esm/",
16+
"build:cjs": "cross-env swc -C module.type=commonjs src --out-dir dist/cjs/"
17+
}
18+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
---
2+
to: packages/<%=h.changeCase.paramCase(name)%>/tests/<%=h.changeCase.paramCase(name)%>.test.ts
3+
---
4+
import { render } from '@chakra-ui/vue-test-utils'
5+
import <%= h.changeCase.pascalCase(name) %> from '../'
6+
7+
8+
it('should render properly', () => {
9+
const { html } = render(<%= h.changeCase.pascalCase(name) %>)
10+
expect(html()).toMatchSnapshot()
11+
})
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
---
2+
to: packages/<%=h.changeCase.paramCase(name)%>/tsconfig.json
3+
---
4+
5+
{
6+
"extends": "../../tsconfig.json",
7+
"include": ["src"]
8+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
---
2+
to: packages/<%=h.changeCase.paramCase(name)%>/src/<%=h.changeCase.paramCase(name)%>.ts
3+
---
4+
5+
import { h, defineComponent } from 'vue'
6+
7+
const <%= h.changeCase.pascalCase(name) %> = defineComponent({
8+
props: {
9+
as: {
10+
type: Object as PropType<string>,
11+
default: 'div',
12+
},
13+
},
14+
setup(props, { slots, attrs }) {
15+
return h(props?.as, { ...attrs }, slots.default?.())
16+
},
17+
})
18+
19+
export default <%= h.changeCase.pascalCase(name) %>
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
---
2+
to: packages/<%=h.changeCase.paramCase(name)%>/package.json
3+
---
4+
5+
{
6+
"name": "<%= '@chakra-ui/' + h.changeCase.paramCase(name)%>",
7+
"version": "1.0.0",
8+
"main": "index.js",
9+
"description": "<%= 'Chakra UI Vue | ' + h.changeCase.pascalCase(name) + ' module'%>",
10+
"repository": "https://github.com/chakra-ui/chakra-ui-vue-next.git",
11+
"author": "codebender828 [email protected]",
12+
"license": "MIT",
13+
"scripts": {
14+
"build": "concurrently yarn:build:*",
15+
"build:esm": "cross-env swc src --out-dir dist/esm/",
16+
"build:cjs": "cross-env swc -C module.type=commonjs src --out-dir dist/cjs/"
17+
}
18+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
---
2+
to: packages/<%=h.changeCase.paramCase(name)%>/tests/<%=h.changeCase.paramCase(name)%>.test.ts
3+
---
4+
import { render } from '@chakra-ui/vue-test-utils'
5+
import <%= h.changeCase.pascalCase(name) %> from '../'
6+
7+
8+
it('should render properly', () => {
9+
const { html } = render(<%= h.changeCase.pascalCase(name) %>)
10+
expect(html()).toMatchSnapshot()
11+
})
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
---
2+
to: packages/<%=h.changeCase.paramCase(name)%>/tsconfig.json
3+
---
4+
5+
{
6+
"extends": "../../tsconfig.json",
7+
"include": ["src"]
8+
}

0 commit comments

Comments
 (0)