Skip to content

Commit 1ef668f

Browse files
Docs: upgrade to Create React App 4 (#1276)
1 parent 53b82ec commit 1ef668f

17 files changed

+2471
-2996
lines changed

.eslintrc.json

+1
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
}
3939
],
4040
"import/extensions": ["error", "always", { "ignorePackages": true }],
41+
"import/no-anonymous-default-export": "error",
4142
"import/no-extraneous-dependencies": "off",
4243
"import/no-namespace": "error",
4344
"import/no-relative-parent-imports": "error",

docs/.env

-1
This file was deleted.

docs/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
"react-router-dom": "^5.2.0"
2525
},
2626
"devDependencies": {
27-
"react-scripts": "3.4.0"
27+
"react-scripts": "4.0.0"
2828
},
2929
"browserslist": [
3030
"last 2 versions",

docs/src/AppWrapper.js

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
// @flow strict
2+
import React, { type Node } from 'react';
3+
import { BrowserRouter, Route, Switch, Redirect } from 'react-router-dom';
4+
import App from './components/App.js';
5+
import CardPage from './components/CardPage.js';
6+
import routes from './components/routes.js';
7+
import sidebarIndex from './components/sidebarIndex.js';
8+
9+
import './docs.css';
10+
import 'gestalt/dist/gestalt.css';
11+
import 'gestalt-datepicker/dist/gestalt-datepicker.css';
12+
13+
const mapRoutes = (pages) =>
14+
pages.map((page, i) => (
15+
<Route
16+
path={`/${page}`}
17+
key={i}
18+
render={() => <CardPage cards={routes[page]} page={page} />}
19+
/>
20+
));
21+
22+
function AppWrapper(): Node {
23+
return (
24+
<BrowserRouter>
25+
<App>
26+
<Switch>
27+
<Route exact path="/" render={() => <Redirect to="/What's New" />} />
28+
{sidebarIndex.map((section) => mapRoutes(section.pages))}
29+
</Switch>
30+
</App>
31+
</BrowserRouter>
32+
);
33+
}
34+
35+
export default AppWrapper;

docs/src/components/atomDark.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// @flow strict
2-
export default {
2+
const atomDark = {
33
plain: {
44
color: '#c5c8c6',
55
backgroundColor: '#111',
@@ -91,3 +91,5 @@ export default {
9191
},
9292
],
9393
};
94+
95+
export default atomDark;

docs/src/index.js

+2-28
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,14 @@
11
// @flow strict
22
import React from 'react';
3-
import { BrowserRouter, Route, Switch, Redirect } from 'react-router-dom';
43
import { render } from 'react-dom';
5-
import 'gestalt/dist/gestalt.css';
6-
import 'gestalt-datepicker/dist/gestalt-datepicker.css';
7-
import App from './components/App.js';
8-
import CardPage from './components/CardPage.js';
9-
import routes from './components/routes.js';
10-
import './docs.css';
11-
import sidebarIndex from './components/sidebarIndex.js';
4+
import AppWrapper from './AppWrapper.js';
125

136
const container = document.getElementById('root');
14-
const mapRoutes = (pages) =>
15-
pages.map((page, i) => (
16-
<Route
17-
path={`/${page}`}
18-
key={i}
19-
render={() => <CardPage cards={routes[page]} page={page} />}
20-
/>
21-
));
227

238
if (container instanceof Element) {
249
render(
2510
<React.StrictMode>
26-
<BrowserRouter>
27-
<App>
28-
<Switch>
29-
<Route
30-
exact
31-
path="/"
32-
render={() => <Redirect to="/What's New" />}
33-
/>
34-
{sidebarIndex.map((section) => mapRoutes(section.pages))}
35-
</Switch>
36-
</App>
37-
</BrowserRouter>
11+
<AppWrapper />
3812
</React.StrictMode>,
3913
container
4014
);

package.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
"@testing-library/react": "^11.0.4",
2727
"@testing-library/react-hooks": "^3.4.2",
2828
"babel-eslint": "10.1.0",
29-
"babel-jest": "^26.5.2",
29+
"babel-jest": "^26.6.0",
3030
"blueimp-md5": "^2.18.0",
3131
"caniuse-lite": "^1.0.30001146",
3232
"chalk": "^4.1.0",
@@ -35,7 +35,7 @@
3535
"cssnano": "^4.1.10",
3636
"cypress": "^5.3.0",
3737
"danger": "10.5.0",
38-
"eslint": "7.10.0",
38+
"eslint": "7.11.0",
3939
"eslint-config-airbnb": "^18.2.0",
4040
"eslint-config-prettier": "^6.13.0",
4141
"eslint-plugin-cypress": "^2.11.2",
@@ -50,7 +50,7 @@
5050
"flow-bin": "^0.135.0",
5151
"husky": "^4.3.0",
5252
"identity-obj-proxy": "^3.0.0",
53-
"jest": "^26.5.2",
53+
"jest": "26.6.0",
5454
"jscodeshift": "^0.11.0",
5555
"lint-staged": "^10.4.0",
5656
"netlify-cli": "^2.65.1",

packages/gestalt-datepicker/rollup.config.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// eslint-disable-next-line flowtype/require-valid-file-annotation
22
import plugins from '../gestalt-core/build.js'; // eslint-disable-line import/no-relative-parent-imports
33

4-
export default {
4+
const rollupConfig = {
55
input: 'src/index.js',
66
output: [
77
{
@@ -45,3 +45,5 @@ export default {
4545
],
4646
plugins: plugins('gestalt-datepicker'),
4747
};
48+
49+
export default rollupConfig;

packages/gestalt/rollup.config.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// eslint-disable-next-line flowtype/require-valid-file-annotation
22
import plugins from '../gestalt-core/build.js'; // eslint-disable-line import/no-relative-parent-imports
33

4-
export default {
4+
const rollupConfig = {
55
input: 'src/index.js',
66
output: [
77
{
@@ -42,3 +42,5 @@ export default {
4242
],
4343
plugins: plugins('gestalt'),
4444
};
45+
46+
export default rollupConfig;

packages/gestalt/src/Button.jsdom.test.js

+2-5
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,8 @@ describe('Button', () => {
5555
render(<Button text="test" disabled ref={ref} />);
5656
expect(ref.current instanceof HTMLButtonElement).toEqual(true);
5757
expect(
58-
ref.current instanceof HTMLButtonElement && ref.current?.tabIndex
59-
).toEqual(-1);
58+
ref.current instanceof HTMLButtonElement && ref.current?.disabled
59+
).toEqual(true);
6060
});
6161

6262
it('renders a disabled link button', () => {
@@ -75,9 +75,6 @@ describe('Button', () => {
7575
expect(
7676
ref.current instanceof HTMLAnchorElement && ref.current?.href
7777
).toEqual('');
78-
expect(
79-
ref.current instanceof HTMLAnchorElement && ref.current?.tabIndex
80-
).toEqual(-1);
8178
});
8279

8380
it('renders a button removed from sequential keyboard navigation via tabIndex', () => {

packages/gestalt/src/IconButton.jsdom.test.js

+2-5
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,6 @@ describe('IconButton', () => {
6060
expect(
6161
ref.current instanceof HTMLAnchorElement && ref.current?.href
6262
).toEqual('');
63-
expect(
64-
ref.current instanceof HTMLAnchorElement && ref.current?.tabIndex
65-
).toEqual(-1);
6663
});
6764

6865
it('renders a disabled button', () => {
@@ -72,8 +69,8 @@ describe('IconButton', () => {
7269
);
7370
expect(ref.current instanceof HTMLButtonElement).toEqual(true);
7471
expect(
75-
ref.current instanceof HTMLButtonElement && ref.current?.tabIndex
76-
).toEqual(-1);
72+
ref.current instanceof HTMLButtonElement && ref.current?.disabled
73+
).toEqual(true);
7774
});
7875

7976
it('renders an IconButton removed from sequential keyboard navigation via tabIndex', () => {

packages/gestalt/src/TapArea.jsdom.test.js

-3
Original file line numberDiff line numberDiff line change
@@ -108,9 +108,6 @@ describe('TapArea', () => {
108108
expect(
109109
ref.current instanceof HTMLAnchorElement && ref.current?.href
110110
).toEqual('');
111-
expect(
112-
ref.current instanceof HTMLAnchorElement && ref.current?.tabIndex
113-
).toEqual(-1);
114111
});
115112

116113
it('renders a TapArea removed from sequential keyboard navigation via tabIndex', () => {

packages/gestalt/src/defaultLayout.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ const offscreen = (width, height = Infinity) => ({
2525
height,
2626
});
2727

28-
export default <T>({
28+
const defaultLayout = <T>({
2929
cache,
3030
columnWidth = 236,
3131
gutter = 14,
@@ -87,3 +87,5 @@ export default <T>({
8787
return positions;
8888
}, []);
8989
};
90+
91+
export default defaultLayout;

packages/gestalt/src/fullWidthLayout.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ const mindex = (arr) => {
1313
return idx;
1414
};
1515

16-
export default <T>({
16+
const fullWidthLayout = <T>({
1717
gutter = 0,
1818
cache,
1919
minCols = 2,
@@ -90,3 +90,5 @@ export default <T>({
9090
}, []);
9191
};
9292
};
93+
94+
export default fullWidthLayout;

packages/gestalt/src/icons/index.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ import workflowStatusProblem from './workflow-status-problem.svg';
170170
import workflowStatusUnstarted from './workflow-status-unstarted.svg';
171171
import workflowStatusWarning from './workflow-status-warning.svg';
172172

173-
export default {
173+
const icons = {
174174
ad,
175175
'ad-group': adGroup,
176176
add,
@@ -342,3 +342,5 @@ export default {
342342
'workflow-status-unstarted': workflowStatusUnstarted,
343343
'workflow-status-warning': workflowStatusWarning,
344344
};
345+
346+
export default icons;

packages/gestalt/src/uniformRowLayout.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ const offscreen = (width, height = Infinity) => ({
1010
height,
1111
});
1212

13-
export default <T>({
13+
const uniformRowLayout = <T>({
1414
cache,
1515
columnWidth = 236,
1616
gutter = 14,
@@ -68,3 +68,5 @@ export default <T>({
6868
}
6969
return positions;
7070
};
71+
72+
export default uniformRowLayout;

0 commit comments

Comments
 (0)