Skip to content

Instantly share code, notes, and snippets.

@matthewoestreich
Last active May 26, 2020 02:48
Show Gist options
  • Select an option

  • Save matthewoestreich/73967e386febae65ca0523cf32aa755b to your computer and use it in GitHub Desktop.

Select an option

Save matthewoestreich/73967e386febae65ca0523cf32aa755b to your computer and use it in GitHub Desktop.
React, Styled Components, Babel: HTML Boilerplate
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<!-- CHANGE PAGE TITLE -->
<title>Page Title</title>
<style>
html * {
box-sizing: border-box;
margin: 0;
padding: 0;
}
html,
body {
height: 100%;
width: 100%;
}
</style>
</head>
<body>
<div id="root"></div>
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/16.13.1/umd/react.production.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/react-dom/16.13.1/umd/react-dom.production.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/react-is/16.13.1/umd/react-is.production.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/styled-components/5.1.0/styled-components.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/babel-standalone/6.26.0/babel.min.js"></script>
<!-- CHANGE TO YOUR SCRIPT -->
<script type="text/babel" src="react_styled-components_babel.js"></script>
</body>
</html>
const styled = window.styled;
const Title = styled.h1`
font-size: 1.5em;
text-align: center;
color: palevioletred;
`;
const Container = styled.div`
height: 100vh;
width: 100vw;
`;
const GradientBackground = styled.div`
height: 100%;
background-color: ${({ startColor }) => startColor || ''};
background-image: linear-gradient(
${({ direction, startColor, endColor }) =>
`${direction}, ${startColor}, ${endColor}`}
);
`;
const App = () => {
return (
<Container>
<GradientBackground
direction="to bottom right"
startColor="black"
endColor="white"
>
<Title>Hello!</Title>
</GradientBackground>
</Container>
);
};
ReactDOM.render(<App />, document.querySelector('#root'));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment