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

Dark scheme overlay #7052

Merged
merged 25 commits into from
Oct 24, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
7bdd265
Set background color in the overlay from styles.
Fabianopb Apr 8, 2019
2d049b3
Add method for getting OS color scheme.
Fabianopb Apr 8, 2019
612f5b8
Set overlay style based on scheme.
Fabianopb Apr 8, 2019
fbd8906
Set background color from iframe.
Fabianopb Apr 9, 2019
89e559f
Pass color scheme via props.
Fabianopb Apr 9, 2019
a9c5770
Style error and warn code blocks.
Fabianopb Apr 11, 2019
952f8a3
Start to use the concept of theme objects.
Fabianopb May 12, 2019
73abe96
Pass theme down to most of components.
Fabianopb May 12, 2019
b1951b5
Add theme to Collapsible and NavigationBar.
Fabianopb May 13, 2019
57c364f
Put ANSI colors in the theme objects.
Fabianopb May 13, 2019
2c4ab11
Create and use a flow type for the Theme.
Fabianopb May 13, 2019
62f921e
Merge remote-tracking branch 'upstream/master' into dark-scheme-overlay
Fabianopb May 13, 2019
a72ad94
Use context hook to spread the theme.
Fabianopb May 14, 2019
cf03c7e
Remove unused variable.
Fabianopb May 14, 2019
96d8ee7
Finalize style of dark theme.
Fabianopb May 14, 2019
195ec3f
Fix pre background in light theme.
Fabianopb May 14, 2019
c261af4
Removed apparently unused variables and method.
Fabianopb May 14, 2019
2cd2d84
Remove hex hash addition from the ansi generator.
Fabianopb May 15, 2019
e605d4d
Update flow-bin to get rid of lint errors related to hooks.
Fabianopb May 15, 2019
9e580dd
Merge remote-tracking branch 'upstream/master' into dark-scheme-overlay
Fabianopb May 15, 2019
0bf749b
Merge branch 'master' of github.com:facebook/create-react-app into da…
Fabianopb Oct 9, 2019
ebb270b
Merge branch 'master' into dark-scheme-overlay
ianschmitz Oct 23, 2019
8f0fd6d
Update initDOM.js
ianschmitz Oct 23, 2019
6d4411e
Update bug_report.md
ianschmitz Oct 23, 2019
6bcb410
Ignore flow errors
ianschmitz Oct 24, 2019
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions CHANGELOG-1.x.md
Original file line number Diff line number Diff line change
Expand Up @@ -1577,20 +1577,20 @@ Unhandled Promise rejections will now crash tests. You can fix them by explicitl
After the regular update procedure above, add these line to `<head>` in `public/index.html`:

```html
<meta name="theme-color" content="#000000">
<!--
<meta name="theme-color" content="#000000" />
<!--
manifest.json provides metadata used when your web app is added to the
homescreen on Android. See https://developers.google.com/web/fundamentals/engage-and-retain/web-app-manifest/
-->
<link rel="manifest" href="%PUBLIC_URL%/manifest.json">
<link rel="manifest" href="%PUBLIC_URL%/manifest.json" />
```

Add `<noscript>` to `<body>` in `public/index.html`:

```html
<noscript>
You need to enable JavaScript to run this app.
</noscript>
<noscript>
You need to enable JavaScript to run this app.
</noscript>
```

