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

Commit ffc175d

Browse files
committed
feat(c-icon): create icon component
1 parent 7251747 commit ffc175d

File tree

3 files changed

+8
-5
lines changed

3 files changed

+8
-5
lines changed

_templates/generator/component/component.ts.ejs.t

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,16 @@ to: packages/<%=h.changeCase.paramCase(name)%>/src/index.ts
33
---
44

55
import { h, defineComponent, PropType } from 'vue'
6+
import { chakra, DOMElements } from '@chakra-ui/vue-system'
67

7-
export const <%= h.changeCase.pascalCase(name) %> = defineComponent({
8+
export const CIcon = defineComponent({
89
props: {
910
as: {
10-
type: Object as PropType<string>,
11+
type: [Object, String] as PropType<DOMElements>,
1112
default: 'div',
1213
},
1314
},
1415
setup(props, { slots, attrs }) {
15-
return h(props?.as, { ...attrs }, slots.default?.())
16+
return () => h(chakra(props.as), { ...attrs }, slots)
1617
},
1718
})

packages/c-icon/src/index.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
import { h, defineComponent, PropType } from 'vue'
2+
import { chakra, DOMElements } from '@chakra-ui/vue-system'
23

34
export const CIcon = defineComponent({
45
props: {
56
as: {
6-
type: Object as PropType<string>,
7+
type: [Object, String] as PropType<DOMElements>,
78
default: 'div',
89
},
910
},
1011
setup(props, { slots, attrs }) {
11-
return h(props?.as, { ...attrs }, slots.default?.())
12+
return () => h(chakra(props.as), { ...attrs }, slots)
1213
},
1314
})

playground/src/.generated/resolver.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
'@chakra-ui/c-accordion': '/Users/jonathanbakebwa/Github/chakra-ui-vue-next/packages/c-accordion/src/index.ts',
44
'@chakra-ui/c-alert': '/Users/jonathanbakebwa/Github/chakra-ui-vue-next/packages/c-alert/src/index.ts',
55
'@chakra-ui/c-button': '/Users/jonathanbakebwa/Github/chakra-ui-vue-next/packages/c-button/src/index.ts',
6+
'@chakra-ui/c-icon': '/Users/jonathanbakebwa/Github/chakra-ui-vue-next/packages/c-icon/src/index.ts',
67
'@chakra-ui/c-theme-provider': '/Users/jonathanbakebwa/Github/chakra-ui-vue-next/packages/c-theme-provider/src/index.ts',
78
'@chakra-ui/system': '/Users/jonathanbakebwa/Github/chakra-ui-vue-next/packages/system/src/index.ts',
89
'@chakra-ui/test-utils': '/Users/jonathanbakebwa/Github/chakra-ui-vue-next/packages/test-utils/src/index.ts',

0 commit comments

Comments
 (0)