Skip to content

Instantly share code, notes, and snippets.

import React from "react";
export default function Button({ text }) {
return <button>{text}</button>;
}
A very simple button.
```jsx
import Button from "./Button";
<Button text="We Salute You!" />
```
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;
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`
import React from "react";
import styled from "@emotion/styled";
import { font, primaryColors, shape } from "../config/styles";
const Wrapper = styled.button`
${font}
${primaryColors}
${shape}
`;
{
"presets": ["@babel/preset-env", "@babel/preset-react"],
"plugins": [["module-resolver", { "root": ["./src"] }]]
}
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>;
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!");
});
import { matchers } from "jest-emotion";
expect.extend(matchers);
module.exports = {
setupFilesAfterEnv: ["./src/setupTests.js"]
};