npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

brickworks

v0.11.0-beta

Published

Lightweight, dynamic, extremely simple layouts for React

Downloads

74

Readme

brickworks

Build Status Coverage Status NPM JavaScript Style Guide

Lightweight, dynamic, simple, and styled grid layouts for React

Disclaimer: Documentation still a work in progress. Full documentation and example site coming with the v1 release, which is very, very soon. Enjoy :)

Overview

Brickworks is a lightweight layout tool, implementing the full Flexbox specification, for use with React and Styled Components. Brickworks exposes a small handful of components to help build and manage consistent layouts, saving you and your team time and most importantly sanity.

Brickworks is designed to be incredibly user-friendly and easy to use, drawing on conventions present in similar CSS frameworks (such as grids, rows, and columns) that almost all developers are already familiar with. This is accomplished through smart defaults and an extremely focused philosophy.

What sets Brickworks apart from the others is its commitment to ONLY be concerned with layout, nothing else. It aims to avoid conflicting with other libraries or styling choices as much as possible and provides the full Flexbox specification through props as an escape hatch for complex layouts that cannot be achieved through shortcuts and smart defaults.

TL;DR - Beautiful, consistent, and easy to build layouts with a handful of props, and the full Flexbox specification when you need it.

Why Use Brickworks

- Dynamic

- Lightweight (~2kb gzipped)

- Fully-typed props with 100% test coverage

- Responsive and mobile-first

- Focused, only concerned with layout

- Smart, easy to understand conventions

- Almost no learning curve

- No giant config required

- Plays well with others

Install

yarn add brickworks
# or with npm
npm install --save brickworks

Brickworks makes use of a modest list of peer dependencies, including Prop Types and Styled Components. Make sure to install those too.

yarn add prop-types styled-components
# or with npm
npm install --save prop-types styled-components

Getting Started

The most basic grid setup

Creates a grid with one row of equally-spaced columns.

import React, { Component } from 'react';
import { Grid, Row, Col } from 'brickworks';

class Example extends Component {
  render() {
    return (
      <Grid>
        <Row>
          <Col>1</Col>
          <Col>2</Col>
          <Col>3</Col>
        </Row>
      </Grid>
    );
  }
}

Responsive three-column layout with gutters

Creates a grid with one row of exactly three columns. Since this example grid has six total column components, they will wrap, creating a stacked layout.

<Grid>
  <Row columns={3}>
    <Col>1</Col>
    <Col>2</Col>
    <Col>3</Col>
    <Col>4</Col>
    <Col>5</Col>
    <Col>6</Col>
  </Row>
</Grid>

Responsive three-column layout with a maximum width

We can also give our grid a max width. It's child components are centered by default.

<Grid maxWidth={800}>
  <Row columns={3}>
    <Col>1</Col>
    <Col>2</Col>
    <Col>3</Col>
  </Row>
</Grid>

Responsive layout with media queries

Brickworks also makes working with different breakpoints a breeze. Our basic grid setup now renders its child Col components at different widths based on media breakpoints, still maintaining equal spacing and widths.

By default, child Col components will stack or wrap based on the column count at each breakpoint. In this example with six columns, we'll get two rows of equally-spaced Col components on medium-sized screens or larger, three rows of two columns on small screens, and six rows of one column on extra small screens.

<Grid>
  <Row xs={1} sm={2} md={3}>
    <Col>1</Col>
    <Col>2</Col>
    <Col>3</Col>
    <Col>4</Col>
    <Col>5</Col>
    <Col>6</Col>
  </Row>
</Grid>

Building Layouts with Brickworks

Brickworks enforces a grid > row > columns convention (similar to Bootstrap and Semantic), and its defaults are based on this implementation pattern. It's built with flexbox and is fully responsive right out of the box.

Grid components function as containers for your layout, effectively managing the padding and margin of their child Row and Col components. They should exist as high up the component tree as possible and not be nested within each other, or other Row or Col components.

Row components serve as wrappers for columns. They can control the width of their child columns through props and media breakpoints.

Col components serve as wrappers for your content. Content should never be placed directly inside a Grid or Row.

Props

