| 1 | /** |
| 2 | * Copyright (c) Meta Platforms, Inc. and affiliates. |
| 3 | * |
| 4 | * This source code is licensed under the MIT license found in the |
| 5 | * LICENSE file in the root directory of this source tree. |
| 6 | * |
| 7 | * @flow |
| 8 | */ |
| 9 | |
| 10 | import * as React from 'react'; |
| 11 | import {LOCAL_STORAGE_ALWAYS_OPEN_IN_EDITOR} from '../../../constants'; |
| 12 | import {useLocalStorage} from '../hooks'; |
| 13 | |
| 14 | import styles from './SettingsShared.css'; |
| 15 | |
| 16 | export default function CodeEditorByDefault({ |
| 17 | onChange, |
| 18 | }: { |
| 19 | onChange?: boolean => void, |
| 20 | }): React.Node { |
| 21 | const [alwaysOpenInEditor, setAlwaysOpenInEditor] = useLocalStorage<boolean>( |
| 22 | LOCAL_STORAGE_ALWAYS_OPEN_IN_EDITOR, |
| 23 | false, |
| 24 | ); |
| 25 | |
| 26 | return ( |
| 27 | <label className={styles.SettingRow}> |
| 28 | <input |
| 29 | type="checkbox" |
| 30 | checked={alwaysOpenInEditor} |
| 31 | onChange={({currentTarget}) => { |
| 32 | setAlwaysOpenInEditor(currentTarget.checked); |
| 33 | if (onChange) { |
| 34 | onChange(currentTarget.checked); |
| 35 | } |
| 36 | }} |
| 37 | className={styles.SettingRowCheckbox} |
| 38 | /> |
| 39 | Open local files directly in your code editor |
| 40 | </label> |
| 41 | ); |
| 42 | } |