Skip to content

Commit

Permalink
Merge branch 'themes'
Browse files Browse the repository at this point in the history
  • Loading branch information
johnrees committed Jun 18, 2020
2 parents 21bf567 + 2c0e1d1 commit f1bf60b
Show file tree
Hide file tree
Showing 16 changed files with 571 additions and 19 deletions.
1 change: 0 additions & 1 deletion src/app.scss
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ body {

body,
#root {
background: #038521;
-webkit-font-smoothing: antialiased;
}

Expand Down
3 changes: 2 additions & 1 deletion src/cosmos.decorator.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import "typeface-inter";

import CssBaseline from "@material-ui/core/CssBaseline";
import { createMuiTheme } from "@material-ui/core/styles";
import ThemeProvider from "@material-ui/styles/ThemeProvider";
import React from "react";
import { useValue } from "react-cosmos/fixture";
Expand All @@ -19,7 +20,7 @@ const Decorator: React.FC<{ children: any; theme?: string }> = ({
const [theme, setTheme] = useValue("theme", { defaultValue });

return (
<ThemeProvider theme={defaultTheme}>
<ThemeProvider theme={createMuiTheme(defaultTheme)}>
<CssBaseline />
<header style={{ display: "none" }}>
<select
Expand Down
27 changes: 25 additions & 2 deletions src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import "./app.scss";
import { ApolloProvider, useQuery } from "@apollo/react-hooks";
import { ThemeProvider } from "@material-ui/core";
import CssBaseline from "@material-ui/core/CssBaseline";
import { createMuiTheme } from "@material-ui/core/styles";
import ApolloClient, { gql } from "apollo-boost";
import { Graph } from "graphlib";
import { createBrowserNavigation } from "navi";
Expand All @@ -17,6 +18,7 @@ import { api, useStore } from "./lib/store";
import routes from "./routes";
import * as serviceWorker from "./serviceWorker";
import defaultTheme from "./themes/default";
import getTeam from "./themes/teams";

const gqlClient = new ApolloClient({
uri: process.env.REACT_APP_GRAPHQL_URL,
Expand Down Expand Up @@ -77,14 +79,35 @@ const InnerApp = () => {

const App = () => {
const currentUser = useStore(state => state.data.currentUser);
const team = getTeam("southwark");

return (
<ApolloProvider client={gqlClient}>
<ThemeProvider theme={defaultTheme}>
<ThemeProvider
theme={createMuiTheme({
...defaultTheme,
palette: {
...defaultTheme.palette,
primary: {
main: team.theme.primary
}
},
overrides: {
...defaultTheme.overrides,
MuiCssBaseline: {
"@global": {
body: {
backgroundColor: team.theme.primary
}
}
}
}
})}
>
<CssBaseline />
<Router
navigation={navigation}
context={{ navigation, gqlClient, currentUser }}
context={{ navigation, gqlClient, currentUser, team }}
>
<InnerApp />
</Router>
Expand Down
17 changes: 13 additions & 4 deletions src/layouts/Application.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import MenuItem from "@material-ui/core/MenuItem";
import { makeStyles } from "@material-ui/core/styles";
import Toolbar from "@material-ui/core/Toolbar";
import ArrowForward from "@material-ui/icons/ArrowForward";
import CouncilLogo from "@material-ui/icons/EcoOutlined";
import MenuIcon from "@material-ui/icons/Menu";
import classNames from "classnames";
import * as React from "react";
Expand Down Expand Up @@ -127,8 +126,17 @@ export const Header = ({
display="flex"
alignItems="center"
px={{ md: 1 }}
py={1}
>
<CouncilLogo /> {team}
{team.logo ? (
<img
src={team.logo}
alt={`${team.name} logo`}
style={{ height: 48 }}
/>
) : (
team.name
)}
</Box>
{currentUser && (
<>
Expand Down Expand Up @@ -210,13 +218,14 @@ export const Header = ({
const Application = ({
children,
currentUser = false,
address = undefined
address = undefined,
team = { name: "Plan✕", logo: null }
}) => {
const classes = useStyles();
return (
<div className={classes.container}>
<Header
team="Hampton"
team={team}
currentUser={currentUser}
address={address}
breadcrumbs={
Expand Down
5 changes: 4 additions & 1 deletion src/layouts/Header.fixture.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@ import { Header } from "./Application";

export default (
<Header
team="Council"
team={{
name: "Plan✕",
logo: null
}}
address="30 Lake Road"
currentUser
breadcrumbs={[
Expand Down
6 changes: 4 additions & 2 deletions src/routes/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,20 @@ export type IContext = {
gqlClient;
navigation;
currentUser;
team;
};

const renderNotFound: React.FC<any> = () => <h1>404 - Not Found</h1>;

const Layout = ({ currentUser }) => {
const Layout = ({ currentUser, team }) => {
const address = useStore(state => state.data.address);
const activeStep = useStore(state => state.data.activeStep);

return (
<Application
currentUser={currentUser}
address={activeStep > 0 && address.name}
team={team}
>
<NotFoundBoundary render={renderNotFound}>
<View />
Expand All @@ -32,7 +34,7 @@ const Layout = ({ currentUser }) => {

export default compose(
withView((req, context: IContext) => (
<Layout currentUser={context.currentUser} />
<Layout currentUser={context.currentUser} team={context.team} />
)),

mount({
Expand Down
19 changes: 11 additions & 8 deletions src/themes/default.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,13 @@
import { createMuiTheme } from "@material-ui/core/styles";
import defaultsDeep from "lodash/defaultsDeep";

// see default values here https://material-ui.com/customization/default-theme

const themePalette = {
primary: {
main: "#038521", // basically black
bodyText: "#141414",
contrastText: "#fff"
main: "#141414",
bodyText: "#141414"
},
secondary: {
main: "#141414",
contrastText: "#fff"
main: "#141414"
},
grey: {
main: "#999999"
Expand Down Expand Up @@ -97,6 +93,13 @@ const _default = {
},
overrides: {
// styling overrides for specific material UI components
MuiCssBaseline: {
"@global": {
body: {
backgroundColor: "#141414"
}
}
},
MuiTypography: {
root: {
fontSize: "inherit",
Expand Down Expand Up @@ -508,4 +511,4 @@ const _default = {
}
};

export default createMuiTheme(defaultsDeep(_default));
export default defaultsDeep(_default);
1 change: 1 addition & 0 deletions src/themes/logos/Buckinghamshire.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
49 changes: 49 additions & 0 deletions src/themes/logos/Camden.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
92 changes: 92 additions & 0 deletions src/themes/logos/Canterbury.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit f1bf60b

Please sign in to comment.