Skip to content

Instantly share code, notes, and snippets.

@ccpu
Forked from StrongerMyself/typescriptreact.json
Created November 16, 2020 12:23
Show Gist options
  • Save ccpu/d067e5b10dd6d863d3e25eac9d8b3260 to your computer and use it in GitHub Desktop.
Save ccpu/d067e5b10dd6d863d3e25eac9d8b3260 to your computer and use it in GitHub Desktop.
vs-code tsx snippets
{
"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