Last active
February 14, 2022 16:34
-
-
Save SandyGifford/399d05989f851d68433aa7036cf52981 to your computer and use it in GitHub Desktop.
VSC Snippet for Typescript/Material UI components
This file contains hidden or 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
{ | |
"MUI Component": { | |
"prefix": "muicomp", | |
"description": "Material UI component template", | |
"body": [ | |
"import { VFC } from \"react\";", | |
"import { makeStyles } from \"@material-ui/core\";", | |
"import { ClassNameMap } from \"@material-ui/core/styles/withStyles\";", | |
"import clsx from \"clsx\";", | |
"", | |
"", | |
"const useStyles = makeStyles(theme => ({", | |
" root: {},", | |
"}), {", | |
" classNamePrefix: \"$1\",", | |
"});", | |
"", | |
"export type $1JSSClassKey = keyof ReturnType<typeof useStyles>;", | |
"", | |
"export type $1Props = {", | |
" classes?: Partial<ClassNameMap<$1JSSClassKey>>;", | |
" className?: string;", | |
"};", | |
"", | |
"export const ${1:name}: VFC<$1Props> = ({", | |
" className,", | |
" classes: extClasses,", | |
"}) => {", | |
" const classes = useStyles({", | |
" classes: extClasses,", | |
" });", | |
"", | |
" return <div className={clsx(classes.root, className)} />;", | |
"};", | |
"" | |
] | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment