Skip to content

Instantly share code, notes, and snippets.

@karltaylor
Created December 1, 2022 17:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save karltaylor/ebfc8ee2583903ad12de5dc34c6baebe to your computer and use it in GitHub Desktop.
Save karltaylor/ebfc8ee2583903ad12de5dc34c6baebe to your computer and use it in GitHub Desktop.
snippets
{
// Place your global snippets here. Each snippet is defined under a snippet name and has a scope, prefix, body and
// description. Add comma separated ids of the languages where the snippet is applicable in the scope field. If scope
// is left empty or omitted, the snippet gets applied to all languages. The prefix is what is
// used to trigger the snippet and the body will be expanded and inserted. Possible variables are:
// $1, $2 for tab stops, $0 for the final cursor position, and ${1:label}, ${2:another} for placeholders.
// Placeholders with the same ids are connected.
// Example:
// "Print to console": {
// "scope": "javascript,typescript",
// "prefix": "log",
// "body": [
// "console.log('$1');",
// "$2"
// ],
// "description": "Log output to console"
// }
"Import React": {
"scope": "typescript, typescriptreact, javascript",
"prefix": "react",
"body": "import React from 'react'"
},
"Add styled-components": {
"scope": "typescript, typescriptreact, javascript",
"prefix": "styled",
"body": "import styled from 'styled-components';"
},
"Add styled wrap componenet": {
"scope": "typescript, typescriptreact, javascript",
"prefix": "const wrap",
"body": ["import styled from 'styled-components'", "", "const Wrap = styled.div`$0`", ""]
},
"Add Sanity Field": {
"scope": "typescript, typescriptreact, javascript",
"prefix": "sanityField",
"body": ["{", " name: '$1',", " title: '$2',", " type: '$3',", "},$0"]
},
"Sanity Component Prepare": {
"scope": "typescript, typescriptreact, javascript",
"description": "Creates object to show title for sanity object",
"prefix": "prepareTitle",
"body": [
"preview: {",
" prepare() {",
" return {",
" title: $0",
" }",
" },",
"},"
]
},
"Fragment Generator": {
"scope": "typescript, typescriptreact, javascript",
"description": "generates a fragment",
"prefix": "fragment",
"body": [
"import { gql } from '@apollo/client'",
"",
"export const $1 = gql`",
" fragment $2 on Sanity_$3 {",
" _key",
" }",
"`"
]
},
"stringifyShit": {
"scope": "typescript, typescriptreact, javascript",
"description": "stringify log",
"prefix": "stringify",
"body": ["console.log(JSON.stringify($1, null, 2))"]
},
"Add stitches styled component": {
"scope": "typescript, typescriptreact, javascript",
"prefix": "styled",
"body": ["", "const $1 = styled('$2', {", " $3", "})", ""]
},
"Spread react errors": {
"scope": "typescriptreact, javascript",
"prefix": "spreadErrors",
"body": "setErrors(p => ({ ...p, $1 }))"
},
"React Native Stylesheet": {
"scope": "typescriptreact, javascript",
"prefix": "rnStyle",
"body": ["const styles = StyleSheet.create({", " $1", "});"]
},
"Background Red": {
"scope": "typescriptreact",
"prefix": "bgred",
"body": "backgroundColor: 'red'"
},
"Handler Todo": {
"scope": "typescriptreact",
"prefix": "handlertodo",
"body": "const handle$1 = () => console.log(\"todo handle$1\")"
},
"Interface Props": {
"scope": "typescript, typescriptreact",
"prefix": "interface",
"body": ["interface Props {", " $1: $2", "}"]
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment