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

flexboxgridjs

v1.0.0

Published

Attempt to understand and translate the kristoferjoseph/flexboxgrid repository to css-in-js and use it in vamsiampolu/css-in-js-test.

Downloads

2

Readme

Converts the styles defined in flexboxgrid to vanilla javascript for use with various css-in-js libraries such as glamor and aphrodite.

The module offers a 12 column grid that uses the flexbox specification to specify columns as flex children with rows as flex parents.

Media Queries

|Name|Max-Width| |:----:|:---:| |Phone|48em| |Tablet|64em| |Desktop|75em|

The em units are calculated with respect to the font size of the parent element while the rem units are computed using the font-size of the root elements. A font size of 16px is usually provided for the root of the application.

The api consists of two container elements, a full width container-fluid as well as a responsive fixed width container.

The row style represents a flex-parent with support for wrapping content to the next line, to reverse the order of items within a row, use the rowReverse style. A row will not grow beyond it's usual size but can shrink upto the width specified for it.

There are several ways of specifying columns using flexboxgridjs, use col to specify equal width columns that expand to occupy the width of a row. To specify columns with a flex-basis (i.e. min-width of the column beyond which it cannot shrink) use col function and pass it a column size argument.

There are also modifiers that allow a column to only apply for one of the media queries specified above using the colPhane, colTablet and colDesktop classes. To specify an offset use the colOffset function and it's counterparts for each media queries as you did ith col.

flexboxgrid also comes with certain modifiers:

  • reorder elements using first and last, has additional styles similar to col which apply only for the given media query.

  • align items on the vertical axis using top, middle and bottom

  • align items on the horizontal axis using start, center and end.

  • justify space between columns, maximize it using between, minimize it using around.

To see examples head over to flexboxgrid homepage.

Additional Information

All properties for a style are camel cased as most styling solutions require/support them.

Most css-in-js provide inline media queries that are specifiedwithin the style of the element like this:

const container = {
  marginRight: 'auto',
  marginLeft: 'auto',
  [phone]: {
    width: containerSm
  },
  [tablet]: {
    width: containerMd
  },
  [desktop]: {
    width: containerLg
  }
}

Preprocessors offer mixins for building parameter based style output, we accomplish this using functions:

export function col (columnSize) {
  if (columnSize == null) {
    return {
      ...colBase,
      flexGrow: 1,
      flexBasis: 0,
      maxWidth: '100%'
    }
  }

  if (isNaN(columnSize)) {
    throw new Error('Column size must be a number')
  } else if (columnSize < 1 || columnSize > 12) {
    throw new Error('Column size must be a number within the range 1-12')
  }

  const baseWidth = 100 / TOTAL_COLUMNS
    const flexBasisNum = baseWidth * columnSize
    const flexBasis = `${flexBasisNum}%`
    const maxWidth = `${flexBasisNum}%`
    const result = {
      ...colBase,
      flexBasis,
      maxWidth
    }

  return result
}