Skip to content

Instantly share code, notes, and snippets.

@StrongerMyself
Last active November 16, 2020 12:23
Show Gist options
  • Save StrongerMyself/7e727bda552b647ee2e3a9c5dd51099a to your computer and use it in GitHub Desktop.
Save StrongerMyself/7e727bda552b647ee2e3a9c5dd51099a 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