Skip to content

Commit 13b106c

Browse files
committed
add updated template from react-factory
1 parent f7d227c commit 13b106c

31 files changed

+14967
-15800
lines changed

.gitignore

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,19 @@
1919
npm-debug.log*
2020
yarn-debug.log*
2121
yarn-error.log*
22+
23+
# test coverage
24+
/cypress/screenshots
25+
/coverage/src
26+
/coverage/home
27+
/coverage/Users
28+
/coverage/base.css
29+
/coverage/block-navigation.js
30+
/coverage/coverage-final.json
31+
/coverage/coverage-summary.json
32+
/coverage/index.html
33+
/coverage/prettify.css
34+
/coverage/prettify.js
35+
/coverage/sort-arrow-sprite.png
36+
/coverage/sorter.js
37+
/coverage/favicon.png

.prettierignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
build/
2+
dist/
3+
lib/build/
4+
lib/dist/

.prettierrc.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,6 @@
22
"useTabs": true,
33
"tabWidth": 4,
44
"trailingComma": "es5",
5-
"printWidth": 80
5+
"printWidth": 120,
6+
"singleQuote": true
67
}

.vscode/snippets/typescriptreact.json

Lines changed: 103 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
"",
1111
"}",
1212
"",
13-
"function $TM_FILENAME_BASE(props: Props) {",
13+
"export function $TM_FILENAME_BASE(props: Props) {",
1414
"",
1515
"const { } = props;",
1616
"const classes = useStyles();",
@@ -27,9 +27,7 @@
2727
"root: {",
2828
"",
2929
"},",
30-
"});",
31-
"",
32-
"export default $TM_FILENAME_BASE;"
30+
"});"
3331
],
3432
"description": "component + makeStyle"
3533
},
@@ -44,7 +42,7 @@
4442
"",
4543
"}",
4644
"",
47-
"function $TM_FILENAME_BASE(props: Props) {",
45+
"export function $TM_FILENAME_BASE(props: Props) {",
4846
"",
4947
"const { } = props;",
5048
"const classes = useStyles(props);",
@@ -61,9 +59,7 @@
6159
"root: (props: Props) => ({",
6260
"",
6361
"}),",
64-
"});",
65-
"",
66-
"export default $TM_FILENAME_BASE;"
62+
"});"
6763
],
6864
"description": "component + makeStyle + Props"
6965
},
@@ -78,7 +74,7 @@
7874
"",
7975
"}",
8076
"",
81-
"function $TM_FILENAME_BASE(props: Props) {",
77+
"export function $TM_FILENAME_BASE(props: Props) {",
8278
"",
8379
"const { } = props;",
8480
"const classes = useStyles(props);",
@@ -95,9 +91,7 @@
9591
"root: (props: Props) => ({",
9692
"",
9793
"}),",
98-
"}));",
99-
"",
100-
"export default $TM_FILENAME_BASE;"
94+
"}));"
10195
],
10296
"description": "component + makeStyle + Props + Theme"
10397
},
@@ -112,7 +106,7 @@
112106
"",
113107
"}",
114108
"",
115-
"function $TM_FILENAME_BASE(props: Props) {",
109+
"export function $TM_FILENAME_BASE(props: Props) {",
116110
"",
117111
"const { } = props;",
118112
"const classes = useStyles();",
@@ -129,16 +123,107 @@
129123
"root: {",
130124
"",
131125
"},",
132-
"}));",
133-
"",
134-
"export default $TM_FILENAME_BASE;"
126+
"}));"
135127
],
136128
"description": "component + makeStyle + Theme"
137129
},
138130
"useState": {
139-
"prefix": "state",
131+
"prefix": "useState",
132+
"body": ["const [${1:value}, set${1/(.*)/${1:/capitalize}/}] = React.useState(${2:value});$0"]
133+
},
134+
135+
"lodash": {
136+
"prefix": "lodash",
137+
"body": ["import * as _ from 'lodash';"]
138+
},
139+
140+
"useAction": {
141+
"prefix": "useAction",
140142
"body": [
141-
"const [${1:value}, set${2:Value}] = React.useState(${3:value});$0"
143+
"// import * as ${1/(.*)/${1:/capitalize}/}Actions from '../actions/${1:actionname}';",
144+
"const ${1:actionname}Actions: typeof ${1/(.*)/${1:/capitalize}/}Actions = useActions(${1/(.*)/${1:/capitalize}/}Actions);"
142145
]
146+
},
147+
148+
"useEffect": {
149+
"prefix": "useEffect",
150+
"body": ["React.useEffect(() => {", "$0", "}, []);"]
151+
},
152+
153+
"useSelector": {
154+
"prefix": "useSelector",
155+
"body": "const ${1:varialbe}: ${2:type} = useSelector((state: RootState) => state.${1:varialbe});"
156+
},
157+
158+
"useHistory": {
159+
"prefix": "useHistory",
160+
"body": "const history = useHistory();"
161+
},
162+
163+
"useMediaQuery - Breakpoint": {
164+
"prefix": "useMedia",
165+
"body": "const isMobile = useMediaQuery((theme: Theme) => theme.breakpoints.down('sm'));"
166+
},
167+
168+
"useMediaQuery - ScreenWidth": {
169+
"prefix": "useMedia",
170+
"body": "const showIcon = useMediaQuery('(max-width:400px)');"
171+
},
172+
173+
"useResponsive - isMobile": {
174+
"prefix": "isMobile",
175+
"body": "const { isMobile } = useResponsive();"
176+
},
177+
178+
"handleTextField": {
179+
"prefix": "handleTextField",
180+
"body": [
181+
"const handle${1:value} = (e: React.ChangeEvent<HTMLInputElement>) => {",
182+
"const value = e.target.value;",
183+
"",
184+
"};"
185+
]
186+
},
187+
188+
"handleSelect": {
189+
"prefix": "handleSelect",
190+
"body": [
191+
"const handle${1:value} = (e: React.ChangeEvent<{ value: any }>) => {",
192+
"const value = e.target.value as string;",
193+
"",
194+
"};"
195+
]
196+
},
197+
198+
"story": {
199+
"prefix": "story",
200+
"body": [
201+
"import { Meta } from '@storybook/react';",
202+
"import * as React from 'react';",
203+
"import { withTheme } from './index.stories';",
204+
"import { ${TM_FILENAME_BASE/(.stories)//}Props} from '../src/components/${TM_FILENAME_BASE/(.stories)//}'",
205+
"import { ${TM_FILENAME_BASE/(.stories)//} } from '../src';",
206+
"",
207+
"export default {",
208+
"title: '${TM_FILENAME_BASE/(.stories)//}',",
209+
"component: ${TM_FILENAME_BASE/(.stories)//},",
210+
"// argTypes: { onClick: { action: 'clicked' } },",
211+
"} as Meta;",
212+
"",
213+
"const Template = (args: ${TM_FILENAME_BASE/(.stories)//}Props) =>",
214+
"withTheme(",
215+
"<${TM_FILENAME_BASE/(.stories)//} {...args} />",
216+
");",
217+
"",
218+
"export const Default = Template.bind({});",
219+
"",
220+
"Default.args = {",
221+
"",
222+
"// add your props here",
223+
"",
224+
"} as ${TM_FILENAME_BASE/(.stories)//}Props;",
225+
""
226+
],
227+
"description": "storybook"
143228
}
144229
}

