feat: add dark mode

This commit is contained in:
thecodrr
2019-12-11 00:07:32 +05:00
parent e9c3067acb
commit 3802acb377
11 changed files with 118 additions and 75 deletions

View File

@@ -20,7 +20,7 @@ const NavMenuItem = props => {
width: "full", width: "full",
borderRadius: "none", borderRadius: "none",
textAlign: "center", textAlign: "center",
color: props.selected ? "accent" : "fontPrimary" color: props.selected ? "primary" : "text"
}} }}
px={0} px={0}
> >
@@ -38,7 +38,12 @@ function App() {
const [selectedIndex, setSelectedIndex] = useState(1); const [selectedIndex, setSelectedIndex] = useState(1);
return ( return (
<ThemeProvider theme={theme}> <ThemeProvider theme={theme}>
<Flex height="100%" alignContent="stretch"> <Flex
bg="background"
sx={{ color: "text" }}
height="100%"
alignContent="stretch"
>
<Box <Box
width={[0, 0, 70]} width={[0, 0, 70]}
sx={{ borderRight: "1px solid", borderRightColor: "border" }} sx={{ borderRight: "1px solid", borderRightColor: "border" }}
@@ -59,7 +64,6 @@ function App() {
<Flex flex="1 1 auto" flexDirection="row" alignContent="stretch" px={0}> <Flex flex="1 1 auto" flexDirection="row" alignContent="stretch" px={0}>
<Flex <Flex
className="navigationView" className="navigationView"
bg="primary"
sx={{ borderRight: "1px solid", borderColor: "border" }} sx={{ borderRight: "1px solid", borderColor: "border" }}
flexDirection="column" flexDirection="column"
flex="1 1 auto" flex="1 1 auto"

View File

@@ -4,7 +4,7 @@ import { ButtonPressedStyle } from "../../theme";
const Button = props => ( const Button = props => (
<Flex <Flex
bg="accent" bg="primary"
width={props.width || "full"} width={props.width || "full"}
py={3} py={3}
px={3} px={3}
@@ -16,7 +16,7 @@ const Button = props => (
color: "fontSecondary", color: "fontSecondary",
fontFamily: "body", fontFamily: "body",
fontWeight: "body", fontWeight: "body",
boxShadow: "0 0 20px 0px #1790F3aa", boxShadow: 1,
...ButtonPressedStyle, ...ButtonPressedStyle,
...props.style ...props.style
}} }}

View File

@@ -43,7 +43,7 @@ const ListItem = props => (
display={props.info ? "flex" : "none"} display={props.info ? "flex" : "none"}
variant="body" variant="body"
fontSize={12} fontSize={12}
color="accent" color="primary"
> >
{props.info} {props.info}
</Text> </Text>
@@ -59,7 +59,7 @@ const ListItem = props => (
style={{ marginRight: -5 }} style={{ marginRight: -5 }}
/> />
</DropdownTrigger> </DropdownTrigger>
<DropdownContent style={{ zIndex: 999, marginLeft: -70 }}> <DropdownContent style={{ zIndex: 999, marginLeft: -85 }}>
<Menu <Menu
dropdownRef={props.dropdownRefs[props.index]} dropdownRef={props.dropdownRefs[props.index]}
menuItems={props.menuItems} menuItems={props.menuItems}

View File

@@ -4,11 +4,7 @@ import { SHADOW } from "../../theme";
function Menu(props) { function Menu(props) {
return ( return (
<Flex <Flex bg="background" py={1} sx={{ borderRadius: "default", boxShadow: 2 }}>
bg="primary"
py={1}
sx={{ borderRadius: "default", boxShadow: SHADOW }}
>
<Box> <Box>
{props.menuItems.map(item => ( {props.menuItems.map(item => (
<Flex <Flex
@@ -29,7 +25,7 @@ function Menu(props) {
sx={{ sx={{
color: item.color || "fontPrimary", color: item.color || "fontPrimary",
":hover": { ":hover": {
backgroundColor: "accent", backgroundColor: "primary",
color: "fontSecondary" color: "fontSecondary"
} }
}} }}

View File

@@ -29,7 +29,7 @@ const Notebook = ({ item, index, onClick, onTopicClick }) => {
e.stopPropagation(); e.stopPropagation();
}} }}
key={topic.dateCreated + topic.title} key={topic.dateCreated + topic.title}
bg="accent" bg="primary"
px={1} px={1}
py={1} py={1}
sx={{ sx={{
@@ -48,7 +48,7 @@ const Notebook = ({ item, index, onClick, onTopicClick }) => {
info={ info={
<Text> <Text>
{new Date(notebook.dateCreated).toDateString().substring(4)} {new Date(notebook.dateCreated).toDateString().substring(4)}
<Text as="span" color="fontPrimary"> <Text as="span" color="text">
{" • " + notebook.totalNotes} Notes {" • " + notebook.totalNotes} Notes
</Text> </Text>
</Text> </Text>

View File

@@ -40,7 +40,7 @@ const Snackbar = props => (
}} }}
alignItems="center" alignItems="center"
flexDirection="row" flexDirection="row"
bg="accent" bg="primary"
py={2} py={2}
px={2} px={2}
> >

View File

@@ -22,7 +22,7 @@ const Topic = ({ item, index, onClick }) => {
title={topic.title} title={topic.title}
info={ info={
<Text> <Text>
<Text as="span" color="fontPrimary"> <Text as="span" color="text">
{topic.totalNotes} Notes {topic.totalNotes} Notes
</Text> </Text>
</Text> </Text>

View File

@@ -6,6 +6,13 @@ body,
height: 100%; height: 100%;
overflow: hidden; overflow: hidden;
} }
body {
font-family: Quicksand, sans-serif;
font-weight: 500;
font-size: 14px;
}
@keyframes fadeUp { @keyframes fadeUp {
0% { 0% {
transform: translateY(500px); transform: translateY(500px);

View File

@@ -1,23 +1,42 @@
export const SHADOW = "0 0 8px 0px #aaaaaa44";
export const DIALOG_SHADOW = "0 0 20px 0px #aaaaaa77";
export const ButtonPressedStyle = { export const ButtonPressedStyle = {
":active": { ":active": {
opacity: "0.8" opacity: "0.8"
} }
}; };
const colorsLight = makeTheme({
background: "white",
accent: "white",
navbg: "#f0f0f0",
border: "#f0f0f0",
hover: "#e0e0e0",
fontSecondary: "white",
text: "black",
overlay: "rgba(255, 255, 255, 0.75)"
});
const colorsDark = makeTheme({
background: "#1f1f1f",
accent: "#000",
navbg: "#2b2b2b",
border: "#2b2b2b",
hover: "#3b3b3b",
fontSecondary: "#000",
text: "#fff",
overlay: "rgba(0, 0, 0, 0.75)"
});
const shadowsDark = {
1: "0 0 0px 0px #00000000",
2: "0 0 8px 0px #55555544",
3: "0 0 20px 0px #55555599"
};
const shadowsLight = {
1: "0 0 20px 0px #1790F3aa",
2: "0 0 8px 0px #aaaaaa44",
3: "0 0 20px 0px #aaaaaa77"
};
export default { export default {
breakpoints: ["480px", "834px", "1200px"], breakpoints: ["480px", "834px", "1200px"],
colors: { colors: colorsLight,
primary: "white",
accent: "#1790F3",
navbg: "#f0f0f0",
transparent: "#00000000",
//font related
fontPrimary: "black",
fontSecondary: "white",
border: "#f0f0f0",
hover: "#e0e0e0"
},
space: [0, 5, 10, 12], space: [0, 5, 10, 12],
fontSizes: { fontSizes: {
heading: 36, heading: 36,
@@ -47,7 +66,6 @@ export default {
default: { default: {
borderWidth: 0, borderWidth: 0,
borderRadius: "default", borderRadius: "default",
bg: "primary",
border: "2px solid", border: "2px solid",
borderColor: "border", borderColor: "border",
fontFamily: "body", fontFamily: "body",
@@ -55,27 +73,17 @@ export default {
fontSizes: "input", fontSizes: "input",
":focus": { ":focus": {
outline: "none", outline: "none",
borderColor: "accent" borderColor: "primary"
}, },
":hover": { ":hover": {
borderColor: "hover" borderColor: "hover"
} }
}, },
search: { search: {
borderWidth: 0, variant: "forms.default",
borderRadius: "default",
bg: "primary",
border: "2px solid",
borderColor: "border",
fontFamily: "body",
fontWeight: "body",
fontSizes: "input",
":focus": { ":focus": {
outline: "none", outline: "none",
boxShadow: SHADOW boxShadow: 2
},
":hover": {
borderColor: "hover"
} }
} }
}, },
@@ -83,7 +91,8 @@ export default {
heading: { heading: {
fontFamily: "body", fontFamily: "body",
fontWeight: "heading", fontWeight: "heading",
fontSize: "heading" fontSize: "heading",
color: "text"
}, },
title: { title: {
fontFamily: "body", fontFamily: "body",
@@ -97,18 +106,9 @@ export default {
} }
}, },
buttons: { buttons: {
nav: {
color: "fontPrimary",
bg: "transparent",
fontFamily: "body",
fontWeight: "body",
":focus": {
outline: "none"
}
},
primary: { primary: {
color: "fontSecondary", color: "fontSecondary",
bg: "accent", bg: "primary",
borderRadius: "default", borderRadius: "default",
fontFamily: "body", fontFamily: "body",
fontWeight: "body", fontWeight: "body",
@@ -118,31 +118,56 @@ export default {
...ButtonPressedStyle ...ButtonPressedStyle
}, },
secondary: { secondary: {
color: "fontPrimary", variant: "buttons.primary",
color: "text",
bg: "navbg", bg: "navbg",
borderRadius: "default",
fontFamily: "body",
fontWeight: "body",
":focus": {
outline: "none"
},
...ButtonPressedStyle ...ButtonPressedStyle
}, },
tertiary: { tertiary: {
color: "fontPrimary", variant: "buttons.primary",
color: "text",
bg: "transparent", bg: "transparent",
borderRadius: "default",
border: "2px solid", border: "2px solid",
borderColor: "border", borderColor: "border",
":active": {
color: "primary",
opacity: 0.8
}
},
nav: {
bg: "transparent",
fontFamily: "body", fontFamily: "body",
fontWeight: "body", fontWeight: "body",
":focus": { ":focus": {
outline: "none" outline: "none"
},
":active": {
color: "accent",
opacity: 0.8
} }
} }
} },
shadows: shadowsLight
}; };
function makeTheme({
background,
accent,
navbg,
border,
hover,
fontSecondary,
text,
overlay
}) {
return {
background,
primary: "#1790F3",
//secondary: "",
accent,
//custom
navbg,
border,
hover,
fontSecondary,
transparent: "#00000000",
text,
overlay
};
}

View File

@@ -1,6 +1,6 @@
import React, { useState, useEffect } from "react"; import React, { useState, useEffect } from "react";
import { Flex, Box, Text, Button as RebassButton } from "rebass"; import { Flex, Box, Text, Button as RebassButton } from "rebass";
import { Input } from "@rebass/forms"; import { Input, Checkbox, Label } from "@rebass/forms";
import Button from "../components/button"; import Button from "../components/button";
import * as Icon from "react-feather"; import * as Icon from "react-feather";
import theme, { DIALOG_SHADOW } from "../theme"; import theme, { DIALOG_SHADOW } from "../theme";
@@ -46,7 +46,7 @@ const Notebooks = props => {
{notebooks.length > 0 ? ( {notebooks.length > 0 ? (
<Flex flexDirection="column" flex="1 1 auto"> <Flex flexDirection="column" flex="1 1 auto">
{selected.type === "topic" && ( {selected.type === "topic" && (
<Text variant="title" color="accent"> <Text variant="title" color="primary">
{selected.title} {selected.title}
</Text> </Text>
)} )}
@@ -155,11 +155,16 @@ const CreateNotebookDialog = props => {
transform: "translate(-50%, -50%)", transform: "translate(-50%, -50%)",
borderWidth: 0, borderWidth: 0,
borderRadius: theme.radii["default"], borderRadius: theme.radii["default"],
boxShadow: DIALOG_SHADOW, backgroundColor: theme.colors.background,
color: theme.colors.text,
boxShadow: theme.shadows["3"],
width: "20%", width: "20%",
paddingRight: 40, paddingRight: 40,
paddingLeft: 40, paddingLeft: 40,
overflowY: "hidden" overflowY: "hidden"
},
overlay: {
background: theme.colors.overlay
} }
}} }}
contentLabel="Add a Notebook" contentLabel="Add a Notebook"
@@ -170,10 +175,12 @@ const CreateNotebookDialog = props => {
alignItems="center" alignItems="center"
alignSelf="center" alignSelf="center"
justifyContent="center" justifyContent="center"
color="accent" color="primary"
py={2} py={2}
> >
<Icon.BookOpen size={42} /> <Box height={42}>
<Icon.BookOpen size={42} />
</Box>
<Text <Text
mx={2} mx={2}
as="span" as="span"
@@ -196,6 +203,10 @@ const CreateNotebookDialog = props => {
onChange={e => (CreateNotebookDialog.description = e.target.value)} onChange={e => (CreateNotebookDialog.description = e.target.value)}
placeholder="Enter description (optional)" placeholder="Enter description (optional)"
/> />
<Label>
<Checkbox variant="checkbox" />
Locked?
</Label>
<Text variant="body" fontWeight="bold" my={1}> <Text variant="body" fontWeight="bold" my={1}>
Topics (optional): Topics (optional):
</Text> </Text>

View File

@@ -6996,7 +6996,7 @@ normalize-url@^3.0.0, normalize-url@^3.0.1:
"notes-core@https://github.com/thecodrr/notes-core.git": "notes-core@https://github.com/thecodrr/notes-core.git":
version "0.2.0" version "0.2.0"
resolved "https://github.com/thecodrr/notes-core.git#281414d69b6bdc73b70e5347745ce8b797b55991" resolved "https://github.com/thecodrr/notes-core.git#82058c8fa60c370644320fea5e1b4bb0c393c4df"
dependencies: dependencies:
fast-filter "^1.0.4" fast-filter "^1.0.4"
fuzzysearch "^1.0.3" fuzzysearch "^1.0.3"