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

Update dark mode colors #96

Merged
merged 3 commits into from
Dec 9, 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
27 changes: 19 additions & 8 deletions src/Alert/Alert.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import Typography from "@material-ui/core/Typography";
import CloseIcon from "@material-ui/icons/Close";
import { CloseIcon } from "../icons";
import clsx from "clsx";
import React from "react";
import { IconButton } from "../IconButton";
Expand All @@ -12,16 +12,19 @@ export interface AlertProps extends AlertBaseProps {
close?: boolean;
title?: string;
}
const Icon: React.FC<{ variant: AlertVariant }> = ({ variant }) => {
interface IconProps extends React.SVGProps<SVGSVGElement> {
variant: AlertVariant;
}
const Icon: React.FC<IconProps> = ({ variant, ...props }) => {
switch (variant) {
case "error":
return <NotAllowedIcon />;
return <NotAllowedIcon {...props} />;
case "warning":
return <WarningIcon />;
return <WarningIcon {...props} />;
case "success":
return <CompleteIcon />;
return <CompleteIcon {...props} />;
default:
return <InfoIcon />;
return <InfoIcon {...props} />;
}
};

Expand All @@ -42,8 +45,15 @@ export const Alert: React.FC<AlertProps> = ({
return (
<AlertBase variant={variant} {...rest}>
<div className={classes.container}>
<div>
<Icon variant={variant} />
<div className={classes.icon}>
<Icon
className={clsx({
[classes.error]: variant === "error",
[classes.warning]: variant === "warning",
[classes.success]: variant === "success",
})}
variant={variant}
/>
</div>
<div className={classes.content}>
<div className={classes.titleBar}>
Expand All @@ -53,6 +63,7 @@ export const Alert: React.FC<AlertProps> = ({
className={clsx(classes.close, {
[classes.closeNoContent]: !children,
})}
hoverOutline={false}
variant="secondary"
onClick={() => setVisible(false)}
data-test="close"
Expand Down
16 changes: 15 additions & 1 deletion src/Alert/styles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@ import { makeStyles } from "../theme";
const useStyles = makeStyles(
(theme) => ({
close: {
color: theme.palette.common.black,
"&:hover": {
color: theme.palette.text.primary,
},
color: theme.palette.text.secondary,
position: "absolute",
right: theme.spacing(-2),
top: theme.spacing(-1),
Expand All @@ -21,6 +24,17 @@ const useStyles = makeStyles(
content: {
padding: theme.spacing(0, 1),
},
icon: {
"& $error": {
color: theme.palette.alert.icon.error,
},
"& $warning": {
color: theme.palette.alert.icon.warning,
},
"& $success": {
color: theme.palette.alert.icon.success,
},
},
root: {},
titleBar: {
marginTop: 6,
Expand Down
2 changes: 1 addition & 1 deletion src/IconButton/IconButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export const IconButton: React.FC<IconButtonProps> = React.forwardRef(
<ButtonBase
ref={ref}
className={clsx(classes.secondary, className, {
[classes.hoverOutline]: hoverOutline,
[classes.hoverOutline]: hoverOutline && !props.disabled,
})}
disableRipple
{...props}
Expand Down
29 changes: 14 additions & 15 deletions src/Notification/Notification.tsx
Original file line number Diff line number Diff line change
@@ -1,25 +1,28 @@
import Button from "@material-ui/core/Button";
import SnackbarContent from "@material-ui/core/SnackbarContent";
import Typography from "@material-ui/core/Typography";
import CloseIcon from "@material-ui/icons/Close";
import { CloseIcon } from "../icons";
import clsx from "clsx";
import React from "react";

import { CompleteIcon, InfoIcon, NotAllowedIcon, WarningIcon } from "../icons";
import useStyles from "./styles";
import type { NotificationProps, NotificationType } from "./types";
import { Button } from "../Button";
import { IconButton } from "../IconButton";

const Icon: React.FC<{ type: NotificationType }> = ({ type }) => {
interface IconProps extends React.SVGProps<SVGSVGElement> {
type: NotificationType;
}
const Icon: React.FC<IconProps> = ({ type, ...props }) => {
switch (type) {
case "error":
return <NotAllowedIcon />;
return <NotAllowedIcon {...props} />;
case "warning":
return <WarningIcon />;
return <WarningIcon {...props} />;
case "success":
return <CompleteIcon />;
return <CompleteIcon {...props} />;
default:
return <InfoIcon />;
return <InfoIcon {...props} />;
}
};

Expand Down Expand Up @@ -56,7 +59,7 @@ export const Notification: React.FC<NotificationProps> = ({
message={
<div className={classes.container}>
<div>
<Icon type={type} />
<Icon className={classes.icon} type={type} />
</div>
<div>
<div className={classes.title}>
Expand All @@ -72,8 +75,7 @@ export const Notification: React.FC<NotificationProps> = ({
<Button
className={classes.actionBtn}
key="action"
color="default"
size="small"
variant="tertiary"
onClick={action.onClick}
data-test="button-action"
>
Expand All @@ -82,14 +84,11 @@ export const Notification: React.FC<NotificationProps> = ({
)}
</div>,
<IconButton
key="close"
aria-label="Close"
color="inherit"
onClick={onClose}
hoverOutline={false}
variant="secondary"
className={clsx(classes.closeBtn, {
[classes.closeBtnInfo]: type === "info",
})}
className={classes.closeBtn}
data-test="close"
>
<CloseIcon />
Expand Down
17 changes: 14 additions & 3 deletions src/Notification/styles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,24 +10,29 @@ const useStyles = makeStyles(
minWidth: "unset",
},
closeBtn: {
"&:hover": {
color: theme.palette.text.primary,
},
"& svg": {
maxHeight: 20,
maxWidth: 20,
},
color: theme.palette.text.secondary,
padding: 10,
position: "absolute",
right: 5,
top: 7,
},
closeBtnInfo: {
color: theme.palette.text.primary,
},
error: {
"& $icon": {
color: theme.palette.alert.icon.error,
},
backgroundColor: theme.palette.alert.paper.error,
},
hiddenText: {
maxHeight: 0,
},
icon: {},
info: {},
snackbar: {
borderRadius: 4,
Expand All @@ -43,13 +48,19 @@ const useStyles = makeStyles(
paddingLeft: `calc(${iconWidth}px + ${theme.spacing(2)})`,
},
success: {
"& $icon": {
color: theme.palette.alert.icon.success,
},
backgroundColor: theme.palette.alert.paper.success,
},
text: {
fontWeight: 400,
paddingTop: 5,
},
warning: {
"& $icon": {
color: theme.palette.alert.icon.warning,
},
backgroundColor: theme.palette.alert.paper.warning,
},

Expand Down
4 changes: 3 additions & 1 deletion src/Pagination/styles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,9 @@ const useStyles = makeStyles(
backgroundColor: fade(theme.palette.primary.main, 0.2),
},
},
color: theme.palette.primary.main,
"&:not($actionsButtonDisabled)": {
color: theme.palette.primary.main,
},
},
root: {},
toolbar: {
Expand Down
6 changes: 4 additions & 2 deletions src/Sidebar/Sidebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@ import clsx from "clsx";
import React from "react";

import { Logo } from "../icons/Logo";
import { LogoDark } from "../icons/LogoDark";
import { localStorageKeys } from "../localStorageKeys";
import { makeStyles } from "../theme";
import { makeStyles, useTheme } from "../theme";
import useLocalStorage from "../tools/useLocalStorage";
import { ExpandButton } from "./ExpandButton";
import { MenuItem, menuWidth, shrunkMenuWidth } from "./MenuItem";
Expand Down Expand Up @@ -56,6 +57,7 @@ export const Sidebar: React.FC<SidebarProps> = ({
false.toString()
);
const isShrunk = isShrunkStr === "true";
const { themeType } = useTheme();

return (
<div
Expand All @@ -65,7 +67,7 @@ export const Sidebar: React.FC<SidebarProps> = ({
>
<div className={classes.float}>
<div className={classes.logo}>
<Logo />
{themeType === "dark" ? <LogoDark /> : <Logo />}
</div>
{menuItems.map((menuItem) => (
<MenuItem
Expand Down
5 changes: 4 additions & 1 deletion src/SidebarDrawer/SidebarDrawer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@ import MenuIcon from "@material-ui/icons/Menu";
import clsx from "clsx";
import React from "react";
import SVG from "react-inlinesvg";
import { useTheme } from "..";

import { Logo } from "../icons/Logo";
import { LogoDark } from "../icons/LogoDark";
import { BaseSidebarProps, SidebarMenuItem } from "../Sidebar/types";
import { SquareButton } from "../SquareButton";
import { MenuItemBtn } from "./MenuItemBtn";
Expand All @@ -25,6 +27,7 @@ export const SidebarDrawer: React.FC<SideBarDrawerProps> = ({
);
const [showSubmenu, setShowSubmenu] = React.useState(false);
const container = React.useRef<HTMLDivElement>(null);
const { themeType } = useTheme();

const handleMenuItemClick = (url: string) => {
setOpened(false);
Expand Down Expand Up @@ -65,7 +68,7 @@ export const SidebarDrawer: React.FC<SideBarDrawerProps> = ({
>
<div className={classes.content}>
<div className={classes.logo}>
<Logo />
{themeType === "dark" ? <LogoDark /> : <Logo />}
</div>
{menuItems.map((menuItem) => (
<MenuItemBtn
Expand Down
4 changes: 2 additions & 2 deletions src/icons/CompleteIcon.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@ export const CompleteIcon: React.FC<React.SVGProps<SVGSVGElement>> = (
{...props}
>
<circle cx="20" cy="20" r="20" fill="var(--background-paper)" />
<circle cx="20" cy="20" r="14" stroke="#5DC292" strokeWidth="4" />
<circle cx="20" cy="20" r="14" stroke="currentColor" strokeWidth="4" />
<path
fillRule="evenodd"
clipRule="evenodd"
d="M28.7678 13.7678C29.3536 14.3536 29.3536 15.3033 28.7678 15.8891L17.4142 27.2426L12.0607 21.8891C11.4749 21.3033 11.4749 20.3536 12.0607 19.7678L12.7678 19.0607C13.3536 18.4749 14.3033 18.4749 14.8891 19.0607L17.4142 21.5858L25.9393 13.0607C26.5251 12.4749 27.4749 12.4749 28.0607 13.0607L28.7678 13.7678Z"
fill="#5DC292"
fill="currentColor"
/>
</svg>
);
Expand Down
26 changes: 26 additions & 0 deletions src/icons/LogoDark.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import React from "react";

export const LogoDark: React.FC = () => (
<svg
width="36"
height="33"
viewBox="0 0 36 33"
fill="none"
xmlns="http://www.w3.org/2000/svg"
>
<path
fill-rule="evenodd"
clip-rule="evenodd"
d="M19.7838 0L13.4043 6.64709H29.1638L35.5433 0H19.7838Z"
fill="#E6F0FF"
/>
<path
fill-rule="evenodd"
clip-rule="evenodd"
d="M6.59759 2.13062C6.4332 2.13062 6.27552 2.1958 6.15911 2.31187L0.182532 8.27133C0.00456112 8.44879 -0.0488948 8.71603 0.0471181 8.94829C0.143131 9.18056 0.369679 9.33205 0.621008 9.33205H21.3482C21.5126 9.33205 21.6703 9.26687 21.7867 9.1508L27.7632 3.19134C27.9412 3.01388 27.9947 2.74664 27.8987 2.51437C27.8026 2.28211 27.5761 2.13062 27.3248 2.13062H6.59759ZM2.12325 8.09007L6.85429 3.37259H25.8225L21.0915 8.09007H2.12325ZM23.9789 27.3629C23.9789 30.6214 22.4977 33 16.6072 33C11.4908 33 9.43754 31.599 9 28.1124L13.6451 27.4281C13.9144 29.1551 14.5539 29.5135 16.6745 29.5135C18.5933 29.5135 19.2328 29.0573 19.2328 28.0146C19.2328 26.7437 18.492 26.418 16.5735 26.0594C16.4207 26.0337 16.2653 26.0082 16.1079 25.9823C13.0752 25.4835 9.30464 24.8634 9.33654 20.6504C9.33654 17.2293 11.2216 15.0787 16.5735 15.0787C21.4542 15.0787 23.3055 16.7404 23.7097 20.0314L18.9298 20.7482C18.7614 19.2168 18.2566 18.6954 16.4389 18.6954C14.9577 18.6954 14.0489 19.0867 14.0489 20.1292C14.0489 21.5304 15.0924 21.7258 17.3814 22.1167C20.3772 22.6056 23.9789 23.3549 23.9789 27.3629Z"
fill="#FAFAFA"
/>
</svg>
);

LogoDark.displayName = "LogoDark";
4 changes: 2 additions & 2 deletions src/icons/NotAllowedIcon.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@ export const NotAllowedIcon: React.FC<React.SVGProps<SVGSVGElement>> = (
xmlns="http://www.w3.org/2000/svg"
{...props}
>
<circle cx="20" cy="20" r="16" fill="#F5FAFB" />
<circle cx="20" cy="20" r="16" fill="var(--background-paper)" />
<circle cx="20" cy="20" r="20" fill="var(--background-paper)" />
<path
fillRule="evenodd"
clipRule="evenodd"
d="M26.9531 29.7815C24.9914 31.1784 22.5917 32 20 32C13.3726 32 8 26.6274 8 20C8 17.4083 8.82158 15.0086 10.2185 13.0469L26.9531 29.7815ZM29.7815 26.9531L13.0469 10.2185C15.0086 8.82158 17.4083 8 20 8C26.6274 8 32 13.3726 32 20C32 22.5917 31.1784 24.9914 29.7815 26.9531ZM36 20C36 28.8366 28.8366 36 20 36C11.1634 36 4 28.8366 4 20C4 11.1634 11.1634 4 20 4C28.8366 4 36 11.1634 36 20Z"
fill="#FE6E76"
fill="currentColor"
/>
</svg>
);
Expand Down
2 changes: 1 addition & 1 deletion src/icons/RadioCheckedIcon.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import React from "react";
export const RadioCheckedIcon = createSvgIcon(
<>
<circle cx="12" cy="12" r="12" fill="currentColor" />
<circle cx="12" cy="12" r="5" fill="var(--background-default)" />
<circle cx="12" cy="12" r="5" fill="var(--background-paper)" />
</>,
"RadioCheckedIcon"
);
4 changes: 2 additions & 2 deletions src/icons/WarningIcon.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ export const WarningIcon: React.FC<React.SVGProps<SVGSVGElement>> = (props) => (
{...props}
>
<circle cx="20" cy="20" r="20" fill="var(--background-paper)" />
<circle cx="20" cy="20" r="14" stroke="#FFB84E" strokeWidth="4" />
<circle cx="20" cy="20" r="14" stroke="currentColor" strokeWidth="4" />
<path
fillRule="evenodd"
clipRule="evenodd"
d="M19.5 11C18.6716 11 18 11.6716 18 12.5V20.5C18 21.3284 18.6716 22 19.5 22H20.5C21.3284 22 22 21.3284 22 20.5V12.5C22 11.6716 21.3284 11 20.5 11H19.5ZM19.5 25C18.6716 25 18 25.6716 18 26.5V27.5C18 28.3284 18.6716 29 19.5 29H20.5C21.3284 29 22 28.3284 22 27.5V26.5C22 25.6716 21.3284 25 20.5 25H19.5Z"
fill="#FFB84E"
fill="currentColor"
/>
</svg>
);
Expand Down
Loading