feat: redirect login to proper route, navigation with Seek component on year pages

This commit is contained in:
Kyle Gill
2019-03-28 17:10:25 -06:00
parent d716274d5f
commit 8890b82332
8 changed files with 57 additions and 14 deletions

View File

@@ -15,6 +15,9 @@ import Register from "./components/screens/Register";
import { withAuthentication } from "./components/session"; import { withAuthentication } from "./components/session";
const RouteLayout = styled.div` const RouteLayout = styled.div`
display: flex;
flex-direction: column;
height: 100%;
margin: 0 auto; margin: 0 auto;
padding: 0 10px; padding: 0 10px;
max-width: 720px; max-width: 720px;

View File

@@ -6,6 +6,7 @@ import { withTheme } from "emotion-theming";
import { todayUrl, yearUrl } from "../../utils/date"; import { todayUrl, yearUrl } from "../../utils/date";
import Logo from "../Logo";
import Icon from "../Icon"; import Icon from "../Icon";
import { withAuthentication } from "../session"; import { withAuthentication } from "../session";
@@ -29,10 +30,13 @@ const Nav = styled.div`
justify-content: space-between; justify-content: space-between;
align-content: center; align-content: center;
`; `;
const Logo = styled.div``; const LogoSection = styled.div`
width: 40px;
`;
const NavIcons = styled.div` const NavIcons = styled.div`
display: flex; display: flex;
flex-direction: row; flex-direction: row;
align-items: center;
* + * { * + * {
margin-left: 10px; margin-left: 10px;
} }
@@ -41,12 +45,16 @@ const NavIcons = styled.div`
const Navbar = ({ authUser, theme, toggleTheme }) => ( const Navbar = ({ authUser, theme, toggleTheme }) => (
<Header> <Header>
<Nav> <Nav>
<Logo>Logo</Logo> <LogoSection>
<Logo color={theme.colors.logo} />
</LogoSection>
<NavIcons> <NavIcons>
<Link to="#">
<Icon <Icon
onClick={() => toggleTheme()} onClick={() => toggleTheme()}
name={theme.name === "Dark" ? "Sun" : "Moon"} name={theme.name === "Dark" ? "Sun" : "Moon"}
/> />
</Link>
{authUser ? ( {authUser ? (
<React.Fragment> <React.Fragment>
<Link to={yearUrl()}> <Link to={yearUrl()}>

View File

@@ -38,9 +38,7 @@ const Seek = ({ title = "", prev = "", next = "", disableNext, theme }) => (
disabled={disableNext} disabled={disableNext}
name="ChevronRight" name="ChevronRight"
style={{ style={{
color: disableNext color: disableNext ? theme.colors.hover : theme.colors.secondary
? theme.colors.quarternary
: theme.colors.secondary
}} }}
/> />
</Link> </Link>

View File

@@ -1,8 +1,34 @@
import React, { Component } from "react"; import React, { Component } from "react";
import styled from "@emotion/styled";
import { withTheme } from "emotion-theming";
import { addDays, subDays, format, isAfter, startOfYesterday } from "date-fns"; import { addDays, subDays, format, isAfter, startOfYesterday } from "date-fns";
import { SIZES } from "../../../styles/constants";
import Seek from "../../Seek"; import Seek from "../../Seek";
const JournalHeading = styled.h2`
font-weight: 700;
font-size: ${SIZES.tiny};
color: ${props => props.theme.colors.secondary};
margin-top: ${SIZES.medium};
`;
const JournalEntryArea = styled.textarea`
flex-grow: 1;
color: ${props => props.theme.colors.primary};
background-color: transparent;
line-height: 1.5;
letter-spacing: 0.5px;
width: 100%;
border: none;
resize: none;
outline: none;
font-size: ${SIZES.small};
&::placeholder {
color: ${props => props.theme.colors.tertiary};
}
`;
class Day extends Component { class Day extends Component {
render() { render() {
const { const {
@@ -15,16 +41,18 @@ class Day extends Component {
if (!currentDay) return; if (!currentDay) return;
return ( return (
<div> <>
<Seek <Seek
title={format(currentDay, "YYYY MMM DD")} title={format(currentDay, "YYYY MMM DD")}
prev={format(subDays(currentDay, 1), "/YYYY/MM/DD")} prev={format(subDays(currentDay, 1), "/YYYY/MM/DD")}
next={format(addDays(currentDay, 1), "/YYYY/MM/DD")} next={format(addDays(currentDay, 1), "/YYYY/MM/DD")}
disableNext={isAfter(currentDay, startOfYesterday())} disableNext={isAfter(currentDay, startOfYesterday())}
/> />
</div> <JournalHeading>WHAT'S HAPPENED TODAY?</JournalHeading>
<JournalEntryArea placeholder="Start writing..." />
</>
); );
} }
} }
export default Day; export default withTheme(Day);

View File

@@ -1,5 +1,6 @@
import React, { Component } from "react"; import React, { Component } from "react";
import { withRouter, Link } from "react-router-dom"; import { withRouter, Link } from "react-router-dom";
import { format } from "date-fns";
import { FirebaseContext } from "../../firebase"; import { FirebaseContext } from "../../firebase";
@@ -30,7 +31,7 @@ class LoginFormBase extends Component {
.doSignInWithEmailAndPassword(email, password) .doSignInWithEmailAndPassword(email, password)
.then(() => { .then(() => {
this.setState({ email: "", password: "", error: null }); this.setState({ email: "", password: "", error: null });
this.props.history.push("/home"); this.props.history.push(format(new Date(), "/YYYY/MM/DD"));
}) })
.catch(error => { .catch(error => {
this.setState({ error }); this.setState({ error });

View File

@@ -1,6 +1,9 @@
* { * {
transition: 0.2s all ease-in-out; transition: 0.2s all ease-in-out;
} }
textarea:focus {
outline: none;
}
body { body {
margin: 0; margin: 0;
padding: 0; padding: 0;

View File

@@ -1,5 +1,5 @@
export const SIZES = { export const SIZES = {
tiny: "0.5rem", tiny: "0.75rem",
small: "1rem", small: "1rem",
normal: "1.25rem", normal: "1.25rem",
medium: "1.5rem", medium: "1.5rem",

View File

@@ -2,6 +2,7 @@ const theme = {
LIGHT: { LIGHT: {
name: "Light", name: "Light",
colors: { colors: {
logo: "#344157",
primary: "#2E3136", primary: "#2E3136",
secondary: "#999", secondary: "#999",
tertiary: "#C4C4C4", tertiary: "#C4C4C4",
@@ -14,6 +15,7 @@ const theme = {
DARK: { DARK: {
name: "Dark", name: "Dark",
colors: { colors: {
logo: "#EAEAEA",
primary: "#F3F6F8", primary: "#F3F6F8",
secondary: "#9Ba3B0", secondary: "#9Ba3B0",
tertiary: "#6F7682", tertiary: "#6F7682",