Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Docs: upgrade to Create React App 4 #1276

Merged
merged 1 commit into from Nov 2, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions .eslintrc.json
Expand Up @@ -38,6 +38,7 @@
}
],
"import/extensions": ["error", "always", { "ignorePackages": true }],
"import/no-anonymous-default-export": "error",
"import/no-extraneous-dependencies": "off",
"import/no-namespace": "error",
"import/no-relative-parent-imports": "error",
Expand Down
1 change: 0 additions & 1 deletion docs/.env

This file was deleted.

2 changes: 1 addition & 1 deletion docs/package.json
Expand Up @@ -24,7 +24,7 @@
"react-router-dom": "^5.2.0"
},
"devDependencies": {
"react-scripts": "3.4.0"
"react-scripts": "4.0.0"
},
"browserslist": [
"last 2 versions",
Expand Down
35 changes: 35 additions & 0 deletions docs/src/AppWrapper.js
@@ -0,0 +1,35 @@
// @flow strict
import React, { type Node } from 'react';
import { BrowserRouter, Route, Switch, Redirect } from 'react-router-dom';
import App from './components/App.js';
import CardPage from './components/CardPage.js';
import routes from './components/routes.js';
import sidebarIndex from './components/sidebarIndex.js';

import './docs.css';
import 'gestalt/dist/gestalt.css';
import 'gestalt-datepicker/dist/gestalt-datepicker.css';

const mapRoutes = (pages) =>
pages.map((page, i) => (
<Route
path={`/${page}`}
key={i}
render={() => <CardPage cards={routes[page]} page={page} />}
/>
));

function AppWrapper(): Node {
return (
<BrowserRouter>
<App>
<Switch>
<Route exact path="/" render={() => <Redirect to="/What's New" />} />
{sidebarIndex.map((section) => mapRoutes(section.pages))}
</Switch>
</App>
</BrowserRouter>
);
}

export default AppWrapper;
4 changes: 3 additions & 1 deletion docs/src/components/atomDark.js
@@ -1,5 +1,5 @@
// @flow strict
export default {
const atomDark = {
plain: {
color: '#c5c8c6',
backgroundColor: '#111',
Expand Down Expand Up @@ -91,3 +91,5 @@ export default {
},
],
};

export default atomDark;
30 changes: 2 additions & 28 deletions docs/src/index.js
@@ -1,40 +1,14 @@
// @flow strict
import React from 'react';
import { BrowserRouter, Route, Switch, Redirect } from 'react-router-dom';
import { render } from 'react-dom';
import 'gestalt/dist/gestalt.css';
import 'gestalt-datepicker/dist/gestalt-datepicker.css';
import App from './components/App.js';
import CardPage from './components/CardPage.js';
import routes from './components/routes.js';
import './docs.css';
import sidebarIndex from './components/sidebarIndex.js';
import AppWrapper from './AppWrapper.js';

const container = document.getElementById('root');
const mapRoutes = (pages) =>
pages.map((page, i) => (
<Route
path={`/${page}`}
key={i}
render={() => <CardPage cards={routes[page]} page={page} />}
/>
));

if (container instanceof Element) {
render(
<React.StrictMode>
<BrowserRouter>
<App>
<Switch>
<Route
exact
path="/"
render={() => <Redirect to="/What's New" />}
/>
{sidebarIndex.map((section) => mapRoutes(section.pages))}
</Switch>
</App>
</BrowserRouter>
<AppWrapper />
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ayeshakmaz @AlbertCarreras fyi had to move this wrapper outside of index.js since otherwise fast refresh does not detect incremental changes to the docs

</React.StrictMode>,
container
);
Expand Down
6 changes: 3 additions & 3 deletions package.json
Expand Up @@ -26,7 +26,7 @@
"@testing-library/react": "^11.0.4",
"@testing-library/react-hooks": "^3.4.2",
"babel-eslint": "10.1.0",
"babel-jest": "^26.5.2",
"babel-jest": "^26.6.0",
"blueimp-md5": "^2.18.0",
"caniuse-lite": "^1.0.30001146",
"chalk": "^4.1.0",
Expand All @@ -35,7 +35,7 @@
"cssnano": "^4.1.10",
"cypress": "^5.3.0",
"danger": "10.5.0",
"eslint": "7.10.0",
"eslint": "7.11.0",
"eslint-config-airbnb": "^18.2.0",
"eslint-config-prettier": "^6.13.0",
"eslint-plugin-cypress": "^2.11.2",
Expand All @@ -50,7 +50,7 @@
"flow-bin": "^0.135.0",
"husky": "^4.3.0",
"identity-obj-proxy": "^3.0.0",
"jest": "^26.5.2",
"jest": "26.6.0",
"jscodeshift": "^0.11.0",
"lint-staged": "^10.4.0",
"netlify-cli": "^2.65.1",
Expand Down
4 changes: 3 additions & 1 deletion packages/gestalt-datepicker/rollup.config.js
@@ -1,7 +1,7 @@
// eslint-disable-next-line flowtype/require-valid-file-annotation
import plugins from '../gestalt-core/build.js'; // eslint-disable-line import/no-relative-parent-imports

export default {
const rollupConfig = {
input: 'src/index.js',
output: [
{
Expand Down Expand Up @@ -45,3 +45,5 @@ export default {
],
plugins: plugins('gestalt-datepicker'),
};

export default rollupConfig;
4 changes: 3 additions & 1 deletion packages/gestalt/rollup.config.js
@@ -1,7 +1,7 @@
// eslint-disable-next-line flowtype/require-valid-file-annotation
import plugins from '../gestalt-core/build.js'; // eslint-disable-line import/no-relative-parent-imports

export default {
const rollupConfig = {
input: 'src/index.js',
output: [
{
Expand Down Expand Up @@ -42,3 +42,5 @@ export default {
],
plugins: plugins('gestalt'),
};

export default rollupConfig;
7 changes: 2 additions & 5 deletions packages/gestalt/src/Button.jsdom.test.js
Expand Up @@ -55,8 +55,8 @@ describe('Button', () => {
render(<Button text="test" disabled ref={ref} />);
expect(ref.current instanceof HTMLButtonElement).toEqual(true);
expect(
ref.current instanceof HTMLButtonElement && ref.current?.tabIndex
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@AlbertCarreras could you verify that this is correct?

When I looked at a disabled <Button />, we only set the disabled attribute, we do not set the tabIndex:

  1. Go to https://gestalt.netlify.app/Button
  2. Toggle Disable buttons
  3. Inspect the HTML in the Chrome devtools
  4. No tabIndex is set on the button

image

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@christianvuerings

The tabIndex gets to -1 if tabIndex is null (when disabled)
image

image

).toEqual(-1);
ref.current instanceof HTMLButtonElement && ref.current?.disabled
).toEqual(true);
});

it('renders a disabled link button', () => {
Expand All @@ -75,9 +75,6 @@ describe('Button', () => {
expect(
ref.current instanceof HTMLAnchorElement && ref.current?.href
).toEqual('');
expect(
ref.current instanceof HTMLAnchorElement && ref.current?.tabIndex
).toEqual(-1);
});

it('renders a button removed from sequential keyboard navigation via tabIndex', () => {
Expand Down
7 changes: 2 additions & 5 deletions packages/gestalt/src/IconButton.jsdom.test.js
Expand Up @@ -60,9 +60,6 @@ describe('IconButton', () => {
expect(
ref.current instanceof HTMLAnchorElement && ref.current?.href
).toEqual('');
expect(
ref.current instanceof HTMLAnchorElement && ref.current?.tabIndex
).toEqual(-1);
});

it('renders a disabled button', () => {
Expand All @@ -72,8 +69,8 @@ describe('IconButton', () => {
);
expect(ref.current instanceof HTMLButtonElement).toEqual(true);
expect(
ref.current instanceof HTMLButtonElement && ref.current?.tabIndex
).toEqual(-1);
ref.current instanceof HTMLButtonElement && ref.current?.disabled
).toEqual(true);
});

it('renders an IconButton removed from sequential keyboard navigation via tabIndex', () => {
Expand Down
3 changes: 0 additions & 3 deletions packages/gestalt/src/TapArea.jsdom.test.js
Expand Up @@ -108,9 +108,6 @@ describe('TapArea', () => {
expect(
ref.current instanceof HTMLAnchorElement && ref.current?.href
).toEqual('');
expect(
ref.current instanceof HTMLAnchorElement && ref.current?.tabIndex
).toEqual(-1);
});

it('renders a TapArea removed from sequential keyboard navigation via tabIndex', () => {
Expand Down
4 changes: 3 additions & 1 deletion packages/gestalt/src/defaultLayout.js
Expand Up @@ -25,7 +25,7 @@ const offscreen = (width, height = Infinity) => ({
height,
});

export default <T>({
const defaultLayout = <T>({
cache,
columnWidth = 236,
gutter = 14,
Expand Down Expand Up @@ -87,3 +87,5 @@ export default <T>({
return positions;
}, []);
};

export default defaultLayout;
4 changes: 3 additions & 1 deletion packages/gestalt/src/fullWidthLayout.js
Expand Up @@ -13,7 +13,7 @@ const mindex = (arr) => {
return idx;
};

export default <T>({
const fullWidthLayout = <T>({
gutter = 0,
cache,
minCols = 2,
Expand Down Expand Up @@ -90,3 +90,5 @@ export default <T>({
}, []);
};
};

export default fullWidthLayout;
4 changes: 3 additions & 1 deletion packages/gestalt/src/icons/index.js
Expand Up @@ -170,7 +170,7 @@ import workflowStatusProblem from './workflow-status-problem.svg';
import workflowStatusUnstarted from './workflow-status-unstarted.svg';
import workflowStatusWarning from './workflow-status-warning.svg';

export default {
const icons = {
ad,
'ad-group': adGroup,
add,
Expand Down Expand Up @@ -342,3 +342,5 @@ export default {
'workflow-status-unstarted': workflowStatusUnstarted,
'workflow-status-warning': workflowStatusWarning,
};

export default icons;
4 changes: 3 additions & 1 deletion packages/gestalt/src/uniformRowLayout.js
Expand Up @@ -10,7 +10,7 @@ const offscreen = (width, height = Infinity) => ({
height,
});

export default <T>({
const uniformRowLayout = <T>({
cache,
columnWidth = 236,
gutter = 14,
Expand Down Expand Up @@ -68,3 +68,5 @@ export default <T>({
}
return positions;
};

export default uniformRowLayout;