Last active
March 30, 2023 19:30
-
-
Save wellserrano/b0ee5c5e9ae96c6dc683a7701007599b to your computer and use it in GitHub Desktop.
FC boilerplate
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"Typescript React Function Component": { | |
"prefix": "fc", | |
"body": [ | |
"import * as React from 'react'", | |
"import { cva, VariantProps } from 'class-variance-authority'", | |
"//import { cn } from '../../lib/utils/cn'", | |
"", | |
"const ${TM_FILENAME_BASE/([^.]+)/${1:/downcase}/g}Variants = cva(", | |
"`$1`,", | |
"{", | |
" variants: {", | |
" variant: {", | |
" opt1: 'test1',", | |
" opt2: 'test2',", | |
" },", | |
" },", | |
" defaultVariants: {", | |
" variant: 'opt1'", | |
" }", | |
" }", | |
")", | |
"", | |
"interface ${TM_FILENAME_BASE}Props", | |
"extends VariantProps<typeof ${TM_FILENAME_BASE/([^.]+)/${1:/downcase}/g}Variants> {", | |
" $2", | |
"}", | |
"", | |
"const $TM_FILENAME_BASE = React.forwardRef<${TM_FILENAME_BASE}Props>(", | |
"({$2}, ref) => {", | |
" return (", | |
" <div>$TM_FILENAME_BASE</div>", | |
" )", | |
"})", | |
"", | |
"${TM_FILENAME_BASE}.displayName = '${TM_FILENAME_BASE}'", | |
"", | |
"export {$TM_FILENAME_BASE}" | |
], | |
"description": "Typescript React Function Component" | |
}, | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment