Skip to content

Instantly share code, notes, and snippets.

@neilsarkar
Created January 16, 2018 05:13
Show Gist options
  • Save neilsarkar/d001561b39e189d9051259d4e4b68b0f to your computer and use it in GitHub Desktop.
Save neilsarkar/d001561b39e189d9051259d4e4b68b0f to your computer and use it in GitHub Desktop.
Atom Snippets
# Your snippets
#
# Atom snippets allow you to enter a simple prefix in the editor and hit tab to
# expand the prefix into a larger code block with templated values.
#
# You can create a new snippet in this file by typing "snip" and then hitting
# tab.
#
# An example CoffeeScript snippet to expand log to console.log:
#
# '.source.coffee':
# 'Console log':
# 'prefix': 'log'
# 'body': 'console.log $1'
#
'.source.go':
'If err':
'prefix': 'ie'
'body': 'if err != nil {
${1:return err}
}'
'.source.js':
'Console log':
'prefix': 'cl'
'body': 'console.log($1)'
'Console warn':
'prefix': 'cw'
'body': 'console.warn($1)'
'If err':
'prefix': 'ie'
'body': 'if( err ) { ${1:return cb(err);} }'
'Import component':
'prefix': 'impc'
'body': 'import ${1} from \'./${1}\''
'Bind this':
'prefix': 'tt'
'body': 'this.${1} = this.${1}.bind(this)'
'Reducer':
'prefix': 'red'
'body': """
const initialState = {}
export default function(state=initialState, action) {
switch(action.type) {
$1
default:
return state
}
}
"""
'PropTypes':
'prefix': 'pt'
'body': """
static propTypes = {
$1
}"""
'Stylesheet':
'prefix': 'ss'
'body': """
const styles = StyleSheet.create({
$1
})"""
'Constructor':
'prefix': 'con'
'body': """
constructor(props) {
super(props)
$1
}
"""
'Render':
'prefix': 'rr'
'body': """
render() { return (
$1
)}
"""
'React':
'prefix': 'rct'
'body': """
import React, { Component } from 'react'
export default class ${1:Foo} extends Component {
render() {
return (
<div className="$2">
$3
</div>
)
}
}
"""
'Functional component':
'prefix': 'fun'
'body': """
'use strict'
import React, {Component} from 'react'
import {
StyleSheet,
Text,
View,
} from 'react-native'
export default function(props) {
return (
<View style={styles.container}>
${3:<Text>Hello</Text>}
</View>
)
}
const styles = StyleSheet.create({
container: {
flex: 1
}
})
"""
'React Native':
'prefix': 'rctn'
'body': """
'use strict'
import React, {Component} from 'react'
import {
StyleSheet,
Text,
View,
} from 'react-native'
export default class ${2:Foo} extends Component {
render() {
const {props} = this
return (
<View style={styles.container}>
${3:<Text>Hello</Text>}
</View>
)
}
}
const styles = StyleSheet.create({
container: {
flex: 1
}
})
"""
'React Native Custom Component':
'prefix': 'rctc'
'body': """
'use strict'
import React from 'react'
import Component from './Component'
import Text from './Text'
import {
View,
} from 'react-native'
export default class ${2:Foo} extends Component {
render() { return (
<View>
${3:<Text>Hello</Text>}
</View>
)}
}
"""
'React Native Container':
'prefix': 'ctrl'
'body': """
'use strict'
import React, {Component} from 'react'
import {connect} from 'react-redux'
import ${1:Foo}View from '../components/${1:Foo}View'
class ${1:Foo} extends Component {
render() {
return (
<${1:Foo}View {...this.props} />
)
}
}
function mapStateToProps(state) {
return {
}
}
function mapDispatchToProps(dispatch) {
return {
}
}
export default connect(mapStateToProps, mapDispatchToProps)(${1:Foo})
"""
'React Native Provider':
'prefix': 'prov'
'body': """
'use strict'
import React, {Component} from 'react'
import {connect} from 'react-redux'
class ${1:Foo} extends Component {
componentWillReceiveProps(props) {
$2
}
render() { return null }
}
function mapStateToProps(state) {
return {
}
}
function mapDispatchToProps(dispatch) {
return {
}
}
export default connect(mapStateToProps, mapDispatchToProps)(${1:Foo})
"""
'.source.ruby':
'Binding pry':
'prefix': 'bp'
'body': 'binding.pry'
'Page content':
'prefix': 'ep'
'body': 'expect(page).to have_content "$1"'
'Open page':
'prefix': 'sop'
'body': 'save_and_open_page'
'Pause':
'prefix': 'std'
'body': 'print "Paused, press enter to continue."; \$stdin.gets'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment