Skip to content

Instantly share code, notes, and snippets.

View hboylan's full-sized avatar
😎

Hugh Boylan hboylan

😎
View GitHub Profile
const SubmitButton = styled(Button)`
margin: 1rem 0;
`
// Custom options prop adds unnecessary complexity
<Select
options={[
{
title: 'One',
value: 'one',
},
{
title: 'Two',
value: 'two',
it('renders with type', () => {
render(<Button type="submit" />)
expect(screen.getByTestId('button')).toHaveAttribute('type', 'submit')
})
it('renders with click event', () => {
const onClick = jest.fn()
render(<Button onClick={onClick} />)
userEvent.click(screen.getByTestId('button'))
expect(onClick).toHaveBeenCalled()
export interface ButtonProps
extends React.ButtonHTMLAttributes<HTMLButtonElement> {
/**
* Button color (primary|secondary|transparent|link)
* @default "primary"
*/
color?: ButtonColor;
/**
* Renders full width
* @default false
export const Alert = styled.div<AlertStyle>`
background-color: ${({ type }) => secondaryAlertStyles[type]};
border-radius: ${({ theme }) => theme.shape!.borderRadius};
box-shadow: 0px 0px 2px rgba(0, 0, 0, 0.2);
display: flex;
opacity: ${({ active }) => (active ? 1 : 0)};
overflow: hidden;
${AccentBar} {
background-color: ${({ type }) => primaryAlertStyles[type]};
@hboylan
hboylan / Folder Structure
Last active June 21, 2021 19:41
Building Blocks blog post
src/components/
├── Button
│ ├── Button.stories.tsx
│ ├── Button.styled.ts
│ ├── Button.test.tsx
│ ├── Button.tsx
│ └── index.ts
├── Checkbox
│ ├── Checkbox.stories.tsx
│ ├── Checkbox.styled.ts
@hboylan
hboylan / .eslintrc
Last active June 22, 2020 12:50
ESLint + Prettier configuration for VS Code
{
"extends": ["prettier"],
"plugins": ["prettier"],
"parser": "@typescript-eslint/parser",
"parserOptions": {
"ecmaVersion": 6,
"sourceType": "module"
},
"rules": {
"prettier/prettier": "error"
@hboylan
hboylan / lambda-s3-read-write-by-line.js
Last active January 6, 2023 18:38
AWS Lambda function to read and write S3 files by line to perform efficient processing
const stream = require('stream')
const readline = require('readline')
const AWS = require('aws-sdk')
const S3 = new AWS.S3()
// read S3 file by line
function createReadline(Bucket, Key) {
// s3 read stream
const input = S3