Skip to content

Commit

Permalink
[dashboard] Change default theme from 'system' to 'light'
Browse files Browse the repository at this point in the history
  • Loading branch information
jankeromnes authored and MatthewFagan committed Aug 9, 2021
1 parent 2d71622 commit a74ef89
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion components/dashboard/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ function App() {

useEffect(() => {
const updateTheme = () => {
const isDark = localStorage.theme === 'dark' || (!('theme' in localStorage) && window.matchMedia("(prefers-color-scheme: dark)").matches);
const isDark = localStorage.theme === 'dark' || (localStorage.theme === 'system' && window.matchMedia("(prefers-color-scheme: dark)").matches);
document.documentElement.classList.toggle('dark', isDark);
}
updateTheme();
Expand Down
10 changes: 5 additions & 5 deletions components/dashboard/src/settings/Preferences.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import vscode from '../images/vscode.svg';
import { PageWithSubMenu } from "../components/PageWithSubMenu";
import settingsMenu from "./settings-menu";

type Theme = 'system' | 'dark' | 'light';
type Theme = 'light' | 'dark' | 'system';

export default function Preferences() {
const { user } = useContext(UserContext);
Expand All @@ -30,20 +30,20 @@ export default function Preferences() {
await getGitpodService().server.updateLoggedInUser({ additionalData });
setDefaultIde(value);
}
const [ theme, setTheme ] = useState<Theme>(localStorage.theme || 'system');
const [ theme, setTheme ] = useState<Theme>(localStorage.theme || 'light');
const actuallySetTheme = (theme: Theme) => {
if (theme === 'light' || theme === 'dark') {
if (theme === 'dark' || theme === 'system') {
localStorage.theme = theme;
} else {
localStorage.removeItem('theme');
}
const isDark = localStorage.theme === 'dark' || (!('theme' in localStorage) && window.matchMedia('(prefers-color-scheme: dark)').matches);
const isDark = localStorage.theme === 'dark' || (localStorage.theme === 'system' && window.matchMedia('(prefers-color-scheme: dark)').matches);
document.documentElement.classList.toggle('dark', isDark);
setTheme(theme);
}

return <div>
<PageWithSubMenu subMenu={settingsMenu} title='Preferences' subtitle='Configure user preferences.'>
<PageWithSubMenu subMenu={settingsMenu} title='Preferences' subtitle='Configure user preferences.'>
<h3>Default IDE</h3>
<p className="text-base text-gray-500">Choose which IDE you want to use.</p>
<div className="mt-4 space-x-4 flex">
Expand Down

0 comments on commit a74ef89

Please sign in to comment.