Brickworks layout components are configured through props. It aims to make available all the configuration necessary to create beautiful and complex layouts without any additional 'clutter'. All Brickworks components are composed with a base set of 'style' props available any component in the library.

| Prop | Default | Type | Description | | ----------- | ------- | --------------- | -------------------------------------------------------------------------------- | | left | | bool | sets the alignment to the left | | right | | bool | sets the alignment to the right | | center | | bool | centers the component | | minWidth | | number / string | set the minimum width | | maxWidth | | number / string | set the maximum width | | minHeight | | number / string | set the minimum height | | maxHeight | | number / string | set the maximum height | | textAlign | | enum | set the text alignment left right center justify initial inherit |

<Grid />

Grid is a container component, typically managing a combination of rows and columns.

| Prop | Default | Type | Description | | -------------- | ---------- | ---------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | flow | row wrap | enum | shorthand for flex-direction and flex-wrap, which define the container's axes row row-reverse column column-reverse nowrap wrap wrap-reverse row nowrap row wrap row wrap-reverse row-reverse nowrap row-reverse wrap row-reverse wrap-reverse column nowrap column wrap column wrap-reverse column-reverse nowrap column-reverse wrap column-reverse wrap-reverse initial inherit | | justify | center | enum | sets alignment of items along the main axis flex-start flex-end center space-around space-between space-evenly initial inherit | | alignContent | | enum | sets alignment of the container's lines along the cross-axis flex-start flex-end center space-around space-between stretch initial inherit | | alignItems | | enum | sets alignment of items along the cross-axis flex-start flex-end center baseline stretch initial inherit | | spacing | 1em | bool / number / string | A grid can be spaced, which creates equally-spaced gutters both horizontally and vertically. spacing can be used simply as a boolean to apply the default padding, or as a number or string which is a valid css value with a unit, i.e. '20px', '1.5rem' | | noSpacing | | bool | Removes/overwrites any spacing applied by default or through the spacing prop on ALL child rows and columns. |

<Row />

Row is both a container component and an item component, typically used to manage child columns, but within a container.

| Prop | Default | Type | Description | | -------------- | ---------- | ------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | flow | row wrap | enum | shorthand for flex-direction and flex-wrap, which define the container's axes row row-reverse column column-reverse nowrap wrap wrap-reverse row nowrap row wrap row wrap-reverse row-reverse nowrap row-reverse wrap row-reverse wrap-reverse column nowrap column wrap column wrap-reverse column-reverse nowrap column-reverse wrap column-reverse wrap-reverse initial inherit | | justify | center | enum | sets alignment of items along the main axis flex-start flex-end center space-around space-between space-evenly initial inherit | | alignContent | | enum | sets alignment of the container's lines along the cross-axis flex-start flex-end center space-around space-between stretch initial inherit | | alignItems | | enum | sets alignment of items along the cross-axis flex-start flex-end center baseline stretch initial inherit | | columns | | number | A row can specify its column count. | | xs | | number | A row can specify its column count for extra-small screens. Brickworks' mobile-first approach makes this the default, so no media query exists for the smallest setting. This is effectively equal to setting the columns prop, but provides a more semantic and readable option when utilizing other sizing props on the same component. | | sm | | number | A row can specify its column count for small screens. default: (min-width: 576px) | | md | | number | A row can specify its column count for medium-sized screens. default (min-width: 768px) | | lg | | number | A row can specify its column count for large screens. default: (min-width: 992px) | | xl | | number | A row can specify its column count for small screens. default: (min-width: 1200px) | | order | 0 | number | sets the order in which the row will appear. |

<Col />

Col is an item component, typically used to wrap content inside a grid or row.

| Prop | Default | Type | Description | | ----------- | ---------- | -------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | flex | 1 1 auto | number / array | sets the flex property, which is shorthand for grow, shrink, and basis. Can simply accept a number, which sets the grow value, or an array containing grow and shrink, or all three values. Omitted values will fall back to their defaults | | alignSelf | | enum | overrides the vertical alignment set by align-items in the parent container for a single element auto, flex-start, flex-end, center, baseline, stretch, initial, inherit | | order | 0 | number | sets the order in which the row will appear |

License

MIT © mattvox