Skip to content

Commit 79247ce

Browse files
authored
feat: atom extension (#44)
1 parent 03d6cb3 commit 79247ce

File tree

7 files changed

+226
-15
lines changed

7 files changed

+226
-15
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,4 @@
2020
"format": "prettier --write \"packages/vscode/{code,snippets}/**/*.{js,jsx,ts,tsx,json,md}\"",
2121
"format:check": "prettier --check \"packages/vscode/{code,snippets}/**/*.{js,jsx,ts,tsx,json,md}\""
2222
}
23-
}
23+
}

packages/atom/README.md

Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
# Usage Guide
2+
3+
# Installation
4+
5+
- Install the Atom package
6+
- Reload Atom
7+
- The code snippets are ready to use 🎉
8+
9+
# Usage
10+
11+
## React
12+
13+
### JavaScript
14+
15+
1. `rimr` (Import React)
16+
17+
```jsx
18+
import React from "react";
19+
```
20+
21+
2. `rimrd` (Import ReactDOM)
22+
23+
```jsx
24+
import ReactDOM from "react-dom";
25+
```
26+
27+
3. `rimrs` (Import React and useState)
28+
29+
```jsx
30+
import React, { useState } from "react";
31+
```
32+
33+
4. `rimrse` (Import React, useState and useEffect)
34+
35+
```jsx
36+
import React, { useState, useEffect } from "react";
37+
```
38+
39+
5. `rfc` (React functional component)
40+
41+
```jsx
42+
const Component = () => {
43+
return <div></div>;
44+
};
45+
export default Component;
46+
```
47+
48+
6. `rue` (useEffect hook)
49+
50+
```jsx
51+
useEffect(() => {}, []);
52+
```
53+
54+
7. `rus` (useState hook)
55+
56+
```jsx
57+
const [state, setState] = useState(initialValue);
58+
```
59+
60+
8. `ruc` (useContext hook)
61+
62+
```jsx
63+
const value = useContext(myContext);
64+
```
65+
66+
9. `rur` (useRef hook)
67+
68+
```jsx
69+
const refContainer = useRef(initialValue);
70+
```
71+
72+
### TypeScript
73+
74+
1. `rfcet` (React functional component)
75+
76+
```tsx
77+
import React from "react";
78+
79+
interface Props {}
80+
81+
function Component({}: Props) {
82+
return <div></div>;
83+
}
84+
85+
export default Component;
86+
```
87+
88+
2. `ruet` (useEffect hook)
89+
90+
```tsx
91+
useEffect(() => {}, []);
92+
```
93+
94+
3. `rust` (useState hook)
95+
96+
```tsx
97+
const [state, setState] = useState(initialValue);
98+
```
99+
100+
4. `ruct` (useContext hook)
101+
102+
```tsx
103+
const value = useContext(myContext);
104+
```
105+
106+
5. `rurt` (useRef hook)
107+
108+
```tsx
109+
const refContainer = useRef(initialValue);
110+
```

packages/atom/package.json

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"name": "react-nextjs-snippets",
3+
"version": "0.0.1",
4+
"description": "This is an extension for React and Next.js Snippets with Typescript support as well!",
5+
"keywords": [
6+
"code-snippets",
7+
"react-code-snippets"
8+
],
9+
"repository": "https://github.com/avneesh0612/react-nextjs-snippets",
10+
"license": "GNU",
11+
"engines": {
12+
"atom": ">=1.0.0 <2.0.0"
13+
}
14+
}
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
".source.js, .source.jsx":
2+
'JavaScript: Import React':
3+
'prefix': 'rimr'
4+
'body': """
5+
import React from 'react';
6+
"""
7+
'JavaScript: Import ReactDOM':
8+
'prefix': 'rimrd'
9+
'body': """
10+
import ReactDOM from 'react-dom';
11+
"""
12+
'JavaScript: Import React and useState':
13+
'prefix': 'rimrs'
14+
'body': """
15+
import React, { useState } from 'react';
16+
"""
17+
'JavaScript: Import React, useState and useEffect':
18+
'prefix': 'rimrse'
19+
'body': """
20+
import React, { useState, useEffect} from 'react';
21+
"""
22+
'JavaScript: React functional component':
23+
'prefix': 'rfc'
24+
'body': """
25+
const ${1:Component} = () => {
26+
return <div></div>
27+
}
28+
29+
export default ${1:Component}
30+
"""
31+
'JavaScript: useEffect hook':
32+
'prefix': 'rue'
33+
'body': """
34+
useEffect(() => {
35+
$1
36+
}, []);
37+
"""
38+
'JavaScript: useState hook':
39+
'prefix': 'rus'
40+
'body': """
41+
const [${1:state}, set${1:State}] = useState(${2:initialValue});
42+
"""
43+
'JavaScript: useContext hook':
44+
'prefix': 'ruc'
45+
'body': """
46+
const ${1:value} = useContext(${2:myContext});
47+
"""
48+
'JavaScript: useRef hook':
49+
'prefix': 'rur'
50+
'body': """
51+
const ${1:refContainer} = useRef(${2:intialValue});
52+
"""
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
".source.ts, .source.tsx":
2+
'TypeScript: React functional component':
3+
'prefix': 'rfcet'
4+
'body': """
5+
import React from "react";
6+
7+
interface Props {}
8+
9+
function ${1:Component}({}: Props) {
10+
return <div></div>;
11+
}
12+
13+
export default ${1:Component};
14+
"""
15+
'TypeScript: useEffect hook':
16+
'prefix': 'ruet'
17+
'body': """
18+
useEffect(() => {
19+
\t${1}
20+
}, []);
21+
"""
22+
'TypeScript: useState hook':
23+
'prefix': 'rust'
24+
'body': """
25+
const [${1:state}, set${1:State}] = useState(${2:initialValue});
26+
"""
27+
'TypeScript: useContext hook':
28+
'prefix': 'ruct'
29+
'body': """
30+
const ${1:value} = useContext(${2:myContext});
31+
"""
32+
'TypeScript: useRef hook':
33+
'prefix': 'rurt'
34+
'body': """
35+
const ${1:refContainer} = useRef(${2:initialValue});
36+
"""

packages/vscode/README.md

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -87,27 +87,27 @@
8787

8888
2. `ruet` (useEffect hook)
8989

90-
```tsx
91-
useEffect(() => {}, []);
92-
```
90+
```tsx
91+
useEffect(() => {}, []);
92+
```
9393

9494
3. `rust` (useState hook)
9595

96-
```tsx
97-
const [state, setState] = useState(initialValue);
98-
```
96+
```tsx
97+
const [state, setState] = useState(initialValue);
98+
```
9999

100100
4. `ruct` (useContext hook)
101101

102-
```tsx
103-
const value = useContext(myContext);
104-
```
102+
```tsx
103+
const value = useContext(myContext);
104+
```
105105

106106
5. `rurt` (useRef hook)
107107

108-
```tsx
109-
const refContainer = useRef(initialValue);
110-
```
108+
```tsx
109+
const refContainer = useRef(initialValue);
110+
```
111111

112112
## NextJS
113113

@@ -258,4 +258,3 @@
258258
259259
export default Document;
260260
```
261-

packages/vscode/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "react-nextjs-snippets",
33
"displayName": "React and Next.js Snippets",
4-
"description": "This is an extension for React and Next.js Snippets with ts support as well!",
4+
"description": "This is an extension for React and Next.js Snippets with Typescript support as well!",
55
"version": "1.2.4",
66
"publisher": "AvneeshAgarwal",
77
"icon": "logo.png",

0 commit comments

Comments
 (0)