Skip to content

Commit a61e7bf

Browse files
committed
Add new snippets
1 parent 793c571 commit a61e7bf

File tree

3 files changed

+280
-0
lines changed

3 files changed

+280
-0
lines changed

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,10 @@
22

33
## 1.0.0
44
- Initial release
5+
6+
## 1.1.0
7+
- Add a bunch of new snippets:
8+
- pre-commented component scaffolding.
9+
- lifecycle methods
10+
- setState + setState transactional
11+
- comment banner

README.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,23 @@ Below is a list of all available snippets and the triggers of each one..
2222
| Trigger | Content |
2323
| -------: | ------- |
2424
| `orStless` | stateless component skeleton |
25+
| `orCStless` | commented stateless component skeleton |
2526
| `orAbsStless` | abstract stateless component skeleton |
27+
| `orCAbsStless` | commented abstract stateless component skeleton |
2628
| `orStful` | stateful component skeleton |
29+
| `orCStful` | commneted stateful component skeleton |
2730
| `orAbsStful` | abstract stateful component skeleton |
31+
| `orCAbsStful` | commented abstract stateful component skeleton |
2832
| `orMixin` | prop mixin skeleton |
33+
| `orWM` | `componentWillMount` method |
34+
| `orDM` | `componentDidMount` method |
35+
| `orWRP` | `componentWillReceiveProps` method |
36+
| `orSUp` | `shouldComponentUpdate` method |
37+
| `orWUp` | `componentWillUpdate` method |
38+
| `orDUp` | `componentDidUpdate` method |
39+
| `orWUn` | `componentWillUnmount` method |
40+
| `orSS` | invoked `setState` with `newState()` |
41+
| `orSST` | invoked `setState` with function |
42+
| `orBanner` | comment banner |
2943

3044
[over_react]: https://workiva.github.io/over_react/

snippets/snippets.json

