Skip to content

Commit

Permalink
adding styled-components basic structure
Browse files Browse the repository at this point in the history
  • Loading branch information
enyelsequeira committed May 25, 2021
1 parent 8065686 commit 213f37b
Show file tree
Hide file tree
Showing 14 changed files with 341 additions and 219 deletions.
4 changes: 4 additions & 0 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"presets": ["next/babel"],
"plugins": [["styled-components", { "ssr": true }]]
}
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
"dependencies": {
"next": "10.2.3",
"react": "17.0.2",
"react-dom": "17.0.2"
"react-dom": "17.0.2",
"styled-components": "^5.3.0",
"styled-normalize": "^8.0.7"
}
}
7 changes: 0 additions & 7 deletions pages/_app.js

This file was deleted.

69 changes: 0 additions & 69 deletions pages/index.js

This file was deleted.

11 changes: 11 additions & 0 deletions src/pages/_app.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import Theme from "../styles/theme"

export default function App({ Component, pageProps }) {
return (
<>
<Theme>
<Component {...pageProps} />
</Theme>
</>
)
}
30 changes: 30 additions & 0 deletions src/pages/_document.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import Document from 'next/document'
import { ServerStyleSheet } from 'styled-components'

export default class MyDocument extends Document {
static async getInitialProps(ctx) {
const sheet = new ServerStyleSheet()
const originalRenderPage = ctx.renderPage

try {
ctx.renderPage = () =>
originalRenderPage({
enhanceApp: (App) => (props) =>
sheet.collectStyles(<App {...props} />),
})

const initialProps = await Document.getInitialProps(ctx)
return {
...initialProps,
styles: (
<>
{initialProps.styles}
{sheet.getStyleElement()}
</>
),
}
} finally {
sheet.seal()
}
}
}
File renamed without changes.
11 changes: 11 additions & 0 deletions src/pages/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@

import styled from 'styled-components'

const Title = styled.h1`
font-size: 50px;
color: ${({ theme }) => theme.colors.background1};
`

export default function Home() {
return <Title>My page</Title>
}
33 changes: 33 additions & 0 deletions src/styles/globals.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import { createGlobalStyle } from 'styled-components';
import { normalize } from 'styled-normalize';


const GlobalStyles = createGlobalStyle`
${normalize};
* {
box-sizing: border-box;
margin: 0;
padding: 0;
}
html {
font-size: 62.5%;
}
body {
font-family: ${props => props.theme.fonts.main};
font-size: 1.6rem;
height: 100%;
background: ${props => props.theme.colors.accent1};
color: ${props => props.theme.colors.primary1};
cursor: default;
}
h1,h2,h3,h4,h5,h6,button {
font-family: ${props => props.theme.fonts.title};
}
a {
text-decoration: none;
}
`;

export default GlobalStyles;
17 changes: 17 additions & 0 deletions src/styles/theme.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { ThemeProvider } from 'styled-components';
import theme from "../themes/default";
import GlobalStyles from './globals';



const Theme = ({ children }) => {

return (
<ThemeProvider theme={theme}>
<GlobalStyles />
{children}
</ThemeProvider>
);
};

export default Theme;
22 changes: 22 additions & 0 deletions src/themes/default.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
export default {
// Temp fonts
fonts: {
title: "Space Grotesk, sans-serif",
main: "Space Grotesk, sans-serif"
},
// Colors for layout
colors: {
primary1: "hsl(204,23.8%,95.9%)",
background1: "#0F1624",
accent1: "hsl(34.9,98.6%,72.9%)",
button: "hsl(205.1,100%,36.1%)",
background2: "hsl(232.7,27.3%,23.7%)",
},
// Breakpoints for responsive design
breakpoints: {
sm: 'screen and (max-width: 550px)',
md: 'screen and (max-width: 800px)',
lg: 'screen and (max-width: 1023px)',
xl: 'screen and (max-width: 1199px)'
},
}
121 changes: 0 additions & 121 deletions styles/Home.module.css

This file was deleted.

16 changes: 0 additions & 16 deletions styles/globals.css

This file was deleted.

Loading

0 comments on commit 213f37b

Please sign in to comment.