Skip to content

Commit

Permalink
Hide dark mode behind feature flag
Browse files Browse the repository at this point in the history
  • Loading branch information
taneliang committed Sep 2, 2020
1 parent 5aa5eda commit f8498d1
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 11 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @flow
*/

export const enableDarkMode = false;
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

import * as React from 'react';
import {useContext} from 'react';
import {enableDarkMode} from '../SchedulingProfilerFeatureFlags';
import {SettingsContext} from './SettingsContext';

import styles from './SettingsShared.css';
Expand All @@ -20,17 +21,19 @@ export default function GeneralSettings(_: {||}) {

return (
<div className={styles.Settings}>
<div className={styles.Setting}>
<div className={styles.RadioLabel}>Theme</div>
<select
className={styles.Select}
value={theme}
onChange={({currentTarget}) => setTheme(currentTarget.value)}>
<option value="auto">Auto</option>
<option value="light">Light</option>
<option value="dark">Dark</option>
</select>
</div>
{enableDarkMode && (
<div className={styles.Setting}>
<div className={styles.RadioLabel}>Theme</div>
<select
className={styles.Select}
value={theme}
onChange={({currentTarget}) => setTheme(currentTarget.value)}>
<option value="auto">Auto</option>
<option value="light">Light</option>
<option value="dark">Dark</option>
</select>
</div>
)}

<div className={styles.Setting}>
<div className={styles.RadioLabel}>Display density</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

import * as React from 'react';
import {createContext, useLayoutEffect, useMemo} from 'react';
import {enableDarkMode} from '../SchedulingProfilerFeatureFlags';
import {COMFORTABLE_LINE_HEIGHT, COMPACT_LINE_HEIGHT} from '../constants';
import {useLocalStorage} from '../hooks';

Expand Down Expand Up @@ -69,6 +70,11 @@ function SettingsContextController({browserTheme, children}: Props) {
}, [displayDensity, documentElements]);

useLayoutEffect(() => {
if (!enableDarkMode) {
updateThemeVariables('light', documentElements);
return;
}

switch (theme) {
case 'light':
updateThemeVariables('light', documentElements);
Expand Down

0 comments on commit f8498d1

Please sign in to comment.