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

WebUI: Dark Colorscheme #588

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
8c17d73
Add button to toggle between light- and dark-mode
GlancingMind Feb 23, 2021
c834c03
Use brower preference and persist theme mode
GlancingMind Feb 25, 2021
30587cc
Fix color of open/close filter buttons in dark mode
GlancingMind Feb 26, 2021
b996779
Fix backgroundcolor of toolbar for dark mode
GlancingMind Feb 26, 2021
7beffb8
Fix searchbar background-color for dark mode
GlancingMind Feb 26, 2021
9280e43
Fix Bug description header for dark mode
GlancingMind Feb 26, 2021
9cac036
Inject theme instead of defining it in Themer.tsx
GlancingMind Mar 1, 2021
680ede3
Fix (hopefully) eslint error on node 14.x pipeline
GlancingMind Mar 1, 2021
548febc
Define each theme in own file under themes dir
GlancingMind Mar 2, 2021
9f6dcc8
Use proper semantic color values
GlancingMind Mar 2, 2021
c8a5330
Fix padding around issue comments
GlancingMind Mar 3, 2021
b918c9f
Revert restructuring between App.tsx and index.tsx
GlancingMind Mar 3, 2021
c24b737
Add Icon to "Close Issue"-button
GlancingMind Mar 3, 2021
8e8ca99
Use colors from theme palette
GlancingMind Mar 3, 2021
50484fb
Fix spacing between cancle and save button
GlancingMind Mar 3, 2021
e040fc8
Implement title inputfield as custom component
GlancingMind Mar 3, 2021
288448b
Reuse BugTitleInput component
GlancingMind Mar 4, 2021
41c3e6e
Use Green color from Light theme
GlancingMind Mar 4, 2021
79422fa
Use info.contrastText instead of text.secondary
GlancingMind Mar 4, 2021
72eb505
Rename "bug" to "issue"
GlancingMind Mar 4, 2021
56d50e9
Revert rename
GlancingMind Mar 5, 2021
188ee05
Ignore system prefered colorscheme mode
GlancingMind Mar 6, 2021
c2c5c40
Change color of ModeIcon
GlancingMind Mar 6, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
38 changes: 10 additions & 28 deletions webui/src/components/BugTitleForm/BugTitleForm.tsx
Original file line number Diff line number Diff line change
@@ -1,19 +1,14 @@
import React, { useState } from 'react';

import {
Button,
fade,
makeStyles,
TextField,
Typography,
} from '@material-ui/core';
import { Button, makeStyles, Typography } from '@material-ui/core';

import { TimelineDocument } from '../../pages/bug/TimelineQuery.generated';
import IfLoggedIn from '../IfLoggedIn/IfLoggedIn';
import Author from 'src/components/Author';
import Date from 'src/components/Date';
import { BugFragment } from 'src/pages/bug/Bug.generated';

import BugTitleInput from './BugTitleInput';
import { useSetTitleMutation } from './SetTitle.generated';

