Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@locomotivemtl/grid-helper

Package Overview
Dependencies
Maintainers
0
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@locomotivemtl/grid-helper

Creates an overlay grid for web development, allowing designers and developers to visualize the grid structure based on design guidelines.

  • 1.0.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
0
Created
Source

GridHelper

The GridHelper class is a utility that creates an overlay grid for web development, allowing designers and developers to visualize the grid structure based on design guidelines. It provides easy toggling and responsiveness based on screen breakpoints.

Features

  • Toggle the grid visibility with Control + g (customizable key).
  • Define grid structure: number of columns, gutter width, margin, color, and opacity.
  • Supports custom breakpoints, allowing different grid configurations at various screen widths.
  • Automatically updates the grid when the window is resized.

Installation

npm install @locomotivemtl/grid-helper

Usage

Basic Example

To initialize the grid with default settings:

const gridHelper = new GridHelper();

Custom Configuration

You can provide a custom configuration to adjust the grid properties:

const gridHelper = new GridHelper({
    columns: 4,
    gutterWidth: '10px',
    marginWidth: '10px',
    color: 'blue',
    opacity: 0.2,
    key: 'g',
    breakpoints: {
        '768': { columns: 8, gutterWidth: '15px' },
        '1024': { columns: 12, gutterWidth: '20px' }
    }
});

You can also use CSS variables to bind them with your CSS logic, especially for columns, gutterWidth, and marginWidth. This can be useful in cases where you dynamically update CSS variables within media queries.

const gridHelper = new GridHelper({
    columns: 'var(--grid-columns)',
    gutterWidth: `var(--grid-gutter)`,
    marginWidth: `var(--grid-margin)`,
});

Options

Main Options

OptionDefault ValueTypeDescription
columns12number | stringNumber of columns in the grid or a CSS variable for columns.
gutterWidth'16px'string | CSSVariableWidth of the gutters between columns or a CSS variable for gutter width.
marginWidth'16px'string | CSSVariableWidth of the margins around the grid or a CSS variable for margin width.
color'red'stringColor of the grid in CSS format.
opacity0.1numberOpacity of the grid.
key'g'stringKey to toggle the grid visibility (with Control key).
breakpointsundefinedobjectBreakpoint configurations for responsive grids.

Breakpoint Options

OptionTypeDescription
columnsnumber | stringNumber of columns in the grid or a CSS variable for columns.
gutterWidthstring | CSSVariableWidth of the gutters between columns or a CSS variable for gutter width.
marginWidthstring | CSSVariableWidth of the margins around the grid or a CSS variable for margin width.
colorstringColor of the grid in CSS format.
opacitynumberOpacity of the grid.
keystringKey to toggle the grid visibility (with Control key).

FAQs

Package last updated on 25 Sep 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc