Socket
Socket
Sign inDemoInstall

@storybook/addon-measure

Package Overview
Dependencies
58
Maintainers
27
Versions
907
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @storybook/addon-measure

Inspect layouts by visualizing the box model


Version published
Weekly downloads
3.8M
decreased by-14.14%
Maintainers
27
Created
Weekly downloads
 

Package description

What is @storybook/addon-measure?

The @storybook/addon-measure npm package is a Storybook addon used for measuring and inspecting elements in a Storybook UI. This tool is particularly useful for developers and designers to ensure precise visual consistency directly within the Storybook environment. It allows users to measure dimensions, spacing, and alignment of components during the development process.

What are @storybook/addon-measure's main functionalities?

Element Measurement

This feature allows users to measure the dimensions and spacing of components. By adding the withMeasure decorator, users can toggle measurement tools in the Storybook UI to inspect the component presented in the story.

import { withMeasure } from '@storybook/addon-measure';

export default {
  title: 'Your Component',
  decorators: [withMeasure]
};

export const YourStory = () => <YourComponent />;

Alignment Inspection

This feature enables users to check the alignment of elements within components. The decorator adds visual guides that help in aligning text, icons, or other elements accurately within the component.

import { withMeasure } from '@storybook/addon-measure';

export default {
  title: 'Another Component',
  decorators: [withMeasure]
};

export const AnotherStory = () => <AnotherComponent />;

Other packages similar to @storybook/addon-measure

Readme

Source

Storybook Addon Measure

Storybook addon for inspecting layouts and visualizing the box model.

  1. Hold down the modifier key:
  • MacOS: ⌥ Option
  • Windows: Alt
  1. Hover over a DOM node

  2. Storybook will display the dimensions of the selected element—margin, padding, border, width and height—in pixels.

Usage

  1. This addon requires Storybook 6.3 or later. Install the latest with npx sb upgrade --prerelease

  2. Install the addon:

npm i -D @storybook/addon-measure
  1. Add "@storybook/addon-measure" to the addons array in your .storybook/main.js:
module.exports = {
  addons: ["@storybook/addon-measure"],
};

Inspiration

  • Inspx by Rauno Freiberg
  • Aaron Westbrook's script
  • Visbug from the Chrome team

Contributing

Development scripts

Clone the repository and install dependencies.

yarn
  • yarn start runs babel in watch mode and starts Storybook
  • yarn build build and package your addon code

Release Management

Setup

This project is configured to use auto for release management. It generates a changelog and pushes it to both GitHub and npm. Therefore, you need to configure access to both:

  • NPM_TOKEN Create a token with both Read and Publish permissions.
  • GH_TOKEN Create a token with the repo scope.

Add them to the .env file at the root of your project:

GH_TOKEN=<value you just got from GitHub>
NPM_TOKEN=<value you just got from npm>

Creating a releasing

To create a release locally you can run the following command, otherwise the GitHub action will make the release for you.

yarn release

That will:

  • Build and package the addon code
  • Bump the version
  • Push a release to GitHub and npm
  • Push a changelog to GitHub

Keywords

FAQs

Last updated on 24 Jun 2021

Did you know?

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

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc