Skip to content

Instantly share code, notes, and snippets.

View alanbsmith's full-sized avatar
👋

Alan B Smith alanbsmith

👋
View GitHub Profile
@alanbsmith
alanbsmith / structuring-our-styled-components-an-example-block.js
Last active March 30, 2022 13:46
structuring-our-styled-components-an-example-block
// src/blocks/Card/index.js
import styled from 'styled-components';
import Header from './Header';
import Image from './Image';
import Text from './Text';
import Title from './Title';
const Card = styled.div`
@alanbsmith
alanbsmith / structuring-our-styled-components-block-example.jsx
Last active December 9, 2017 14:02
structuring-our-styled-components-block-example
// SomeComponent.js
import Card from './blocks/Card';
...
<Card>
<Card.Header>
<Card.Image
alt=”bob-ross-headshot”
src=”www.example.com/bob-ross.jpg”
@alanbsmith
alanbsmith / structuring-our-styled-components-example-file-structure-2
Last active August 21, 2023 06:29
structuring-our-styled-components-example-file-structure-2
├ src/
├── blocks/
| ├── Card/
| | ├── Header.js // <- Element
| | ├── Image.js // <- Element
| | ├── Text.js // <- Element
| | ├── Title.js // <- Element
| | └── index.js // <- Block
├── elements/
| ├── A.js // <- Element
@alanbsmith
alanbsmith / structuring-our-styled-components-example-element.js
Last active December 8, 2017 18:18
structuring-our-styled-components-example-element
// lib/elements/A/index.js
import styled from 'styled-components';
...
const A = styled.a`
color: #263238;
text-decoration: none;
transition: color 0.2s ease;
&:hover {
color: #0097a7;
@alanbsmith
alanbsmith / structuring-our-styled-components-example-modifiers.js
Created December 8, 2017 18:20
structuring-our-styled-components-example-modifiers
const modifierConfig = {
darkGreyText: ({ theme }) => `
color: ${theme.colors.base.text};
`,
midGreyText: ({ theme }) => `
color: ${theme.colors.base.textLight};
`,
uppercase: () => `
@alanbsmith
alanbsmith / structuring-our-styled-components-example-modifier-use.jsx
Created December 8, 2017 18:22
structuring-our-styled-components-example-modifier-use
<A
href="https://example.com"
modifiers={['darkGreyText', 'uppercase']}
/>
@alanbsmith
alanbsmith / structuring-our-styled-components-import-long-example.js
Last active December 9, 2017 14:03
structuring-our-styled-components-import-long-example
import Card from './blocks/Card';
import CardHeader from './blocks/Card/Header';
import CardImage from './blocks/Card/Image';
import CardText from './blocks/Card/Text';
import CardTitle from './blocks/Card/Title';
@alanbsmith
alanbsmith / structuring-our-styled-components-import-short-example.js
Created December 8, 2017 18:29
structuring-our-styled-components-import-short-example
import Card from './blocks/Card';
@alanbsmith
alanbsmith / effective-testing-for-styled-components-clone-repo.sh
Created December 8, 2017 21:16
effective-testing-for-styled-components-clone-repo
$ git clone [email protected]:alanbsmith/jest-snapshot-example.git
$ cd jest-snapshot-example
$ yarn install
@alanbsmith
alanbsmith / effective-testing-for-styled-components-eslint-scripts.sh
Created December 8, 2017 21:18
effective-testing-for-styled-components-eslint-scripts
$ yarn lint:js
$ yarn lint:js:watch