-
-
Save ccpu/d067e5b10dd6d863d3e25eac9d8b3260 to your computer and use it in GitHub Desktop.
vs-code tsx snippets
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
{ | |
"tsx-test-filename": { | |
"prefix": "tsx-test-filename", | |
"body": [ | |
"${TM_FILENAME_BASE/^(.)|([.-](.))/${1:/upcase}${3:/upcase}/g}", | |
], | |
"description": "TSX filename" | |
}, | |
"tsx": { | |
"prefix": "tsx", | |
"body": [ | |
"import React, { FunctionComponent } from 'react'", | |
"", | |
"interface Props {}", | |
"", | |
"export const ${TM_FILENAME_BASE/^(.)|([.-](.))/${1:/upcase}${3:/upcase}/g}: FunctionComponent<Props> = (props) => {", | |
" return (", | |
" <>${TM_FILENAME_BASE/^(.)|([.-](.))/${1:/upcase}${3:/upcase}/g}</>", | |
" )", | |
"}", | |
"", | |
"${TM_FILENAME_BASE/^(.)|([.-](.))/${1:/upcase}${3:/upcase}/g}.displayName = '${TM_FILENAME_BASE/^(.)|([.-](.))/${1:/upcase}${3:/upcase}/g}'", | |
"", | |
], | |
"description": "TSX filename" | |
}, | |
"tsx-fc": { | |
"prefix": "tsx-func-component", | |
"body": [ | |
"import React, { FunctionComponent } from 'react'", | |
"import { cn } from 'src/core/bem'", | |
"", | |
"interface Props {}", | |
"", | |
"export const ${TM_FILENAME_BASE/^(.)|([.-](.))/${1:/upcase}${3:/upcase}/g}: FunctionComponent<Props> = (props) => {", | |
" return (", | |
" <div className={cn('${TM_FILENAME_BASE/^(.)|([.-](.))/${1:/upcase}${3:/upcase}/g}')()}>", | |
" ${TM_FILENAME_BASE/^(.)|([.-](.))/${1:/upcase}${3:/upcase}/g}", | |
" </div>", | |
" )", | |
"}", | |
"", | |
"${TM_FILENAME_BASE/^(.)|([.-](.))/${1:/upcase}${3:/upcase}/g}.displayName = '${TM_FILENAME_BASE/^(.)|([.-](.))/${1:/upcase}${3:/upcase}/g}'", | |
"", | |
], | |
"description": "TSX func component" | |
}, | |
"tsx-fc-parent": { | |
"prefix": "tsx-func-parent-component", | |
"body": [ | |
"import React, { FunctionComponent } from 'react'", | |
"import { pCn } from 'src/core/bem'", | |
"", | |
"interface Props {}", | |
"", | |
"export const ${TM_FILENAME_BASE/^(.)|([.-](.))/${1:/upcase}${3:/upcase}/g}: FunctionComponent<Props> = (props) => {", | |
" const cnPar = pCn('${TM_FILENAME_BASE/^(.)|([.-](.))/${1:/upcase}${3:/upcase}/g}')", | |
" return (", | |
" <div className={cnPar()()}>", | |
" ${TM_FILENAME_BASE/^(.)|([.-](.))/${1:/upcase}${3:/upcase}/g}", | |
" </div>", | |
" )", | |
"}", | |
"", | |
"${TM_FILENAME_BASE/^(.)|([.-](.))/${1:/upcase}${3:/upcase}/g}.displayName = '${TM_FILENAME_BASE/^(.)|([.-](.))/${1:/upcase}${3:/upcase}/g}'", | |
"", | |
], | |
"description": "TSX func component" | |
}, | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment