Skip to content

Saleor Core: the high performance, composable, headless commerce API.

Dark theme improvements

dominik-zeglen8145d2d5808d
diff --git a/saleor/static/dashboard-next/components/AppLayout/AppLayout.tsx b/saleor/static/dashboard-next/components/AppLayout/AppLayout.tsx
index 3015a5e5eb..be788d0668 100644
--- a/saleor/static/dashboard-next/components/AppLayout/AppLayout.tsx
+++ b/saleor/static/dashboard-next/components/AppLayout/AppLayout.tsx
@@ -12,6 +12,7 @@ import {
withStyles,
WithStyles
} from "@material-ui/core/styles";
+import Switch from "@material-ui/core/Switch";
import * as classNames from "classnames";
import * as React from "react";
import SVG from "react-inlinesvg";
@@ -61,6 +62,9 @@ const styles = (theme: Theme) =>
flexDirection: "column",
minHeight: `calc(100vh - ${appLoaderHeight}px)`
},
+ darkThemeSwitch: {
+ marginRight: theme.spacing.unit * 2
+ },
header: {
display: "flex",
height: 40,
@@ -103,6 +107,10 @@ const styles = (theme: Theme) =>
spacer: {
flex: 1
},
+ userBar: {
+ alignItems: "center",
+ display: "flex"
+ },
userChip: {
backgroundColor: theme.palette.common.white,
border: `1px solid ${theme.palette.grey[200]}`
@@ -140,7 +148,7 @@ const AppLayout = withStyles(styles, {
}: AppLayoutProps &
WithStyles<typeof styles> &
RouteComponentProps<any>) => {
- const { variant: themeVariant } = useTheme();
+ const { isDark, toggleTheme } = useTheme();
return (
<AppProgress>
{({ value: isProgressVisible }) => (
@@ -188,7 +196,7 @@ const AppLayout = withStyles(styles, {
<SVG
className={classes.logo}
src={
- themeVariant === "dark"
+ isDark
? saleorDarkLogo
: saleorLightLogo
}
@@ -213,110 +221,126 @@ const AppLayout = withStyles(styles, {
<div
className={classes.spacer}
/>
- <Anchor>
- {anchor => (
- <Toggle>
- {(
- menuOpen,
- {
- disable: closeMenu,
- enable: openMenu
- }
- ) => {
- const handleLogout = () => {
- close();
- logout();
- };
- return (
- <div
- className={
- classes.userMenuContainer
- }
- ref={anchor}
- >
- <Chip
- className={
- classes.userChip
- }
- label={
- <>
- {user.email}
- <ArrowDropdown
- className={classNames(
- classes.arrow,
- {
- [classes.rotate]: menuOpen
- }
- )}
- />
- </>
- }
- onClick={
- openMenu
- }
- />
- <Popper
+ <div
+ className={classes.userBar}
+ >
+ <Switch
+ color="primary"
+ className={
+ classes.darkThemeSwitch
+ }
+ checked={isDark}
+ onClick={toggleTheme}
+ />
+ <Anchor>
+ {anchor => (
+ <Toggle>
+ {(
+ menuOpen,
+ {
+ disable: closeMenu,
+ enable: openMenu
+ }
+ ) => {
+ const handleLogout = () => {
+ close();
+ logout();
+ };
+ return (
+ <div
className={
- classes.popover
+ classes.userMenuContainer
}
- open={menuOpen}
- anchorEl={
- anchor.current
- }
- transition
- disablePortal
- placement="bottom-end"
+ ref={anchor}
>
- {({
- TransitionProps,
- placement
- }) => (
- <Grow
- {...TransitionProps}
- style={{
- transformOrigin:
- placement ===
- "bottom"
- ? "right top"
- : "right bottom"
- }}
- >
- <Paper>
- <ClickAwayListener
- onClickAway={
- closeMenu
- }
- mouseEvent="onClick"
- >
- <Menu>
- <MenuItem
- className={
- classes.userMenuItem
- }
- onClick={
- handleLogout
- }
- >
- {i18n.t(
- "Log out",
- {
- context:
- "button"
+ <Chip
+ className={
+ classes.userChip
+ }
+ label={
+ <>
+ {
+ user.email
+ }
+ <ArrowDropdown
+ className={classNames(
+ classes.arrow,
+ {
+ [classes.rotate]: menuOpen
+ }
+ )}
+ />
+ </>
+ }
+ onClick={
+ openMenu
+ }
+ />
+ <Popper
+ className={
+ classes.popover
+ }
+ open={
+ menuOpen
+ }
+ anchorEl={
+ anchor.current
+ }
+ transition
+ disablePortal
+ placement="bottom-end"
+ >
+ {({
+ TransitionProps,
+ placement
+ }) => (
+ <Grow
+ {...TransitionProps}
+ style={{
+ transformOrigin:
+ placement ===
+ "bottom"
+ ? "right top"
+ : "right bottom"
+ }}
+ >
+ <Paper>
+ <ClickAwayListener
+ onClickAway={
+ closeMenu
+ }
+ mouseEvent="onClick"
+ >
+ <Menu>
+ <MenuItem
+ className={
+ classes.userMenuItem
+ }
+ onClick={
+ handleLogout
}
- )}
- </MenuItem>
- </Menu>
- </ClickAwayListener>
- </Paper>
- </Grow>
- )}
- </Popper>
- </div>
- );
- }}
- </Toggle>
- )}
- </Anchor>
+ >
+ {i18n.t(
+ "Log out",
+ {
+ context:
+ "button"
+ }
+ )}
+ </MenuItem>
+ </Menu>
+ </ClickAwayListener>
+ </Paper>
+ </Grow>
+ )}
+ </Popper>
+ </div>
+ );
+ }}
+ </Toggle>
+ )}
+ </Anchor>
+ </div>
</div>
</Container>
</div>
diff --git a/saleor/static/dashboard-next/components/AppLayout/MenuList.tsx b/saleor/static/dashboard-next/components/AppLayout/MenuList.tsx
index b612a13381..4868ca006a 100644
--- a/saleor/static/dashboard-next/components/AppLayout/MenuList.tsx
+++ b/saleor/static/dashboard-next/components/AppLayout/MenuList.tsx
@@ -45,7 +45,7 @@ const styles = (theme: Theme) =>
height: "100%",
left: -32,
position: "absolute",
- width: 4
+ width: 5
},
position: "relative"
},
@@ -55,6 +55,7 @@ const styles = (theme: Theme) =>
},
cursor: "pointer",
fontSize: "1rem",
+ fontWeight: 500,
textTransform: "uppercase",
transition: theme.transitions.duration.standard + "ms"
},
diff --git a/saleor/static/dashboard-next/components/CardTitle/CardTitle.tsx b/saleor/static/dashboard-next/components/CardTitle/CardTitle.tsx
index 70495ea55f..c00a0f6f88 100644
--- a/saleor/static/dashboard-next/components/CardTitle/CardTitle.tsx
+++ b/saleor/static/dashboard-next/components/CardTitle/CardTitle.tsx
@@ -16,7 +16,7 @@ const styles = (theme: Theme) =>
},
hr: {
border: "none",
- borderTop: "1px solid #eaeaea",
+ borderTop: `1px solid ${theme.overrides.MuiCard.root.borderColor}`,
height: 0,
marginBottom: 0,
marginTop: 0,
diff --git a/saleor/static/dashboard-next/components/Hr.tsx b/saleor/static/dashboard-next/components/Hr.tsx
index 50d57c12c4..64ed3d3f4a 100644
--- a/saleor/static/dashboard-next/components/Hr.tsx
+++ b/saleor/static/dashboard-next/components/Hr.tsx
@@ -1,16 +1,22 @@
-import { createStyles, withStyles, WithStyles } from "@material-ui/core/styles";
+import {
+ createStyles,
+ Theme,
+ withStyles,
+ WithStyles
+} from "@material-ui/core/styles";
import * as React from "react";
-const styles = createStyles({
- root: {
- backgroundColor: "#eeeeee",
- border: "none",
- display: "block",
- height: 1,
- margin: 0,
- width: "100%"
- }
-});
+const styles = (theme: Theme) =>
+ createStyles({
+ root: {
+ backgroundColor: theme.overrides.MuiCard.root.borderColor,
+ border: "none",
+ display: "block",
+ height: 1,
+ margin: 0,
+ width: "100%"
+ }
+ });
export const Hr = withStyles(styles, { name: "Hr" })(
({ classes }: WithStyles<typeof styles>) => <hr className={classes.root} />
diff --git a/saleor/static/dashboard-next/components/RichTextEditor/RichTextEditor.tsx b/saleor/static/dashboard-next/components/RichTextEditor/RichTextEditor.tsx
index 240bd15b71..81f43e4d26 100644
--- a/saleor/static/dashboard-next/components/RichTextEditor/RichTextEditor.tsx
+++ b/saleor/static/dashboard-next/components/RichTextEditor/RichTextEditor.tsx
@@ -83,7 +83,9 @@ const styles = (theme: Theme) =>
"&:after": {
animationDuration: theme.transitions.duration.shortest + "ms",
animationFillMode: "both",
- background: theme.palette.grey[700],
+ background: theme.palette.getContrastText(
+ theme.palette.background.default
+ ),
bottom: -1,
content: "''",
display: "block",
@@ -148,7 +150,10 @@ const styles = (theme: Theme) =>
alignItems: "center",
background: "none",
border: "none",
- borderRight: `1px ${theme.palette.grey[300]} solid`,
+ borderRight: `1px ${
+ theme.overrides.MuiCard.root.borderColor
+ } solid`,
+ color: theme.typography.body1.color,
cursor: "pointer",
display: "inline-flex",
height: 36,
@@ -167,13 +172,14 @@ const styles = (theme: Theme) =>
},
display: "flex"
},
- border: `1px ${theme.palette.grey[300]} solid`,
+ background: theme.palette.background.default,
+ border: `1px ${theme.overrides.MuiCard.root.borderColor} solid`,
display: "inline-flex",
marginBottom: theme.spacing.unit
},
"&-block": {
"&--blockquote": {
- borderLeft: `2px solid ${theme.palette.grey[300]}`,
+ borderLeft: `2px solid ${theme.overrides.MuiCard.root.borderColor}`,
margin: 0,
padding: `${theme.spacing.unit}px ${theme.spacing.unit * 2}px`
}
diff --git a/saleor/static/dashboard-next/components/SaveButtonBar/SaveButtonBar.tsx b/saleor/static/dashboard-next/components/SaveButtonBar/SaveButtonBar.tsx
index 2d827730ed..f58f7ebebd 100644
--- a/saleor/static/dashboard-next/components/SaveButtonBar/SaveButtonBar.tsx
+++ b/saleor/static/dashboard-next/components/SaveButtonBar/SaveButtonBar.tsx
@@ -44,7 +44,7 @@ const styles = (theme: Theme) =>
root: {
background: theme.palette.background.default,
borderTop: "1px solid transparent",
- boxShadow: `0px -5px 5px 0px ${theme.palette.grey[200]}`,
+ boxShadow: `0 -5px 5px 0 ${theme.overrides.MuiCard.root.borderColor}`,
transition: theme.transitions.duration.standard + "ms"
},
spacer: {
@@ -52,8 +52,8 @@ const styles = (theme: Theme) =>
},
stop: {
"&$root": {
- borderTopColor: theme.palette.grey[200],
- boxShadow: `0px 0px 4px 0px ${theme.palette.grey[200]}`
+ borderTopColor: theme.overrides.MuiCard.root.borderColor,
+ boxShadow: `0 0 0 0 ${theme.overrides.MuiCard.root.borderColor}`
}
}
});
diff --git a/saleor/static/dashboard-next/components/Skeleton.tsx b/saleor/static/dashboard-next/components/Skeleton.tsx
index 959930449e..ef5d8b7ecd 100644
--- a/saleor/static/dashboard-next/components/Skeleton.tsx
+++ b/saleor/static/dashboard-next/components/Skeleton.tsx
@@ -1,25 +1,31 @@
-import { createStyles, withStyles, WithStyles } from "@material-ui/core/styles";
+import {
+ createStyles,
+ Theme,
+ withStyles,
+ WithStyles
+} from "@material-ui/core/styles";
import classNames from "classnames";
import * as React from "react";
-const styles = createStyles({
- "@keyframes skeleton-animation": {
- "0%": {
- opacity: 0.6
+const styles = (theme: Theme) =>
+ createStyles({
+ "@keyframes skeleton-animation": {
+ "0%": {
+ opacity: 0.6
+ },
+ "100%": {
+ opacity: 1
+ }
},
- "100%": {
- opacity: 1
+ skeleton: {
+ animation: "skeleton-animation .75s linear infinite forwards alternate",
+ background: theme.palette.background.default,
+ borderRadius: 4,
+ display: "block",
+ height: "0.8em",
+ margin: "0.2em 0"
}
- },
- skeleton: {
- animation: "skeleton-animation .75s linear infinite forwards alternate",
- background: "#eee",
- borderRadius: 4,
- display: "block",
- height: "0.8em",
- margin: "0.2em 0"
- }
-});
+ });
interface SkeletonProps extends WithStyles<typeof styles> {
className?: string;
diff --git a/saleor/static/dashboard-next/components/Tab/TabContainer.tsx b/saleor/static/dashboard-next/components/Tab/TabContainer.tsx
index 31cf6bfdc4..b266e8929e 100644
--- a/saleor/static/dashboard-next/components/Tab/TabContainer.tsx
+++ b/saleor/static/dashboard-next/components/Tab/TabContainer.tsx
@@ -1,15 +1,21 @@
-import { createStyles, withStyles, WithStyles } from "@material-ui/core/styles";
+import {
+ createStyles,
+ Theme,
+ withStyles,
+ WithStyles
+} from "@material-ui/core/styles";
import * as React from "react";
export interface TabContainerProps {
children: React.ReactNode | React.ReactNodeArray;
}
-const styles = createStyles({
- root: {
- borderBottom: "1px solid #eeeeee"
- }
-});
+const styles = (theme: Theme) =>
+ createStyles({
+ root: {
+ borderBottom: `1px solid ${theme.overrides.MuiCard.root.borderColor}`
+ }
+ });
const TabContainer = withStyles(styles, {
name: "TabContainer"
diff --git a/saleor/static/dashboard-next/components/TableCellAvatar/TableCellAvatar.tsx b/saleor/static/dashboard-next/components/TableCellAvatar/TableCellAvatar.tsx
index 661bc4a321..815c0b1659 100644
--- a/saleor/static/dashboard-next/components/TableCellAvatar/TableCellAvatar.tsx
+++ b/saleor/static/dashboard-next/components/TableCellAvatar/TableCellAvatar.tsx
@@ -16,7 +16,7 @@ const styles = (theme: Theme) =>
createStyles({
avatar: {
background: "none",
- border: "1px solid #eaeaea",
+ border: `1px solid ${theme.overrides.MuiCard.root.borderColor}`,
borderRadius: 2,
color: "#bdbdbd",
padding: theme.spacing.unit / 2
diff --git a/saleor/static/dashboard-next/components/TableFilter/FilterTab.tsx b/saleor/static/dashboard-next/components/TableFilter/FilterTab.tsx
index 194bc597c9..8b28d72d0b 100644
--- a/saleor/static/dashboard-next/components/TableFilter/FilterTab.tsx
+++ b/saleor/static/dashboard-next/components/TableFilter/FilterTab.tsx
@@ -10,7 +10,7 @@ import * as React from "react";
const styles = (theme: Theme) =>
createStyles({
tabLabel: {
- color: "#616161",
+ color: theme.typography.caption.color,
fontSize: "0.875rem"
},
tabRoot: {
diff --git a/saleor/static/dashboard-next/components/TableFilter/FilterTabs.tsx b/saleor/static/dashboard-next/components/TableFilter/FilterTabs.tsx
index 6d24723ee8..380f6ca8fb 100644
--- a/saleor/static/dashboard-next/components/TableFilter/FilterTabs.tsx
+++ b/saleor/static/dashboard-next/components/TableFilter/FilterTabs.tsx
@@ -10,7 +10,7 @@ import * as React from "react";
const styles = (theme: Theme) =>
createStyles({
tabsRoot: {
- borderBottom: "1px solid #e0e0e0",
+ borderBottom: `1px solid ${theme.overrides.MuiCard.root.borderColor}`,
paddingLeft: `${theme.spacing.unit * 3}px`
}
});
diff --git a/saleor/static/dashboard-next/components/Theme/ThemeProvider.tsx b/saleor/static/dashboard-next/components/Theme/ThemeProvider.tsx
index 44bb5a6c46..c6dc8e3b35 100644
--- a/saleor/static/dashboard-next/components/Theme/ThemeProvider.tsx
+++ b/saleor/static/dashboard-next/components/Theme/ThemeProvider.tsx
@@ -1,11 +1,9 @@
-import { Theme } from "@material-ui/core/styles";
import MuiThemeProvider from "@material-ui/core/styles/MuiThemeProvider";
import * as React from "react";
+import Baseline from "../../Baseline";
import createTheme, { IThemeColors } from "../../theme";
-export type ThemeVariant = "dark" | "light";
-
// TODO: fix secondary buttons lol
const dark: IThemeColors = {
background: {
@@ -37,39 +35,35 @@ const light: IThemeColors = {
};
interface IThemeContext {
- theme: Theme;
- variant: ThemeVariant;
- setTheme: (variant: ThemeVariant) => void;
+ isDark: boolean;
+ toggleTheme: () => void;
}
export const ThemeContext = React.createContext<IThemeContext>(undefined);
interface ThemeProviderProps {
- variant?: ThemeVariant;
+ isDefaultDark?: boolean;
}
-const ThemeProvider: React.FC<ThemeProviderProps> = ({ children, variant }) => {
- const defaultTheme = createTheme(variant === "dark" ? dark : light);
- const [themeInfo, setTheme] = React.useState({
- muiTheme: defaultTheme,
- variant
- });
+const ThemeProvider: React.FC<ThemeProviderProps> = ({
+ children,
+ isDefaultDark
+}) => {
+ const [isDark, setDark] = React.useState(isDefaultDark);
return (
<ThemeContext.Provider
value={{
- setTheme: variant =>
- setTheme({
- muiTheme: createTheme(variant === "dark" ? dark : light),
- variant
- }),
- theme: themeInfo.muiTheme,
- variant
+ isDark,
+ toggleTheme: () => setDark(!isDark)
}}
>
- <MuiThemeProvider theme={themeInfo.muiTheme}>{children}</MuiThemeProvider>
+ <MuiThemeProvider theme={createTheme(isDark ? dark : light)}>
+ <Baseline />
+ {children}
+ </MuiThemeProvider>
</ThemeContext.Provider>
);
};
ThemeProvider.defaultProps = {
- variant: "dark"
+ isDefaultDark: false
};
export default ThemeProvider;
diff --git a/saleor/static/dashboard-next/index.tsx b/saleor/static/dashboard-next/index.tsx
index 66393f8efb..2b2553096e 100644
--- a/saleor/static/dashboard-next/index.tsx
+++ b/saleor/static/dashboard-next/index.tsx
@@ -17,7 +17,6 @@ import LoginLoading from "./auth/components/LoginLoading/LoginLoading";
import SectionRoute from "./auth/components/SectionRoute";
import { hasPermission } from "./auth/misc";
import Login from "./auth/views/Login";
-import Baseline from "./Baseline";
import CategorySection from "./categories";
import CollectionSection from "./collections";
import { AppProgressProvider } from "./components/AppProgress";
@@ -33,7 +32,6 @@ import ConfigurationSection, { configurationMenu } from "./configuration";
import { CustomerSection } from "./customers";
import DiscountSection from "./discounts";
import HomePage from "./home";
-import useTheme from "./hooks/useTheme";
import i18n from "./i18n";
import { NotFound } from "./NotFound";
import OrdersSection from "./orders";
@@ -117,7 +115,6 @@ const App: React.FC = () => (
<WindowTitle title={i18n.t("Dashboard")} />
{/* FIXME: #3424 */}
{/* <ConfirmFormLeaveDialog /> */}
- <Baseline />
<AuthProvider>
{({
hasToken,
diff --git a/saleor/static/dashboard-next/products/components/ProductOrganization/ProductOrganization.tsx b/saleor/static/dashboard-next/products/components/ProductOrganization/ProductOrganization.tsx
index ee2f34dafa..33b2643371 100644
--- a/saleor/static/dashboard-next/products/components/ProductOrganization/ProductOrganization.tsx
+++ b/saleor/static/dashboard-next/products/components/ProductOrganization/ProductOrganization.tsx
@@ -40,7 +40,7 @@ const styles = (theme: Theme) =>
margin: `${theme.spacing.unit * 3}px 0`
},
hr: {
- backgroundColor: "#eaeaea",
+ backgroundColor: theme.overrides.MuiCard.root.borderColor,
border: "none",
height: 1,
margin: `0 -${theme.spacing.unit * 3}px ${theme.spacing.unit * 3}px`
diff --git a/saleor/static/dashboard-next/storybook/Decorator.tsx b/saleor/static/dashboard-next/storybook/Decorator.tsx
index c68294d4be..beb127ca68 100644
--- a/saleor/static/dashboard-next/storybook/Decorator.tsx
+++ b/saleor/static/dashboard-next/storybook/Decorator.tsx
@@ -1,19 +1,16 @@
-import CssBaseline from "@material-ui/core/CssBaseline";
-import MuiThemeProvider from "@material-ui/core/styles/MuiThemeProvider";
import * as React from "react";
import { Provider as DateProvider } from "../components/Date/DateContext";
import { FormProvider } from "../components/Form";
import { MessageManager } from "../components/messages";
+import ThemeProvider from "../components/Theme";
import { TimezoneProvider } from "../components/Timezone";
-import theme from "../theme";
export const Decorator = storyFn => (
<FormProvider>
<DateProvider value={+new Date("2018-08-07T14:30:44+00:00")}>
<TimezoneProvider value="America/New_York">
- <MuiThemeProvider theme={theme}>
- <CssBaseline />
+ <ThemeProvider isDefaultDark={false}>
<MessageManager>
<div
style={{
@@ -23,7 +20,7 @@ export const Decorator = storyFn => (
{storyFn()}
</div>
</MessageManager>
- </MuiThemeProvider>
+ </ThemeProvider>
</TimezoneProvider>
</DateProvider>
</FormProvider>
diff --git a/saleor/static/dashboard-next/theme.ts b/saleor/static/dashboard-next/theme.ts
index 695edd1eed..372e214bc3 100644
--- a/saleor/static/dashboard-next/theme.ts
+++ b/saleor/static/dashboard-next/theme.ts
@@ -1,4 +1,5 @@
import { createMuiTheme, Theme } from "@material-ui/core/styles";
+import { fade } from "@material-ui/core/styles/colorManipulator";
const createShadow = (pv, pb, ps, uv, ub, us, av, ab, as) =>
[
@@ -34,7 +35,7 @@ export default (colors: IThemeColors): Theme =>
},
MuiCard: {
root: {
- border: `1px solid ${colors.paperBorder}`,
+ borderColor: colors.paperBorder,
borderRadius: 8,
boxShadow: "none"
}
@@ -124,6 +125,7 @@ export default (colors: IThemeColors): Theme =>
paddingLeft: 24 + "px",
textAlign: "left" as "left"
},
+ borderBottomColor: colors.paperBorder,
padding: "4px 24px 4px 0"
}
},
@@ -140,7 +142,7 @@ export default (colors: IThemeColors): Theme =>
},
hover: {
"$root&:hover": {
- backgroundColor: "rgba(90, 179, 120, .1)"
+ backgroundColor: fade(colors.primary, 0.2)
}
}
}