Lines changed: 259 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,46 @@
2121
],
2222
"description": "Creates a stateless OverReact component"
2323
},
24+
"statelessCommentedComponents": {
25+
"prefix": "orCStless",
26+
"body": [
27+
"@Factory()",
28+
"UiFactory<${1:MyComponent}Props> ${1:MyComponent};",
29+
"",
30+
"@Props()",
31+
"class ${1:MyComponent}Props extends UiProps {",
32+
"",
33+
"}",
34+
"",
35+
"@Component()",
36+
"class ${1:MyComponent}Component extends UiComponent<${1:MyComponent}Props> {",
37+
"\t// Refs",
38+
"",
39+
"\t// --------------------------------------------------------------------------",
40+
"\t// React Component Specifications and Lifecycle Methods",
41+
"\t// --------------------------------------------------------------------------",
42+
"",
43+
"\t@override",
44+
"\tMap getDefaultProps() => (newProps());",
45+
"",
46+
"\t@override",
47+
"\trender() { }",
48+
"",
49+
"\t// --------------------------------------------------------------------------",
50+
"\t// Private Utility Methods",
51+
"\t// --------------------------------------------------------------------------",
52+
"",
53+
"\t// --------------------------------------------------------------------------",
54+
"\t// Public Utility Methods",
55+
"\t// --------------------------------------------------------------------------",
56+
"",
57+
"\t// --------------------------------------------------------------------------",
58+
"\t// Public API Methods",
59+
"\t// --------------------------------------------------------------------------",
60+
"}"
61+
],
62+
"description": "Creates a commented stateless OverReact component"
63+
},
2464
"abstractStatelessComponents": {
2565
"prefix": "orAbsStless",
2666
"body": [
@@ -40,6 +80,43 @@
4080
],
4181
"description": "Creates an abstract stateless OverReact component"
4282
},
83+
"abstractCommentedStatelessComponents": {
84+
"prefix": "orCAbsStless",
85+
"body": [
86+
"@AbstractProps()",
87+
"abstract class ${1:MyComponent}Props extends UiProps {",
88+
"",
89+
"}",
90+
"",
91+
"@AbstractComponent()",
92+
"abstract class ${1:MyComponent}Component<T extends ${1:MyComponent}Props> extends UiComponent<T> {",
93+
"\t// Refs",
94+
"",
95+
"\t// --------------------------------------------------------------------------",
96+
"\t// React Component Specifications and Lifecycle Methods",
97+
"\t// --------------------------------------------------------------------------",
98+
"",
99+
"\t@override",
100+
"\tMap getDefaultProps() => (newProps());",
101+
"",
102+
"\t@override",
103+
"\trender() { }",
104+
"",
105+
"\t// --------------------------------------------------------------------------",
106+
"\t// Private Utility Methods",
107+
"\t// --------------------------------------------------------------------------",
108+
"",
109+
"\t// --------------------------------------------------------------------------",
110+
"\t// Public Utility Methods",
111+
"\t// --------------------------------------------------------------------------",
112+
"",
113+
"\t// --------------------------------------------------------------------------",
114+
"\t// Public API Methods",
115+
"\t// --------------------------------------------------------------------------",
116+
"}"
117+
],
118+
"description": "Creates an commented abstract stateless OverReact component"
119+
},
43120
"statefulComponents": {
44121
"prefix": "orStful",
45122
"body": [
@@ -70,6 +147,54 @@
70147
],
71148
"description": "Creates a stateful OverReact component"
72149
},
150+
"statefulCommentedComponents": {
151+
"prefix": "orCStful",
152+
"body": [
153+
"@Factory()",
154+
"UiFactory<${1:MyComponent}Props> ${1:MyComponent};",
155+
"",
156+
"@Props()",
157+
"class ${1:MyComponent}Props extends UiProps {",
158+
"",
159+
"}",
160+
"",
161+
"@State()",
162+
"class ${1:MyComponent}State extends UiState {",
163+
"",
164+
"}",
165+
"",
166+
"@Component()",
167+
"class ${1:MyComponent}Component extends UiStatefulComponent<${1:MyComponent}Props, ${1:MyComponent}State> {",
168+
"\t// Refs",
169+
"",
170+
"\t// --------------------------------------------------------------------------",
171+
"\t// React Component Specifications and Lifecycle Methods",
172+
"\t// --------------------------------------------------------------------------",
173+
"",
174+
"\t@override",
175+
"\tMap getDefaultProps() => (newProps());",
176+
"",
177+
"\t@override",
178+
"\tMap getInitialState() => (newState());",
179+
"",
180+
"\t@override",
181+
"\trender() { }",
182+
"",
183+
"\t// --------------------------------------------------------------------------",
184+
"\t// Private Utility Methods",
185+
"\t// --------------------------------------------------------------------------",
186+
"",
187+
"\t// --------------------------------------------------------------------------",
188+
"\t// Public Utility Methods",
189+
"\t// --------------------------------------------------------------------------",
190+
"",
191+
"\t// --------------------------------------------------------------------------",
192+
"\t// Public API Methods",
193+
"\t// --------------------------------------------------------------------------",
194+
"}"
195+
],
196+
"description": "Creates a commented stateful OverReact component"
197+
},
73198
"abstractStatefulComponents": {
74199
"prefix": "orAbsStful",
75200
"body": [
@@ -97,6 +222,51 @@
97222
],
98223
"description": "Creates an abstract stateful OverReact component"
99224
},
225+
"abstractCommentedStatefulComponents": {
226+
"prefix": "orCAbsStful",
227+
"body": [
228+
"@AbstractProps()",
229+
"abstract class ${1:MyComponent}Props extends UiProps {",
230+
"",
231+
"}",
232+
"",
233+
"@AbstractState()",
234+
"abstract class ${1:MyComponent}State extends UiState {",
235+
"",
236+
"}",
237+
"",
238+
"@AbstractComponent()",
239+
"abstract class ${1:MyComponent}Component<T extends ${1:MyComponent}Props, S extends ${1:MyComponent}State> extends UiStatefulComponent<T, S> {",
240+
"\t// Refs",
241+
"",
242+
"\t// --------------------------------------------------------------------------",
243+
"\t// React Component Specifications and Lifecycle Methods",
244+
"\t// --------------------------------------------------------------------------",
245+
"",
246+
"\t@override",
247+
"\tMap getDefaultProps() => (newProps());",
248+
"",
249+
"\t@override",
250+
"\tMap getInitialState() => (newState());",
251+
"",
252+
"\t@override",
253+
"\trender() { }",
254+
"",
255+
"\t// --------------------------------------------------------------------------",
256+
"\t// Private Utility Methods",
257+
"\t// --------------------------------------------------------------------------",
258+
"",
259+
"\t// --------------------------------------------------------------------------",
260+
"\t// Public Utility Methods",
261+
"\t// --------------------------------------------------------------------------",
262+
"",
263+
"\t// --------------------------------------------------------------------------",
264+
"\t// Public API Methods",
265+
"\t// --------------------------------------------------------------------------",
266+
"}"
267+
],
268+
"description": "Creates an commented abstract stateful OverReact component"
269+
},
100270
"propMixins": {
101271
"prefix": "orMixin",
102272
"body": [
@@ -116,5 +286,94 @@
116286
"}"
117287
],
118288
"description": "Creates an abstract stateful OverReact component"
289+
},
290+
"componentWillMount": {
291+
"prefix": "orWM",
292+
"body": [
293+
"@override",
294+
"void componentWillMount() {",
295+
"\tsuper.componentWillMount()",
296+
"",
297+
"}"
298+
],
299+
"description": "componentWillMount method"
300+
},
301+
"componentDidMount": {
302+
"prefix": "orDM",
303+
"body": [
304+
"@override",
305+
"void componentDidMount() { }"
306+
],
307+
"description": "componentDidMount method"
308+
},
309+
"componentWillReceiveProps": {
310+
"prefix": "orWRP",
311+
"body": [
312+
"@override",
313+
"void componentWillReceiveProps(Map nextProps) {",
314+
"\tsuper.componentWillReceiveProps(nextProps)",
315+
"",
316+
"}"
317+
],
318+
"description": "componentWillReceiveProps method"
319+
},
320+
"shouldComponentUpdate": {
321+
"prefix": "orSUp",
322+
"body": [
323+
"@override",
324+
"bool shouldComponentUpdate(Map nextProps, Map nextState) { }"
325+
],
326+
"description": "shouldComponentUpdate method"
327+
},
328+
"componentWillUpdate": {
329+
"prefix": "orWUp",
330+
"body": [
331+
"@override",
332+
"void componentWillUpdate(Map nextProps, Map nextState) { }"
333+
],
334+
"description": "componentWillUpdate method"
335+
},
336+
"componentDidUpdate": {
337+
"prefix": "orDUp",
338+
"body": [
339+
"@override",
340+
"void componentDidUpdate(Map prevProps, Map prevState) { }"
341+
],
342+
"description": "componentDidUpdate method"
343+
},
344+
"componentWillUnmount": {
345+
"prefix": "orWUn",
346+
"body": [
347+
"@override",
348+
"void componentWillUnmount() { }"
349+
],
350+
"description": "componentWillUnmount method"
351+
},
352+
"setState": {
353+
"prefix": "orSS",
354+
"body": [
355+
"setState(newState());"
356+
],
357+
"description": "setState with new state"
358+
},
359+
"setStateTransactional": {
360+
"prefix": "orSST",
361+
"body": [
362+
"setState((Map prevState, Map props) {",
363+
"\tvar stateChanges = newState()",
364+
"",
365+
"\treturn stateChanges;",
366+
"});"
367+
],
368+
"description": "setState with new state"
369+
},
370+
"banner": {
371+
"prefix": "orBanner",
372+
"body": [
373+
"// --------------------------------------------------------------------------",
374+
"// ${1:Message}",
375+
"// --------------------------------------------------------------------------"
376+
],
377+
"description": "Creates a code comment banner"
119378
}
120379
}

0 commit comments

Comments
 (0)