Then create a file called `public/manifest.json` that looks like this:
Expand Down
2 changes: 1 addition & 1 deletion docusaurus/docs/advanced-configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,4 @@ You can adjust various development and production settings by setting environmen
| INLINE_RUNTIME_CHUNK | 🚫 Ignored | ✅ Used | By default, Create React App will embed the runtime script into `index.html` during the production build. When set to `false`, the script will not be embedded and will be imported as usual. This is normally required when dealing with CSP. |
| IMAGE_INLINE_SIZE_LIMIT | 🚫 Ignored | ✅ Used | By default, images smaller than 10,000 bytes are encoded as a data URI in base64 and inlined in the CSS or JS build artifact. Set this to control the size limit in bytes. Setting it to 0 will disable the inlining of images. |
| EXTEND_ESLINT | ✅ Used | ✅ Used | When set to `true`, ESLint configs that extend `eslint-config-react-app` will be used by `eslint-loader`. Any rules that are set to `"error"` will stop the application from building. |
| TSC_COMPILE_ON_ERROR | ✅ Used | ✅ Used | When set to `true`, you can run and properly build TypeScript projects even if there are TypeScript type check errors. These errors are printed as warnings in the terminal and/or browser console. |
| TSC_COMPILE_ON_ERROR | ✅ Used | ✅ Used | When set to `true`, you can run and properly build TypeScript projects even if there are TypeScript type check errors. These errors are printed as warnings in the terminal and/or browser console. |
7 changes: 1 addition & 6 deletions docusaurus/docs/debugging-tests.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,7 @@ Use the following [`launch.json`](https://code.visualstudio.com/docs/editor/debu
"type": "node",
"request": "launch",
"runtimeExecutable": "${workspaceRoot}/node_modules/.bin/react-scripts",
"args": [
"test",
"--runInBand",
"--no-cache",
"--watchAll=false"
],
"args": ["test", "--runInBand", "--no-cache", "--watchAll=false"],
"cwd": "${workspaceRoot}",
"protocol": "inspector",
"console": "integratedTerminal",
Expand Down
2 changes: 1 addition & 1 deletion docusaurus/docs/using-the-public-folder.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ If you put a file into the `public` folder, it will **not** be processed by Webp
Inside `index.html`, you can use it like this:

```html
<link rel="icon" href="%PUBLIC_URL%/favicon.ico">
<link rel="icon" href="%PUBLIC_URL%/favicon.ico" />
```

Only files inside the `public` folder will be accessible by `%PUBLIC_URL%` prefix. If you need to use a file from `src` or `node_modules`, you’ll have to copy it there to explicitly specify your intention to make this file a part of the build.
Expand Down
8 changes: 6 additions & 2 deletions packages/create-react-app/createReactApp.js
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,9 @@ function createApp(
if (npmInfo.npmVersion) {
console.log(
chalk.yellow(
`You are using npm ${npmInfo.npmVersion} so the project will be bootstrapped with an old unsupported version of tools.\n\n` +
`You are using npm ${
npmInfo.npmVersion
} so the project will be bootstrapped with an old unsupported version of tools.\n\n` +
`Please update to npm 5 or higher for a better, fully supported experience.\n`
)
);
Expand All @@ -262,7 +264,9 @@ function createApp(
if (yarnInfo.yarnVersion) {
console.log(
chalk.yellow(
`You are using Yarn ${yarnInfo.yarnVersion} together with the --use-pnp flag, but Plug'n'Play is only supported starting from the 1.12 release.\n\n` +
`You are using Yarn ${
yarnInfo.yarnVersion
} together with the --use-pnp flag, but Plug'n'Play is only supported starting from the 1.12 release.\n\n` +
`Please update to Yarn 1.12 or higher for a better, fully supported experience.\n`
)
);
Expand Down
2 changes: 1 addition & 1 deletion packages/react-error-overlay/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
"eslint-plugin-import": "2.18.2",
"eslint-plugin-jsx-a11y": "6.2.3",
"eslint-plugin-react": "7.14.3",
"flow-bin": "^0.63.1",
"flow-bin": "^0.110.0",
"html-entities": "1.2.1",
"jest": "24.9.0",
"jest-fetch-mock": "2.1.2",
Expand Down
21 changes: 13 additions & 8 deletions packages/react-error-overlay/src/components/CloseButton.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,27 +6,32 @@
*/

/* @flow */
import React from 'react';
import { black } from '../styles';
import React, { useContext } from 'react';
import { ThemeContext } from '../iframeScript';
import type { Theme } from '../styles';

const closeButtonStyle = {
color: black,
const closeButtonStyle = (theme: Theme) => ({
color: theme.closeColor,
lineHeight: '1rem',
fontSize: '1.5rem',
padding: '1rem',
cursor: 'pointer',
position: 'absolute',
right: 0,
top: 0,
};
});

type CloseCallback = () => void;
function CloseButton({ close }: {| close: CloseCallback |}) {
type CloseButtonPropsType = {|
close: () => void,
|};

function CloseButton({ close }: CloseButtonPropsType) {
const theme = useContext(ThemeContext);
return (
<span
title="Click or press Escape to dismiss."
onClick={close}
style={closeButtonStyle}
style={closeButtonStyle(theme)}
>
×
</span>
Expand Down
31 changes: 16 additions & 15 deletions packages/react-error-overlay/src/components/CodeBlock.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
*/

/* @flow */
import React from 'react';
import { redTransparent, yellowTransparent } from '../styles';
import React, { useContext } from 'react';
import { ThemeContext } from '../iframeScript';

const _preStyle = {
position: 'relative',
Expand All @@ -20,16 +20,6 @@ const _preStyle = {
borderRadius: '0.25rem',
};

const primaryPreStyle = {
..._preStyle,
backgroundColor: redTransparent,
};

const secondaryPreStyle = {
..._preStyle,
backgroundColor: yellowTransparent,
};

const codeStyle = {
fontFamily: 'Consolas, Menlo, monospace',
};
Expand All @@ -39,9 +29,20 @@ type CodeBlockPropsType = {|
codeHTML: string,
|};

function CodeBlock(props: CodeBlockPropsType) {
const preStyle = props.main ? primaryPreStyle : secondaryPreStyle;
const codeBlock = { __html: props.codeHTML };
function CodeBlock({ main, codeHTML }: CodeBlockPropsType) {
const theme = useContext(ThemeContext);
const primaryPreStyle = {
..._preStyle,
backgroundColor: theme.primaryPreBackground,
color: theme.primaryPreColor,
};
const secondaryPreStyle = {
..._preStyle,
backgroundColor: theme.secondaryPreBackground,
color: theme.secondaryPreColor,
};
const preStyle = main ? primaryPreStyle : secondaryPreStyle;
const codeBlock = { __html: codeHTML };

return (
<pre style={preStyle}>
Expand Down
83 changes: 39 additions & 44 deletions packages/react-error-overlay/src/components/Collapsible.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,81 +6,76 @@
*/

/* @flow */
import React, { Component } from 'react';
import { black } from '../styles';
import React, { useState, useContext } from 'react';
import { ThemeContext } from '../iframeScript';

import type { Element as ReactElement } from 'react';
import type { Theme } from '../styles';

const _collapsibleStyle = {
color: black,
cursor: 'pointer',
border: 'none',
display: 'block',
width: '100%',
textAlign: 'left',
background: '#fff',
fontFamily: 'Consolas, Menlo, monospace',
fontSize: '1em',
padding: '0px',
lineHeight: '1.5',
};

const collapsibleCollapsedStyle = {
const collapsibleCollapsedStyle = (theme: Theme) => ({
..._collapsibleStyle,
color: theme.color,
background: theme.background,
marginBottom: '1.5em',
};
});

const collapsibleExpandedStyle = {
const collapsibleExpandedStyle = (theme: Theme) => ({
..._collapsibleStyle,
color: theme.color,
background: theme.background,
marginBottom: '0.6em',
};
});

type Props = {|
type CollapsiblePropsType = {|
children: ReactElement<any>[],
|};

type State = {|
collapsed: boolean,
|};

class Collapsible extends Component<Props, State> {
state = {
collapsed: true,
};
function Collapsible(props: CollapsiblePropsType) {
const theme = useContext(ThemeContext);
const [collapsed, setCollapsed] = useState(true);

toggleCollapsed = () => {
this.setState(state => ({
collapsed: !state.collapsed,
}));
const toggleCollapsed = () => {
setCollapsed(!collapsed);
};

render() {
const count = this.props.children.length;
const collapsed = this.state.collapsed;
return (
<div>
const count = props.children.length;
return (
<div>
<button
onClick={toggleCollapsed}
style={
collapsed
? collapsibleCollapsedStyle(theme)
: collapsibleExpandedStyle(theme)
}
>
{(collapsed ? '▶' : '▼') +
` ${count} stack frames were ` +
(collapsed ? 'collapsed.' : 'expanded.')}
</button>
<div style={{ display: collapsed ? 'none' : 'block' }}>
{props.children}
<button
onClick={this.toggleCollapsed}
style={
collapsed ? collapsibleCollapsedStyle : collapsibleExpandedStyle
}
onClick={toggleCollapsed}
style={collapsibleExpandedStyle(theme)}
>
{(collapsed ? '▶' : '▼') +
` ${count} stack frames were ` +
(collapsed ? 'collapsed.' : 'expanded.')}
{`▲ ${count} stack frames were expanded.`}
</button>
<div style={{ display: collapsed ? 'none' : 'block' }}>
{this.props.children}
<button
onClick={this.toggleCollapsed}
style={collapsibleExpandedStyle}
>
{`▲ ${count} stack frames were expanded.`}
</button>
</div>
</div>
);
}
</div>
);
}

export default Collapsible;
Loading