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

@mollycule/lattice

v1.0.7

Published

CSS Grid with Styled components

Downloads

639

Readme

@mollycule/lattice

CSS Grid based layout renderer based on styled-components and styled-system

Build Status MIT License Contributors LinkedIn

Table of Contents

About The Project

Lattice is a standard CSS Grid approach to create make layouting a breeze in your React apps.

It has support for making bootstrap like responsive layouts very easily in CSS in JS ecosystems, making it very suitable for modern day React ecosystem

Built With

Getting Started

Prerequisites

Following Peer Dependencies are required for using uselattice package:

  • react: "^16.0.0"

Install

npm install --save @mollycule/lattice

yarn add @mollycule/lattice

Usage

import React from 'react'
import styled, { ThemeProvider } from 'styled-components'
import { Grid, Cell as BaseCell, BREAKPOINTS } from '@mollycule/lattice'

const Cell = styled(BaseCell)`
  min-height: 50px;
  background: mediumslateblue;
  color: white;
`

const App = () => (
  <ThemeProvider theme={{ breakpoints: BREAKPOINTS }}>
    <Grid
      width='70vw'
      mx='auto'
      gap='3px'
      cols={{ xs: 2, sm: 3, md: 4 }}
      height='500px'
      alignContent='center'
      alignItems='center'
      justifyContent='center'
      justifyItems='start'
    >
      <Cell x-offset='3' x-span='2'>
        1
      </Cell>
      <Cell y-offset={{ sm: '2', md: '1' }} y-span={{ sm: '1', md: '2' }}>
        2
      </Cell>
      <Cell>
        <Box pt='5px' fontWeight='bold' color='aqua'>
          3
        </Box>
      </Cell>
      <Cell x-span={{ sm: '2', md: '1' }}>4</Cell>
    </Grid>
  </ThemeProvider>
)

The library exports Grid, Cell and a general usage Box for general use divs. Using these, there won't be a need of writing a styled component ever. All the particular styles can be inlined by virtue of styled-system properties.

The styled components being extendable makes the generic Box component to be wrapped around for more specific frequently used elements when needed.

API

Grid Props

| Prop Name | Value Type | Example | Mapped CSS property | | -------------- | ---------------- | ----------------------------------------------------- | ----------------------- | | gap | string | gap='2px' | grid-gap | | rowGap | string | rowGap='2px' | grid-row-gap | | columnGap | string | columnGap='2px' | grid-column-gap | | alignItems | string | alignItems='center' | align-items | | alignContent | string | alignContent='center' | align-content | | justifyItems | string | justifyItems='center' | justify-items | | justifyContent | string | justifyContent='center' | justify-content | | cols | number or string | cols={2} or cols='repeat(3, minmax(200px, auto))' | grid-template-columns | | flow | string | flow='row' | grid-auto-flow | | areas | string[] | areas={['a a b', 'c c b']}' | grid-template-areas |

Cell Props

| Prop Name | Value Type | Example | Mapped CSS property | | --------- | ---------- | -------------- | ------------------- | | area | string | area='a' | grid-area | | x-offset | string | x-offset='2' | grid-column-start | | x-span | string | x-span='2' | grid-column-end | | y-offset | string | y-offset='3' | grid-row-start | | y-span | string | y-span='2' | grid-row-end |

All the above property values are responsive compatible, which can be specified based on the breakpoints approach of styled-system. A default breakpoint is also exported from the library based on Bootstrap responsive system.

export const BREAKPOINTS = {
  xs: 0,
  sm: '480px',
  md: '768px',
  lg: '1024px'
}

Note: Please use string values most of the time in order to prevent automatic suffixing of numeric values by 'px' in React as these custom properties don't fall under React unitless properties.

License

MIT © paramsinghvc

Contributing

Contributions are what make the open source community such an amazing place to be learn, inspire, and create. Any contributions you make are greatly appreciated.

  1. Fork the Project
  2. Create your Feature Branch (git checkout -b feature/AmazingFeature)
  3. Commit your Changes (git commit -m 'Add some AmazingFeature)
  4. Push to the Branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

License

Distributed under the MIT License. See LICENSE for more information.

Contact

Param Singh - @paramsinghvc - [email protected]

Project Link: https://github.com/paramsinghvc/lattice

Acknowledgements