Skip to content

Commit 92f5c3a

Browse files
authored
[Devtools] Rename Forget badge (#28858)
## Summary The Forget codename needs to be hidden from the UI to avoid confusion. Going forward, we'll be referring to this set of features as part of the larger React compiler. We'll be describing the primary feature that we've built so far as auto-memoization, and this badge helps devs see which components have been automatically memoized by the compiler. ## How did you test this change? - force Forget badge on with and without the presence of other badges - confirm colors/UI in light and dark modes - force badges on for `ElementBadges`, `InspectableElementBadges`, `IndexableElementBadges` - Running yarn start in packages/react-devtools-shell [demo video](https://github.com/facebook/react/assets/973058/fa829018-7644-4425-8395-c5cd84691f3c)
1 parent 1cd77a4 commit 92f5c3a

File tree

5 files changed

+40
-10
lines changed

5 files changed

+40
-10
lines changed

packages/react-devtools-shared/src/devtools/constants.js

+9-5
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,9 @@ export const THEME_STYLES: {[style: Theme | DisplayDensity]: any, ...} = {
7777
'--color-error-border': 'hsl(0, 100%, 92%)',
7878
'--color-error-text': '#ff0000',
7979
'--color-expand-collapse-toggle': '#777d88',
80-
'--color-forget-badge': '#2683E2',
80+
'--color-forget-badge-background': '#2683e2',
81+
'--color-forget-badge-background-inverted': '#1a6bbc',
82+
'--color-forget-text': '#fff',
8183
'--color-link': '#0000ff',
8284
'--color-modal-background': 'rgba(255, 255, 255, 0.75)',
8385
'--color-bridge-version-npm-background': '#eff0f1',
@@ -195,10 +197,10 @@ export const THEME_STYLES: {[style: Theme | DisplayDensity]: any, ...} = {
195197
'--color-commit-gradient-text': '#000000',
196198
'--color-component-name': '#61dafb',
197199
'--color-component-name-inverted': '#282828',
198-
'--color-component-badge-background': 'rgba(255, 255, 255, 0.25)',
199-
'--color-component-badge-background-inverted': 'rgba(0, 0, 0, 0.25)',
200+
'--color-component-badge-background': '#5e6167',
201+
'--color-component-badge-background-inverted': '#46494e',
200202
'--color-component-badge-count': '#8f949d',
201-
'--color-component-badge-count-inverted': 'rgba(255, 255, 255, 0.7)',
203+
'--color-component-badge-count-inverted': 'rgba(255, 255, 255, 0.85)',
202204
'--color-console-error-badge-text': '#000000',
203205
'--color-console-error-background': '#290000',
204206
'--color-console-error-border': '#5c0000',
@@ -222,7 +224,9 @@ export const THEME_STYLES: {[style: Theme | DisplayDensity]: any, ...} = {
222224
'--color-error-border': '#900',
223225
'--color-error-text': '#f55',
224226
'--color-expand-collapse-toggle': '#8f949d',
225-
'--color-forget-badge': '#2683E2',
227+
'--color-forget-badge-background': '#2683e2',
228+
'--color-forget-badge-background-inverted': '#1a6bbc',
229+
'--color-forget-text': '#fff',
226230
'--color-link': '#61dafb',
227231
'--color-modal-background': 'rgba(0, 0, 0, 0.75)',
228232
'--color-bridge-version-npm-background': 'rgba(0, 0, 0, 0.25)',

packages/react-devtools-shared/src/devtools/views/Components/Badge.css

-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
padding: 0.125rem 0.25rem;
66
line-height: normal;
77
border-radius: 0.125rem;
8-
margin-right: 0.25rem;
98
font-family: var(--font-family-monospace);
109
font-size: var(--font-size-monospace-small);
1110
}

packages/react-devtools-shared/src/devtools/views/Components/Element.css

+1
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
--color-component-badge-background: var(
3333
--color-component-badge-background-inverted
3434
);
35+
--color-forget-badge-background: var(--color-forget-badge-background-inverted);
3536
--color-component-badge-count: var(--color-component-badge-count-inverted);
3637
--color-attribute-name: var(--color-attribute-name-inverted);
3738
--color-attribute-value: var(--color-attribute-value-inverted);
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,21 @@
11
.Root {
2-
background-color: var(--color-forget-badge);
2+
background-color: var(--color-forget-badge-background);
3+
color: var(--color-forget-text);
4+
padding-right: 1.75em;
5+
position: relative;
6+
}
7+
8+
.Root::after {
9+
bottom: 0;
10+
content: '✨';
11+
position: absolute;
12+
right: 0.25em;
13+
}
14+
15+
.ForgetToggle {
16+
display: flex;
17+
}
18+
19+
.ForgetToggle > span { /* targets .ToggleContent */
20+
padding: 0;
321
}

packages/react-devtools-shared/src/devtools/views/Components/ForgetBadge.js

+11-3
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import * as React from 'react';
1111

1212
import Badge from './Badge';
1313
import IndexableDisplayName from './IndexableDisplayName';
14+
import Toggle from '../Toggle';
1415

1516
import styles from './ForgetBadge.css';
1617

@@ -34,10 +35,17 @@ export default function ForgetBadge(props: Props): React.Node {
3435
const {className = ''} = props;
3536

3637
const innerView = props.indexable ? (
37-
<IndexableDisplayName displayName="Forget" id={props.elementID} />
38+
<IndexableDisplayName displayName="Memo" id={props.elementID} />
3839
) : (
39-
'Forget'
40+
'Memo'
4041
);
4142

42-
return <Badge className={`${styles.Root} ${className}`}>{innerView}</Badge>;
43+
const onChange = () => {};
44+
const title =
45+
'✨ This component has been auto-memoized by the React Compiler.';
46+
return (
47+
<Toggle onChange={onChange} className={styles.ForgetToggle} title={title}>
48+
<Badge className={`${styles.Root} ${className}`}>{innerView}</Badge>
49+
</Toggle>
50+
);
4351
}

0 commit comments

Comments
 (0)