Add globalStyles
This commit is contained in:
parent
b50db0274d
commit
1e117f1ad0
6 changed files with 57 additions and 40 deletions
|
|
@ -1,12 +1,14 @@
|
||||||
import React, { Component } from 'react'
|
import React, { Component } from 'react'
|
||||||
import { BrowserRouter as Router, Route, Switch } from 'react-router-dom'
|
import { BrowserRouter as Router, Route, Switch } from 'react-router-dom'
|
||||||
import Helmet from 'react-helmet'
|
import Helmet from 'react-helmet'
|
||||||
|
|
||||||
import Home from './views/Home'
|
import Home from './views/Home'
|
||||||
import About from './views/About'
|
import About from './views/About'
|
||||||
import NoMatch from './views/NoMatch'
|
import NoMatch from './views/NoMatch'
|
||||||
import Nav from './components/Nav'
|
import Nav from './components/Nav'
|
||||||
import NavLink from './components/NavLink'
|
import NavLink from './components/NavLink'
|
||||||
import Logo from './components/Logo'
|
import Logo from './components/Logo'
|
||||||
|
import globalStyles from './globalStyles'
|
||||||
|
|
||||||
const siteTitle = 'HyperStatic'
|
const siteTitle = 'HyperStatic'
|
||||||
const routes = [
|
const routes = [
|
||||||
|
|
@ -23,6 +25,9 @@ const routes = [
|
||||||
]
|
]
|
||||||
|
|
||||||
class App extends Component {
|
class App extends Component {
|
||||||
|
componentDidMount () {
|
||||||
|
globalStyles()
|
||||||
|
}
|
||||||
render () {
|
render () {
|
||||||
return (
|
return (
|
||||||
<Router>
|
<Router>
|
||||||
|
|
|
||||||
|
|
@ -2,18 +2,20 @@ import React from 'react'
|
||||||
import { Route, Link } from 'react-router-dom'
|
import { Route, Link } from 'react-router-dom'
|
||||||
import styled from 'styled-components'
|
import styled from 'styled-components'
|
||||||
|
|
||||||
|
import { color } from '../globalStyles'
|
||||||
|
|
||||||
const NavLink = styled.span`
|
const NavLink = styled.span`
|
||||||
a {
|
a {
|
||||||
padding: .5rem 1rem;
|
padding: .5rem 1rem;
|
||||||
display: block;
|
display: block;
|
||||||
font-weight: 400;
|
font-weight: 400;
|
||||||
transition: color 0.2s, border-bottom-color 0.2s;
|
transition: color 0.2s, border-bottom-color 0.2s;
|
||||||
color: ${props => props.active ? 'var(--col1)' : 'inherit'};
|
color: ${props => props.active ? color.primary : 'inherit'};
|
||||||
text-decoration: none;
|
text-decoration: none;
|
||||||
border-bottom: 1px solid;
|
border-bottom: 1px solid;
|
||||||
border-bottom-color: ${props => props.active ? 'var(--col1)' : 'transparent'};
|
border-bottom-color: ${props => props.active ? color.primary : 'transparent'};
|
||||||
&:hover, &:active, &:focus {
|
&:hover, &:active, &:focus {
|
||||||
color: ${props => props.active ? 'var(--col1)' : 'inherit'};
|
color: ${props => props.active ? color.primary : 'inherit'};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
`
|
`
|
||||||
|
|
|
||||||
|
|
@ -2,10 +2,12 @@ import React from 'react'
|
||||||
import styled from 'styled-components'
|
import styled from 'styled-components'
|
||||||
import { Section, Container } from './common'
|
import { Section, Container } from './common'
|
||||||
|
|
||||||
|
import { color } from '../globalStyles'
|
||||||
|
|
||||||
const Header = styled(Section)`
|
const Header = styled(Section)`
|
||||||
line-height: 1em;
|
line-height: 1em;
|
||||||
color: var(--col1);
|
color: ${color.primary};
|
||||||
background: var(--col1);
|
background: ${color.primary};
|
||||||
color: white;
|
color: white;
|
||||||
h2{
|
h2{
|
||||||
font-weight: 100;
|
font-weight: 100;
|
||||||
|
|
|
||||||
43
src/globalStyles.js
Normal file
43
src/globalStyles.js
Normal file
|
|
@ -0,0 +1,43 @@
|
||||||
|
import { injectGlobal } from 'styled-components'
|
||||||
|
|
||||||
|
export const color = {
|
||||||
|
primary: '#FA5463',
|
||||||
|
secondary: '#212121',
|
||||||
|
lightGrey: 'whitesmoke'
|
||||||
|
}
|
||||||
|
|
||||||
|
export const font = {
|
||||||
|
primary: `'Avenir', sans-serif`
|
||||||
|
}
|
||||||
|
|
||||||
|
export default () => injectGlobal`
|
||||||
|
html{
|
||||||
|
box-sizing: border-box;
|
||||||
|
font-size: 62.5%;
|
||||||
|
background: ${color.lightGrey};
|
||||||
|
}
|
||||||
|
|
||||||
|
body {
|
||||||
|
font-family: ${font.primary};
|
||||||
|
min-height: 100vh;
|
||||||
|
position: relative;
|
||||||
|
background: white;
|
||||||
|
color: ${color.secondary};
|
||||||
|
font-size: 1.6em;
|
||||||
|
font-weight: 300;
|
||||||
|
letter-spacing: .01em;
|
||||||
|
line-height: 1.6;
|
||||||
|
-webkit-font-smoothing: antialiased;
|
||||||
|
}
|
||||||
|
|
||||||
|
*,
|
||||||
|
*:before,
|
||||||
|
*:after {
|
||||||
|
box-sizing: border-box;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
a{
|
||||||
|
color: ${color.primary};
|
||||||
|
}
|
||||||
|
`
|
||||||
|
|
@ -1,34 +0,0 @@
|
||||||
:root{
|
|
||||||
--col1: #FA5463;
|
|
||||||
--col2: #212121;
|
|
||||||
}
|
|
||||||
|
|
||||||
html{
|
|
||||||
box-sizing: border-box;
|
|
||||||
font-size: 62.5%;
|
|
||||||
background: whitesmoke;
|
|
||||||
}
|
|
||||||
|
|
||||||
body {
|
|
||||||
font-family: 'Avenir', sans-serif;
|
|
||||||
min-height: 100vh;
|
|
||||||
position: relative;
|
|
||||||
background: white;
|
|
||||||
color: var(--col2);
|
|
||||||
font-size: 1.6em;
|
|
||||||
font-weight: 300;
|
|
||||||
letter-spacing: .01em;
|
|
||||||
line-height: 1.6;
|
|
||||||
font-smoothing: antialiased;
|
|
||||||
}
|
|
||||||
|
|
||||||
*,
|
|
||||||
*:before,
|
|
||||||
*:after {
|
|
||||||
box-sizing: border-box;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
a{
|
|
||||||
color: var(--col1);
|
|
||||||
}
|
|
||||||
|
|
@ -2,7 +2,6 @@ import React from 'react'
|
||||||
import { render } from 'react-snapshot'
|
import { render } from 'react-snapshot'
|
||||||
import App from './App'
|
import App from './App'
|
||||||
import 'normalize.css'
|
import 'normalize.css'
|
||||||
import './index.css'
|
|
||||||
|
|
||||||
const rootEl = document.getElementById('root')
|
const rootEl = document.getElementById('root')
|
||||||
render(<App />, rootEl)
|
render(<App />, rootEl)
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue