Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[dashboard] Change default theme from 'system' to 'light' #4084

Merged
merged 1 commit into from
Apr 27, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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