.yo-rc.json

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"generator-react-factory": {
3+
"promptValues": {
4+
"githubUser": "innFactory",
5+
"appName": "create-react-app-material-typescript-redux",
6+
"appVersion": "3.0.0",
7+
"otherFeatures": [
8+
"Snackbar State and Component"
9+
]
10+
}
11+
}
12+
}

README.md

Lines changed: 29 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
# Create React App example with Material-UI, TypeScript, Redux and Routing
1+
# create-react-app-material-typescript-redux derived from Create React App example with Material-UI, TypeScript, Redux and Routing
22

3-
This is a new version with React Hooks, Material-UI 4 and React-Redux 7 (with hooks!). We use this template for all our new projects. If you want to bootstrap a project with the classic approach without hooks but with class components, you are welcome to use the [previous version](https://github.com/innFactory/create-react-app-material-typescript-redux/tree/v1).
3+
Made with our new CLI Tool [react-factory](https://github.com/innFactory/react-factory) for choosing the optional features and configure our individual setup.
44

55
<img width="100%" src="screenshot.png" alt="example"/>
66

@@ -11,53 +11,46 @@ Inspired by:
1111

1212
## Contains
1313

14-
- [x] [Material-UI](https://github.com/mui-org/material-ui)
15-
- [x] [Typescript](https://www.typescriptlang.org/)
16-
- [x] [React](https://facebook.github.io/react/)
17-
- [x] [Redux](https://github.com/reactjs/redux)
18-
- [x] [Redux-Thunk](https://github.com/gaearon/redux-thunk)
19-
- [x] [Redux-Persist](https://github.com/rt2zz/redux-persist)
20-
- [x] [React Router](https://github.com/ReactTraining/react-router)
21-
- [x] [Redux DevTools Extension](https://github.com/zalmoxisus/redux-devtools-extension)
22-
- [x] [TodoMVC example](http://todomvc.com)
23-
- [x] PWA Support
14+
- [x] [Material-UI](https://github.com/mui-org/material-ui)
15+
- [x] [Typescript](https://www.typescriptlang.org/)
16+
- [x] [React](https://facebook.github.io/react/)
17+
- [x] [Redux](https://github.com/reactjs/redux)
18+
- [x] [Redux-Thunk](https://github.com/gaearon/redux-thunk)
19+
- [x] [Redux-Persist](https://github.com/rt2zz/redux-persist)
20+
- [x] [React Router](https://github.com/ReactTraining/react-router)
21+
- [x] [Redux DevTools Extension](https://github.com/zalmoxisus/redux-devtools-extension)
22+
- [x] [TodoMVC example](http://todomvc.com)
23+
24+
Optional:
25+
26+
- [ ] Cypress-Tests-Environment
27+
- [ ] Firebase-Integration
28+
- [ ] Github Actions (cypress-test, build-and-deploy to firebase)
29+
- [ ] Snackbars
30+
- [ ] Subfolder Library
31+
- [ ] Service Worker
32+
- [ ] PolyFills (IE11)
2433

25-
## Roadmap
26-
27-
- [x] Make function based components and use hooks for state etc.
28-
- [x] Implement [Material-UIs new styling solution](https://material-ui.com/css-in-js/basics/) based on hooks
29-
- [x] use react-redux hooks
30-
- [ ] Hot Reloading -> Waiting for official support of react-scripts
3134

3235
## How to use
3336

34-
Download or clone this repo
35-
36-
```bash
37-
git clone https://github.com/innFactory/create-react-app-material-typescript-redux
38-
cd create-react-app-material-typescript-redux
39-
```
37+
We made a CLI Tool [react-factory](https://github.com/innFactory/react-factory) to include more options.
4038

41-
Install it and run:
39+
<img width="70%" src="react_factory.png" alt="example"/>
4240

41+
First install [Yeoman](http://yeoman.io) and the CLI Tool:
4342
```bash
44-
npm i
45-
npm start
43+
npm install -g yo
44+
npm install -g generator-react-factory
4645
```
4746

48-
## Enable PWA ServiceWorker [OPTIONAL]
47+
Then generate your new project:
4948

50-
Just comment in the following line in the `index.tsx`:
51-
52-
```javascript
53-
// registerServiceWorker();
49+
```bash
50+
yo react-factory
5451
```
5552

56-
to
5753

58-
```javascript
59-
registerServiceWorker();
60-
```
6154

6255
## Enable Prettier [OPTIONAL]
6356

0 commit comments

Comments
 (0)