Files
react/packages/react-devtools-shared/src/devtools/views/Settings/DebuggingSettings.js
T
Ruslan LesiutinandGitHub 6738544fb7 refactor[devtools]: update css for settings and support css variables in shadow dom scnenario (#33487)
## Summary

Minor changes around css and styling of Settings dialog.

1. `:root` selector was updated to `:is(:root, :host)` to make css
variables available on Shadow Root
2. CSS tweaks around Settings dialog: removed references to deleted
styles, removed unused styles, ironed out styling for cases when input
styles are enhanced by user agent stylesheet

<!--
Explain the **motivation** for making this change. What existing problem
does the pull request solve?
-->

## How did you test this change?

| Before | After |
|--------|--------|
| ![Screenshot 2025-06-09 at 15 35
55](https://github.com/user-attachments/assets/1ac5d002-744b-4b10-9501-d4f2a7c827d2)
| ![Screenshot 2025-06-09 at 15 26
12](https://github.com/user-attachments/assets/8cc07cda-99a5-4930-973b-b139b193e349)
|
| ![Screenshot 2025-06-09 at 15 36
02](https://github.com/user-attachments/assets/1af4257c-928d-4ec6-a614-801cc1936f4b)
| ![Screenshot 2025-06-09 at 15 26
25](https://github.com/user-attachments/assets/7a3a0f7c-5f3d-4567-a782-dd37368a15ae)
|
| ![Screenshot 2025-06-09 at 15 36
05](https://github.com/user-attachments/assets/a1e00381-2901-4e22-b1c6-4a3f66ba78c9)
| ![Screenshot 2025-06-09 at 15 26
30](https://github.com/user-attachments/assets/bdefce68-cbb5-4b88-b44c-a74f28533f7d)
|
| ![Screenshot 2025-06-09 at 15 36
12](https://github.com/user-attachments/assets/4eda6234-0ef0-40ca-ad9d-5990a2b1e8b4)
| ![Screenshot 2025-06-09 at 15 26
37](https://github.com/user-attachments/assets/5cac305e-fd29-460c-b0b8-30e477b8c26e)
|
2025-06-09 18:25:19 +01:00

126 lines
3.7 KiB
JavaScript

/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @flow
*/
import * as React from 'react';
import {use, useState, useEffect} from 'react';
import type {DevToolsHookSettings} from 'react-devtools-shared/src/backend/types';
import type Store from 'react-devtools-shared/src/devtools/store';
import styles from './SettingsShared.css';
type Props = {
hookSettings: Promise<$ReadOnly<DevToolsHookSettings>>,
store: Store,
};
export default function DebuggingSettings({
hookSettings,
store,
}: Props): React.Node {
const usedHookSettings = use(hookSettings);
const [appendComponentStack, setAppendComponentStack] = useState(
usedHookSettings.appendComponentStack,
);
const [breakOnConsoleErrors, setBreakOnConsoleErrors] = useState(
usedHookSettings.breakOnConsoleErrors,
);
const [hideConsoleLogsInStrictMode, setHideConsoleLogsInStrictMode] =
useState(usedHookSettings.hideConsoleLogsInStrictMode);
const [showInlineWarningsAndErrors, setShowInlineWarningsAndErrors] =
useState(usedHookSettings.showInlineWarningsAndErrors);
useEffect(() => {
store.setShouldShowWarningsAndErrors(showInlineWarningsAndErrors);
}, [showInlineWarningsAndErrors]);
useEffect(() => {
store.updateHookSettings({
appendComponentStack,
breakOnConsoleErrors,
showInlineWarningsAndErrors,
hideConsoleLogsInStrictMode,
});
}, [
store,
appendComponentStack,
breakOnConsoleErrors,
showInlineWarningsAndErrors,
hideConsoleLogsInStrictMode,
]);
return (
<div className={styles.SettingList}>
<div className={styles.SettingWrapper}>
<label className={styles.SettingRow}>
<input
type="checkbox"
checked={appendComponentStack}
onChange={({currentTarget}) =>
setAppendComponentStack(currentTarget.checked)
}
className={styles.SettingRowCheckbox}
/>
Append component stacks to console warnings and errors
</label>
</div>
<div className={styles.SettingWrapper}>
<label className={styles.SettingRow}>
<input
type="checkbox"
checked={showInlineWarningsAndErrors}
onChange={({currentTarget}) =>
setShowInlineWarningsAndErrors(currentTarget.checked)
}
className={styles.SettingRowCheckbox}
/>
Show inline warnings and errors
</label>
</div>
<div className={styles.SettingWrapper}>
<label className={styles.SettingRow}>
<input
type="checkbox"
checked={breakOnConsoleErrors}
onChange={({currentTarget}) =>
setBreakOnConsoleErrors(currentTarget.checked)
}
className={styles.SettingRowCheckbox}
/>
Break on warnings
</label>
</div>
<div className={styles.SettingWrapper}>
<label className={styles.SettingRow}>
<input
type="checkbox"
checked={hideConsoleLogsInStrictMode}
onChange={({currentTarget}) =>
setHideConsoleLogsInStrictMode(currentTarget.checked)
}
className={styles.SettingRowCheckbox}
/>
Hide logs during additional invocations in&nbsp;
<a
className={styles.StrictModeLink}
target="_blank"
rel="noopener noreferrer"
href="https://react.dev/reference/react/StrictMode">
Strict Mode
</a>
</label>
</div>
</div>
);
}