hygen component generator
This commit is contained in:
parent
20dde76aab
commit
ff094f7c75
|
@ -21,6 +21,11 @@ npm run typecheck:watch
|
|||
```
|
||||
## Code generation
|
||||
|
||||
generate new SolidJS component:
|
||||
```
|
||||
npx hygen component new NewComponentName
|
||||
```
|
||||
|
||||
generate new SolidJS context:
|
||||
```
|
||||
npx hygen context new NewContextName
|
||||
|
|
18
_templates/component/new/component.ejs.t
Normal file
18
_templates/component/new/component.ejs.t
Normal file
|
@ -0,0 +1,18 @@
|
|||
---
|
||||
to: src/components/<%= h.changeCase.pascal(name) %>/<%= h.changeCase.pascal(name) %>.tsx
|
||||
---
|
||||
|
||||
import { clsx } from 'clsx'
|
||||
import styles from './<%= h.changeCase.pascal(name) %>.module.scss'
|
||||
|
||||
type Props = {
|
||||
class?: string
|
||||
}
|
||||
|
||||
export const <%= h.changeCase.pascal(name) %> = (props: Props) => {
|
||||
return (
|
||||
<div class={clsx(styles.<%= h.changeCase.pascal(name) %>, props.class)}>
|
||||
<%= h.changeCase.pascal(name) %>
|
||||
</div>
|
||||
)
|
||||
}
|
4
_templates/component/new/index.ejs.t
Normal file
4
_templates/component/new/index.ejs.t
Normal file
|
@ -0,0 +1,4 @@
|
|||
---
|
||||
to: src/components/<%= h.changeCase.pascal(name) %>/index.ts
|
||||
---
|
||||
export { <%= h.changeCase.pascal(name) %> } from './<%= h.changeCase.pascal(name) %>'
|
7
_templates/component/new/styles.ejs.t
Normal file
7
_templates/component/new/styles.ejs.t
Normal file
|
@ -0,0 +1,7 @@
|
|||
---
|
||||
to: src/components/<%= h.changeCase.pascal(name) %>/<%= h.changeCase.pascal(name) %>.module.scss
|
||||
---
|
||||
|
||||
.<%= h.changeCase.pascal(name) %> {
|
||||
display: block;
|
||||
}
|
Loading…
Reference in New Issue
Block a user