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

react-grid-debugger

v1.0.2

Published

Tool for debugging grid-based layouts

Downloads

2

Readme

react-grid-debugger

Visual Tool for debugging grid-based layouts

Grid Debugger Demo

NPM JavaScript Style Guide

Table of Contents

Motivation

A layout based on a grid system can be something hard to visually debug: proportions, alignments and gutters may vary from project to project and making sure that each layout is well implemented takes both developer and designer time.

This is a visual tool based on a React component that adds a grid overlay on top of our current page, making it easier to see if the number of columns, spacings, etc are up to spec.

Install

npm install --save react-grid-debugger
or
yarn add grid-debuger

Please check Should this be a dependency or a devDependency? to understand if you need it as a dev dependency or not

Usage

react-grid-debugger is a react component, so you can use it like you'd use any other component.

It accepts a theme prop so if your project uses styled-components/emotion and you have defined the breakpoints for your theme, you can pass it into the debugger.

import React, { Component } from 'react'

import GridDebugger from 'react-grid-debugger'

export default class App extends Component {
  render () {
    return (
      <main>
        <GridDebugger
          show
          maxWidth={'1000px'}
          theme={myAppTheme}
          numCols={[1, 4, 12]}
          gutter={{ 320: '2rem', 680: '40px', 800: '50px'}}
          />
      </main>
    )
  }
}

Toggling the debugger

Pressing keys Ctrl and g simultaneously toggles the debugger visibility.

More configuration examples:

<GridDebugger numCols={12} gutter="40px" />
<GridDebugger numCols={12} gutter={{ 320: '2rem', 680: '40px', 800: '50px'}} />
<GridDebugger numCols={12} gutter={['2rem', '40px', '50px', '1000px']} />
<GridDebugger numCols={[1, 4, 7]} gutter={{ 320: '2rem', 680: '40px', 800: '50px'}} />
<GridDebugger maxWidth={'400px'} numCols={[1, 4, 12]} gutter={{ 320: '2rem', 680: '40px', 800: '50px'}} />
<GridDebugger maxWidth={['280px', '600px', '1000px']} numCols={[1, 4, 12]} gutter={{ 320: '2rem', 680: '40px', 800: '50px'}} />

Props

Note that most of the props accept:

  • string or number: for indicating a single value for that prop.
  • array: an array (of numbers or strings) that should be used as values, ordered by breakpoints. This means that the first element of the array will be used for the first breakpoint, the second one for the second breakpoint, and so on. If no theme is provided to the debugger, the default breakpoints are used. If the number of values provided is bigger than the number of breakpoints, the remaining ones are discarded.
  • object: an object where each key represents a screen width and its property represents the value that should be used for that breakpoint.

| Prop | Type | Required |Description | |------|----------|------|-------------| | show | bool | No | wether the debugger should be initially visible (it can be toggled with ctrl + g) | | theme | No | object | represents the app theme, normally provided by a ThemeProvider, if you use styled-components/emotion | | maxWidth | string / array / object | No | grid maximum width | | numCols | number / array / object | Yes | number of columns | | gutter | string / array / object | Yes | gutter size |

Should this be a dependency or a devDependency?

It's really up to you. You might want to just have it available locally and not worry abound bundling it, or you may want it to be available on a specific environment. If you do make it available in a prod build, make sure to use a separate chunk for it and only request it if really needed.

License

MPL-2.0