Last active
December 6, 2017 22:57
-
-
Save ddgromit/062b30f9f295a731d8d97bc75ae091ee to your computer and use it in GitHub Desktop.
Atom Snippets
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
'.source.js': | |
'[DD] query renderer': | |
prefix: 'queryrendererfile' | |
body: """ | |
/* @flow */ | |
import React from 'react'; | |
import { graphql } from 'react-relay/compat'; | |
import DefaultQueryRenderer from 'components/DefaultQueryRenderer'; | |
import type { $1QueryResponse } from './__generated__/$1Query.graphql'; | |
const query = graphql` | |
query $1Query { | |
me { | |
id | |
} | |
} | |
`; | |
export default class $1 extends React.Component<{}> { | |
render() { | |
return ( | |
<DefaultQueryRenderer | |
query={query} | |
renderSuccess={(props: $1QueryResponse) => ( | |
<div>todo</div> | |
)} | |
/> | |
); | |
} | |
} | |
""" | |
'Derek\'s React Native Class': | |
prefix: 'rncomponent' | |
body: """ | |
/* @flow */ | |
import React from 'react'; | |
import { | |
View, | |
} from 'react-native'; | |
export default class $1 extends React.Component { | |
render() { | |
return ( | |
<View> | |
$2 | |
</View> | |
); | |
} | |
} | |
""" | |
'Derek\'s React Native Styles': | |
prefix: 'ddrnstyles' | |
body: """ | |
const styles = StyleSheet.create({ | |
$1: { | |
$2: $3, | |
}, | |
}); | |
""" | |
'Derek\'s Prop Types': | |
prefix: 'proptypes' | |
body: """ | |
static propTypes = { | |
$1: PropTypes.$2, | |
} | |
""" | |
'Derek\'s Prop Type': | |
prefix: 'pt' | |
body: '$1: PropTypes.$2,$3' | |
'Derek\'s Prop Type': | |
prefix: 'ptreq' | |
body: '$1: PropTypes.$2.isRequired,$3' | |
'Dereks Style Prop': | |
prefix: 'styleprop' | |
body: "style={styles.$1}" | |
'[DD] import': | |
prefix: 'import', | |
body: "import $1 from '$2/$1';$3" | |
'[DD] import relay': | |
prefix: 'importrelay', | |
body: "import Relay from 'react-relay';" | |
'[DD] import PropType': | |
prefix: 'importproptypes' | |
body: "import PropTypes from 'prop-types';" | |
'[DD] import React': | |
prefix: 'importreact' | |
body: "import React from 'react';" | |
'[DD] import withQueryParams': | |
prefix: 'importwithqueryparams' | |
body: "import withQueryParams from 'utils/routing/withQueryParams';" | |
'[DD] import withRouter': | |
prefix: 'importwithrouter' | |
body: "import { withRouter } from 'react-router';" | |
'[DD] const styled.div = ': | |
prefix: 'styled' | |
body: """ | |
const $1 = styled.$2` | |
$3 | |
`; | |
""" | |
'[DD] setState': | |
prefix: 'setState' | |
body: """ | |
this.setState({ | |
$1: $2, | |
}); | |
""" | |
'[DD] React handle method': | |
prefix: 'handle' | |
body: """ | |
handle$1 = () => { | |
$2 | |
} | |
""" | |
'[DD] ref prop': | |
prefix: 'ref' | |
body: "ref={(ref) => { this.$1 = ref; }}$2" | |
'[DD] React constructor': | |
prefix: 'constr' | |
body: """ | |
constructor() { | |
super(); | |
this.state = { | |
$1: $2, | |
}; | |
} | |
""" | |
'[DD] import styled-components': | |
prefix: 'importstyled' | |
body: "import styled from 'styled-components';" | |
'[DD] import createFragmentContainer': | |
prefix: 'importcreatefragment' | |
body: "import { graphql, createFragmentContainer } from 'react-relay/compat';" | |
'[DD] import flow type': | |
prefix: 'importflow' | |
body: "import type { $1 } from './__generated__/$1.graphql';$2" | |
'[DD] createFragmentContainer': | |
prefix: 'createFragmentContainer' | |
body: """ | |
export default createFragmentContainer($1, graphql` | |
fragment $1_$2 on $3 { | |
$4 | |
} | |
`); | |
""" | |
'[DD] mutation': | |
prefix: 'mutation' | |
body: """ | |
/* @flow */ | |
import { graphql } from 'react-relay/compat'; | |
import commitModernMutation from 'graph/utils/commitModernMutation'; | |
import type { | |
$1MutationVariables, | |
$1MutationResponse, | |
} from './__generated__/$1Mutation.graphql'; | |
const mutation = graphql` | |
mutation $1Mutation($input: $2Input!) { | |
$1(input: $input) { | |
$3 | |
} | |
} | |
`; | |
export default function $1(args: { | |
$4 | |
}): Promise<$1MutationResponse> { | |
const variables:$1MutationVariables = { | |
input: { | |
...args, | |
}, | |
}; | |
return commitModernMutation({ | |
mutation, | |
variables, | |
}); | |
} | |
""" | |
'.source.ruby': | |
'[DD] Ruby file': | |
prefix: 'rbmodule' | |
body: """ | |
# frozen_string_literal: true | |
module $1 | |
module_function | |
def $2 | |
$3 | |
end | |
end | |
""" | |
'[DD] Ruby class': | |
prefix: 'rbclass' | |
body: """ | |
# frozen_string_literal: true | |
class $1 | |
def initialize | |
$2 | |
end | |
end | |
""" | |
'[DD] RSpec file': | |
prefix: 'rspec' | |
body: """ | |
# frozen_string_literal: true | |
require 'rails_helper' | |
RSpec.describe $1 do | |
it '$2' do | |
$3 | |
end | |
end | |
""" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment