Skip to content

Commit

Permalink
feat(theming): add theme-ui
Browse files Browse the repository at this point in the history
  • Loading branch information
pixelmord committed Jan 27, 2020
1 parent aebe05f commit d79635f
Show file tree
Hide file tree
Showing 7 changed files with 2,488 additions and 51 deletions.
3 changes: 2 additions & 1 deletion packages/poolbase-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@
"firebase-functions": "^3.3.0",
"next": "^9.2.1",
"react": "^16.12.0",
"react-dom": "^16.12.0"
"react-dom": "^16.12.0",
"theme-ui": "^0.3.1"
},
"devDependencies": {
"@types/node": "^13.5.0",
Expand Down
13 changes: 13 additions & 0 deletions packages/poolbase-app/src/app/components/Header.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import React from 'react';
import { useColorMode } from 'theme-ui';

export default function Header() {
const [colorMode, setColorMode] = useColorMode();
return (
<header>
<button onClick={() => setColorMode(colorMode === 'light' ? 'dark' : 'light')}>
Toggle {colorMode === 'light' ? 'Dark' : 'Light'}
</button>
</header>
);
}
34 changes: 34 additions & 0 deletions packages/poolbase-app/src/app/pages/_app.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import React from 'react';
import App from 'next/app';
import { ThemeProvider, Styled } from 'theme-ui';

import Header from '../components/Header';
import theme from '../theme';

class MyApp extends App {
// Only uncomment this method if you have blocking data requirements for
// every single page in your application. This disables the ability to
// perform automatic static optimization, causing every page in your app to
// be server-side rendered.
//
// static async getInitialProps(appContext) {
// // calls page's `getInitialProps` and fills `appProps.pageProps`
// const appProps = await App.getInitialProps(appContext);
//
// return { ...appProps }
// }

render() {
const { Component, pageProps } = this.props;
return (
<ThemeProvider theme={theme}>
<Header />
<Styled.root as="main">
<Component {...pageProps} />
</Styled.root>
</ThemeProvider>
);
}
}

export default MyApp;
23 changes: 23 additions & 0 deletions packages/poolbase-app/src/app/pages/_document.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import React from 'react';
import Document, { Html, Head, Main, NextScript } from 'next/document';

class MyDocument extends Document {
static async getInitialProps(ctx) {
const initialProps = await Document.getInitialProps(ctx);
return { ...initialProps };
}

render() {
return (
<Html>
<Head />
<body>
<Main />
<NextScript />
</body>
</Html>
);
}
}

export default MyDocument;
41 changes: 41 additions & 0 deletions packages/poolbase-app/src/app/theme/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
export default {
useColorSchemeMediaQuery: true,
useCustomProperties: true,
colors: {
text: '#000',
background: '#fff',
primary: '#07c',
secondary: '#609',
modes: {
dark: {
text: '#fff',
background: '#222',
primary: '#0cf',
secondary: '#90c',
},
},
},
fonts: {
body: 'system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", sans-serif',
heading: 'inherit',
},
styles: {
root: {
fontFamily: 'body',
color: 'text',
bg: 'background',
},
h1: {
fontSize: [4, 5, 6],
color: 'primary',
},
a: {
color: 'primary',
textDecoration: 'none',
':hover': {
color: 'secondary',
textDecoration: 'underline',
},
},
},
};
Loading

0 comments on commit d79635f

Please sign in to comment.