This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import {calculateStuff, fontSizes} from 'who-knows'; | |
| // we can define breakpoints and use them | |
| const breakpoints = { | |
| sm: '(max-width: 420px)', | |
| md: '(max-width: 1024px)', | |
| lg: '(max-width: 1300px)' | |
| } | |
| export const BodyText = styled.p` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| export const DefaultButton = styled.button` | |
| width: 200px; | |
| height: 60px; | |
| font-size: 15px; | |
| `; | |
| export const FancyButton = styled(DefaultButton)` | |
| background-color: gold; | |
| ` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| export const BodyText = styled.span` | |
| font-size: 15px; | |
| color: red; | |
| ` | |
| // we dynamically swap our span element for a link element by using "as" prop | |
| return ( | |
| <BodyText as="a"> This is now a link! </BodyText> | |
| ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const theme = { | |
| fontSizes: { | |
| sm: '10px', | |
| md: '15px', | |
| lg: '25px' | |
| } | |
| } | |
| const BodyText = styled.p` | |
| font-size: ${props => props.theme.fontSizes.sm} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { UserPage, FacebookHeader, FacebookFooter } from 'facebook-ripoff-components'; | |
| import { myUsersTheme } from 'file-that-gets-users-theme'; | |
| const myUserTheme = (parentTheme) => ({ | |
| backgroundColor: 'ugly-green' | |
| }) | |
| const facebookTheme = { | |
| backgroundColor: 'facebook-blue' | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { createGlobalStyle } from 'styled-components/macro'; | |
| export default createGlobalStyle` | |
| html { | |
| font-size: 10px; | |
| } | |
| body { | |
| margin: 0; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import RestOfOurApp from 'rest-of-our-app'; | |
| import GlobalStyles from './globalStyles'; // importing our global styles | |
| export const App = () => { | |
| return ( | |
| <ThemeProvider theme={theme}> | |
| <GlobalStyles /> // we place it as a sibling of our root app component | |
| <RestOfOurApp/> | |
| <ThemeProvider/> | |
| ); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // this example was taken directly from the styled components docs | |
| // I stripped out some styling since it's not really necessary to get the point | |
| const Link = styled.a` | |
| color: purple; | |
| `; | |
| const Icon = styled.svg` | |
| width: 48px; | |
| height: 48px; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import React, { useEffect } from "react"; | |
| import { setTargetPosition } from "./actions"; | |
| const animatedCompStyle = { | |
| position: "fixed", | |
| top: 0, | |
| left: 0, | |
| transform: "none", | |
| width: "50px", | |
| height: "50px", |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* | |
| I'm assuming you have a super simple store setup somewhere | |
| (look at the codesandbox for details) | |
| */ | |
| import store from "./store"; | |
| export const setTargetPosition = ({ x, y }) => { | |
| store.dispatch({ | |
| type: "ACTION_SET_TARGET_POSITION", | |
| payload: { |
OlderNewer