/**
Expand Down Expand Up @@ -45,26 +40,12 @@ const useStyles = makeStyles((theme) => ({
marginLeft: theme.spacing(2),
},
greenButton: {
marginLeft: '8px',
backgroundColor: '#2ea44fd9',
color: '#fff',
'&:hover': {
backgroundColor: '#2ea44f',
},
marginLeft: theme.spacing(1),
backgroundColor: theme.palette.success.main,
color: theme.palette.success.contrastText,
},
titleInput: {
borderRadius: theme.shape.borderRadius,
borderColor: fade(theme.palette.primary.main, 0.2),
borderStyle: 'solid',
borderWidth: '1px',
backgroundColor: fade(theme.palette.primary.main, 0.05),
padding: theme.spacing(0, 0),
minWidth: 336,
transition: theme.transitions.create([
'width',
'borderColor',
'backgroundColor',
]),
saveButton: {
marginRight: theme.spacing(1),
},
}));

Expand Down Expand Up @@ -122,11 +103,11 @@ function BugTitleForm({ bug }: Props) {
function editableBugTitle() {
return (
<form className={classes.headerTitle} onSubmit={submitNewTitle}>
<TextField
<BugTitleInput
inputRef={(node) => {
issueTitleInput = node;
}}
className={classes.titleInput}
label="Title"
variant="outlined"
fullWidth
margin="dense"
Expand All @@ -135,6 +116,7 @@ function BugTitleForm({ bug }: Props) {
/>
<div className={classes.editButtonContainer}>
<Button
className={classes.saveButton}
size="small"
variant="contained"
type="submit"
Expand Down
40 changes: 40 additions & 0 deletions webui/src/components/BugTitleForm/BugTitleInput.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import { createStyles, fade, withStyles, TextField } from '@material-ui/core';
import { Theme } from '@material-ui/core/styles';

const BugTitleInput = withStyles((theme: Theme) =>
createStyles({
root: {
'& .MuiInputLabel-outlined': {
color: theme.palette.text.primary,
},
'& input:valid + fieldset': {
color: theme.palette.text.primary,
borderColor: theme.palette.divider,
borderWidth: 2,
},
'& input:valid:hover + fieldset': {
color: theme.palette.text.primary,
borderColor: fade(theme.palette.divider, 0.3),
borderWidth: 2,
},
'& input:valid:focus + fieldset': {
color: theme.palette.text.primary,
borderColor: theme.palette.divider,
},
'& input:invalid + fieldset': {
borderColor: theme.palette.error.main,
borderWidth: 2,
},
'& input:invalid:hover + fieldset': {
borderColor: theme.palette.error.main,
borderWidth: 2,
},
'& input:invalid:focus + fieldset': {
borderColor: theme.palette.error.main,
borderWidth: 2,
},
},
})
)(TextField);

export default BugTitleInput;
11 changes: 11 additions & 0 deletions webui/src/components/CloseBugButton/CloseBugButton.tsx
Original file line number Diff line number Diff line change
@@ -1,19 +1,29 @@
import React from 'react';

import Button from '@material-ui/core/Button';
import { makeStyles, Theme } from '@material-ui/core/styles';
import ErrorOutlineIcon from '@material-ui/icons/ErrorOutline';

import { BugFragment } from 'src/pages/bug/Bug.generated';
import { TimelineDocument } from 'src/pages/bug/TimelineQuery.generated';

import { useCloseBugMutation } from './CloseBug.generated';

const useStyles = makeStyles((theme: Theme) => ({
closeIssueIcon: {
color: theme.palette.secondary.dark,
paddingTop: '0.1rem',
},
}));

interface Props {
bug: BugFragment;
disabled: boolean;
}

function CloseBugButton({ bug, disabled }: Props) {
const [closeBug, { loading, error }] = useCloseBugMutation();
const classes = useStyles();

function closeBugAction() {
closeBug({
Expand Down Expand Up @@ -45,6 +55,7 @@ function CloseBugButton({ bug, disabled }: Props) {
variant="contained"
onClick={() => closeBugAction()}
disabled={bug.status === 'CLOSED' || disabled}
startIcon={<ErrorOutlineIcon className={classes.closeIssueIcon} />}
>
Close issue
</Button>
Expand Down
7 changes: 7 additions & 0 deletions webui/src/components/Header/Header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import AppBar from '@material-ui/core/AppBar';
import Toolbar from '@material-ui/core/Toolbar';
import { makeStyles } from '@material-ui/core/styles';

import { LightSwitch } from '../../components/Themer';
import CurrentIdentity from '../CurrentIdentity/CurrentIdentity';

const useStyles = makeStyles((theme) => ({
Expand All @@ -21,6 +22,9 @@ const useStyles = makeStyles((theme) => ({
display: 'flex',
alignItems: 'center',
},
lightSwitch: {
padding: '0 20px',
},
logo: {
height: '42px',
marginRight: theme.spacing(2),
Expand All @@ -39,6 +43,9 @@ function Header() {
git-bug
</Link>
<div className={classes.filler}></div>
<div className={classes.lightSwitch}>
<LightSwitch />
</div>
<CurrentIdentity />
</Toolbar>
</AppBar>
Expand Down
65 changes: 65 additions & 0 deletions webui/src/components/Themer.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
import React, { createContext, useContext, useState } from 'react';

import { fade, ThemeProvider } from '@material-ui/core';
import IconButton from '@material-ui/core/IconButton/IconButton';
import Tooltip from '@material-ui/core/Tooltip/Tooltip';
import { Theme } from '@material-ui/core/styles';
import { NightsStayRounded, WbSunnyRounded } from '@material-ui/icons';
import { makeStyles } from '@material-ui/styles';

const ThemeContext = createContext({
toggleMode: () => {},
mode: '',
});

const useStyles = makeStyles((theme: Theme) => ({
iconButton: {
color: fade(theme.palette.primary.contrastText, 0.5),
},
}));

const LightSwitch = () => {
const { mode, toggleMode } = useContext(ThemeContext);
const nextMode = mode === 'light' ? 'dark' : 'light';
const description = `Switch to ${nextMode} theme`;
const classes = useStyles();

return (
<Tooltip title={description}>
<IconButton
onClick={toggleMode}
aria-label={description}
className={classes.iconButton}
>
{mode === 'light' ? <WbSunnyRounded /> : <NightsStayRounded />}
</IconButton>
</Tooltip>
);
};

type Props = {
children: React.ReactNode;
lightTheme: Theme;
darkTheme: Theme;
};
const Themer = ({ children, lightTheme, darkTheme }: Props) => {
const savedMode = localStorage.getItem('themeMode');
const preferedMode = savedMode != null ? savedMode : 'light';
const [mode, setMode] = useState(preferedMode);

const toggleMode = () => {
const preferedMode = mode === 'light' ? 'dark' : 'light';
localStorage.setItem('themeMode', preferedMode);
setMode(preferedMode);
};

const preferedTheme = mode === 'dark' ? darkTheme : lightTheme;

return (
<ThemeContext.Provider value={{ toggleMode: toggleMode, mode: mode }}>
<ThemeProvider theme={preferedTheme}>{children}</ThemeProvider>
</ThemeContext.Provider>
);
};

export { Themer as default, LightSwitch };
9 changes: 4 additions & 5 deletions webui/src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,17 @@ import React from 'react';
import ReactDOM from 'react-dom';
import { BrowserRouter } from 'react-router-dom';

import ThemeProvider from '@material-ui/styles/ThemeProvider';

import App from './App';
import apolloClient from './apollo';
import theme from './theme';
import Themer from './components/Themer';
import { defaultLightTheme, defaultDarkTheme } from './themes/index';

ReactDOM.render(
<ApolloProvider client={apolloClient}>
<BrowserRouter>
<ThemeProvider theme={theme}>
<Themer lightTheme={defaultLightTheme} darkTheme={defaultDarkTheme}>
<App />
</ThemeProvider>
</Themer>
</BrowserRouter>
</ApolloProvider>,
document.getElementById('root')
Expand Down
10 changes: 6 additions & 4 deletions webui/src/pages/bug/Message.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,13 @@ const useStyles = makeStyles((theme) => ({
},
header: {
...theme.typography.body1,
color: '#444',
padding: '0.5rem 1rem',
borderBottom: '1px solid #ddd',
borderBottom: `1px solid ${theme.palette.divider}`,
display: 'flex',
backgroundColor: '#e2f1ff',
borderTopRightRadius: theme.shape.borderRadius,
borderTopLeftRadius: theme.shape.borderRadius,
backgroundColor: theme.palette.info.main,
color: theme.palette.info.contrastText,
},
title: {
flex: 1,
Expand All @@ -47,7 +49,7 @@ const useStyles = makeStyles((theme) => ({
},
body: {
...theme.typography.body2,
padding: '0 1rem',
padding: '0.5rem',
},
}));

Expand Down
4 changes: 2 additions & 2 deletions webui/src/pages/list/Filter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ function stringify(params: Query): string {
const useStyles = makeStyles((theme) => ({
element: {
...theme.typography.body2,
color: '#444',
color: theme.palette.text.secondary,
padding: theme.spacing(0, 1),
fontWeight: 400,
textDecoration: 'none',
Expand All @@ -75,7 +75,7 @@ const useStyles = makeStyles((theme) => ({
},
itemActive: {
fontWeight: 600,
color: '#333',
color: theme.palette.text.primary,
},
icon: {
paddingRight: theme.spacing(0.5),
Expand Down
4 changes: 2 additions & 2 deletions webui/src/pages/list/FilterToolbar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ import { useBugCountQuery } from './FilterToolbar.generated';

const useStyles = makeStyles((theme) => ({
toolbar: {
backgroundColor: theme.palette.grey['100'],
borderColor: theme.palette.grey['300'],
backgroundColor: theme.palette.primary.light,
borderColor: theme.palette.divider,
borderWidth: '1px 0',
borderStyle: 'solid',
margin: theme.spacing(0, -1),
Expand Down