Instantly share code, notes, and snippets.
- Warsaw, Poland
tfiechowski
/ comopnent-library-components-button-basic.js
Created
July 31, 2019 08:36
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 from "react"; | |
export default function Button({ text }) { | |
return <button>{text}</button>; | |
} |
tfiechowski
/ comopnent-library-components-button-basic.txt
Last active
July 31, 2019 08:44
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
A very simple button. | |
```jsx | |
import Button from "./Button"; | |
<Button text="We Salute You!" /> | |
``` |
tfiechowski
/ comopnent-library-components-button-css.js
Created
July 31, 2019 09:04
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 from "react"; | |
import styled from "@emotion/styled"; | |
const Wrapper = styled.button` | |
text-transform: uppercase; | |
font-size: 1.5em; | |
font-weight: bold; | |
letter-spacing: 4px; | |
background: #5cdb95; |
tfiechowski
/ comopnent-library-components-shared-css.js
Created
July 31, 2019 10:00
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 { css } from "@emotion/core"; | |
export const font = css` | |
text-transform: uppercase; | |
font-size: 1.5em; | |
font-weight: bold; | |
letter-spacing: 4px; | |
`; | |
export const shape = css` |
tfiechowski
/ comopnent-library-components-button-shared-styles.js
Created
July 31, 2019 10:05
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 from "react"; | |
import styled from "@emotion/styled"; | |
import { font, primaryColors, shape } from "../config/styles"; | |
const Wrapper = styled.button` | |
${font} | |
${primaryColors} | |
${shape} | |
`; |
tfiechowski
/ comopnent-library-components-package-module-resolver.json
Created
July 31, 2019 10:15
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
{ | |
"presets": ["@babel/preset-env", "@babel/preset-react"], | |
"plugins": [["module-resolver", { "root": ["./src"] }]] | |
} |
tfiechowski
/ comopnent-library-components-button-absolute-import.js
Created
July 31, 2019 10:21
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 from "react"; | |
import styled from "@emotion/styled"; | |
import { font, primaryColors, shape } from "config/styles"; | |
const Wrapper = styled.button` | |
${font}; ${primaryColors}; ${shape}; | |
`; | |
export default function Button({ text }) { | |
return <Wrapper>{text}</Wrapper>; |
tfiechowski
/ comopnent-library-components-button-test-basic.js
Created
July 31, 2019 17:21
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 { render, getByText } from "@testing-library/react"; | |
import React from "react"; | |
import Button from "components/Button"; | |
describe("Button", () => { | |
test("should display text", () => { | |
const { container } = render(<Button text="We Salute You!" />); | |
getByText(container, "We Salute You!"); | |
}); |
tfiechowski
/ comopnent-library-components-setup-tests.js
Created
July 31, 2019 17:23
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 { matchers } from "jest-emotion"; | |
expect.extend(matchers); |
tfiechowski
/ comopnent-library-components-button-testing-jest-config.js
Created
July 31, 2019 17:23
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
module.exports = { | |
setupFilesAfterEnv: ["./src/setupTests.js"] | |
}; |