Skip to content

Commit 7d2eec0

Browse files
committed
init
0 parents  commit 7d2eec0

20 files changed

+2667
-0
lines changed

.eslintignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
dist

.eslintrc.json

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"extends": ["eslint:recommended", "prettier"],
3+
"parser": "@typescript-eslint/parser",
4+
"plugins": ["@typescript-eslint/eslint-plugin"],
5+
"parserOptions": {
6+
"project": "./tsconfig.json"
7+
},
8+
"rules": {},
9+
"env": {
10+
"node": true
11+
}
12+
}

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
node_modules
2+
.eslintcache
3+
dist
4+
localTest

.husky/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
_

.husky/pre-commit

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/bin/sh
2+
. "$(dirname "$0")/_/husky.sh"
3+
4+
npx lint-staged

.prettierrc

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
{
2+
"useTabs": true,
3+
"overrides": [
4+
{
5+
"files": "*.md",
6+
"options": {
7+
"printWidth": 70,
8+
"useTabs": false,
9+
"trailingComma": "none",
10+
"arrowParens": "avoid",
11+
"proseWrap": "never"
12+
}
13+
},
14+
{
15+
"files": "*.{json,babelrc,eslintrc,remarkrc,prettierrc}",
16+
"options": {
17+
"useTabs": false
18+
}
19+
}
20+
]
21+
}

README.md

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
# plop generator react atomic component
2+
3+
_An opinionated [`plop`][plop] generator for [`typescript`][typescript] [`atomic`][atomic] [`react`][react] components._
4+
5+
## Installation
6+
7+
This package is hosted on [`npm`][npm].
8+
9+
```bash
10+
npm install --save-dev @a9g/plop-generator-react-atomic-component
11+
```
12+
13+
## Usage
14+
15+
First, create two interfaces to include classnames or styles (depending on if you are using react-native or not) to include them into your props.
16+
17+
```typescript
18+
import { StyleProp, ViewStyle } from "react-native";
19+
20+
export interface PropsWithClassName {
21+
className?: string;
22+
}
23+
24+
export interface PropsWithStyle {
25+
style?: StyleProp<ViewStyle>;
26+
}
27+
```
28+
29+
Afterwards, be sure you have [`plop`][plop] installed. Then, add the following lines to your `plopfile.js`.
30+
31+
```javascript
32+
const atomicGenerator =
33+
require("@a9g/plop-generator-react-atomic-component").default;
34+
35+
const defaultConfig = {
36+
createIndex: true,
37+
functional: true,
38+
basePath: "src/ui/components",
39+
withClassnameInterfaceImportPath: "/framework/ui", //make sure to configure this path
40+
withStyleInterfaceImportPath: "/framework/ui",
41+
tests: true,
42+
stories: true,
43+
styledComponents: true,
44+
useNative: false, // native and macro can't be used together
45+
useMacro: false
46+
};
47+
48+
atomicGenerator(plop, defaultConfig);
49+
```
50+
51+
Now you'll have access to the `atomic-component` generator as shown below.
52+
53+
```bash
54+
plop atomic-component
55+
```
56+
57+
```text
58+
src
59+
└── ui
60+
└── components
61+
└── $Type
62+
└── $ComponentName
63+
├── $ComponentName.tsx
64+
├── $ComponentName.test.tsx (optional)
65+
├── $ComponentName.stories.tsx (optional)
66+
├── $ComponentName.styles.tsx (optional)
67+
└── index.tsx (optional)
68+
```
69+
70+
## Questions
71+
72+
Report bugs or provide feedback by filing [issues][issues]
73+
74+
## License
75+
76+
MIT see [license.md](license.md)
77+
78+
[npm]: https://www.npmjs.com/package/@a9g/plop-generator-react-atomic-component
79+
[issues]: https://github.com/ahoendgen/plop-generator-react-atomic-component/issues
80+
[plop]: https://plopjs.com
81+
[react]: https://reactjs.org
82+
[typescript]: https://typescriptlang.org
83+
[atomic]: https://atomicdesign.bradfrost.com/

license.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# The MIT License
2+
3+
Copyright 2021 André Hoendgen, contributors
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
6+
7+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
8+
9+
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

package.json

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
{
2+
"name": "@a9g/plop-generator-react-atomic-component",
3+
"version": "0.0.1",
4+
"description": "plop generator react atomic component",
5+
"main": "dist/index.js",
6+
"types": "dist/types/index.d.ts",
7+
"author": "André Hoendgen <[email protected]> (andre-hoendgen.de)",
8+
"license": "MIT",
9+
"repository": "https://github.com/ahoendgen/plop-generator-react-atomic-component",
10+
"keywords": [
11+
"node",
12+
"typescript",
13+
"eslint",
14+
"prettier",
15+
"jest",
16+
"plop",
17+
"plop-pack",
18+
"plop-generator",
19+
"react"
20+
],
21+
"files": [
22+
"dist"
23+
],
24+
"scripts": {
25+
"start": "tsc --watch",
26+
"build": "tsc",
27+
"postbuild": "cp -r src/templates dist/templates",
28+
"pretest": "npm run lint && tsc --noEmit",
29+
"format": "prettier --loglevel warn --write \"**/*.{ts,tsx,css,md,json}\"",
30+
"posttest": "npm run format",
31+
"prepare": "husky install",
32+
"prepublishOnly": "rimraf dist && run-s build",
33+
"lint": "eslint . --cache --fix --ext .ts,.tsx"
34+
},
35+
"devDependencies": {
36+
"@typescript-eslint/eslint-plugin": "^5.6.0",
37+
"@typescript-eslint/parser": "^5.6.0",
38+
"eslint": "^8.4.1",
39+
"eslint-config-prettier": "^8.3.0",
40+
"husky": "^7.0.4",
41+
"lint-staged": "^12.1.2",
42+
"npm-run-all": "^4.1.5",
43+
"prettier": "^2.5.1",
44+
"rimraf": "^3.0.2",
45+
"typescript": "^4.5.3"
46+
},
47+
"lint-staged": {
48+
"*.{ts,tsx,css,md,json,js}": "prettier --write"
49+
},
50+
"dependencies": {
51+
"node-plop": "^0.30.0"
52+
},
53+
"volta": {
54+
"node": "16.13.1",
55+
"yarn": "1.22.17"
56+
},
57+
"publishConfig": {
58+
"access": "public"
59+
}
60+
}

plopfile.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
const generator = require("./dist/index").default;
2+
3+
const config = plop => {
4+
generator(plop);
5+
}
6+
7+
module.exports = config

0 commit comments

Comments
 (0)