GithubHelp home page GithubHelp logo

raunofreiberg / inspx Goto Github PK

View Code? Open in Web Editor NEW
1.4K 7.0 31.0 1.13 MB

Pixel perfect layout inspection.

Home Page: https://inspx.rauno.xyz

License: MIT License

TypeScript 39.80% CSS 4.48% JavaScript 30.60% SCSS 25.12%
react layout component inspect element dx

inspx's Introduction

image

inspx

npm

Pixel perfect layout inspection.

Built for React as a proof of concept.

Setup

Install the package:

npm install inspx --save-dev

Wrap the root of your application or arbitrary component trees:

import Inspect from 'inspx';

<Inspect>
  <App />
</Inspect>

Usage

Inspect elements by hovering an element and holding Option (โŒฅ) simultaneously.

demo

By default, any element with padding, margin, or width and height is inspectable.

You can disable certain properties:

<Inspect 
  margin 
  size={false} 
  padding={false}
>
  <App />
</Inspect>

Configuration

By default, the component will only be enabled in the development environment.

You can configure this behavior with the disabled prop:

<Inspect
  disabled={
    process.env.NODE_ENV === 'staging' || 
    process.env.NODE_ENV === 'production'
  }
>
  <App />
</Inspect>

Optionally, you can leverage code splitting by wrapping the exported component and using your own instead.

The library is lightweight enough for this to likely be a premature and insignificant optimization.

import * as React from 'react';
import { InspectProps } from 'inspx';

const Inspect = React.lazy(() => import('inspx'));

export default function Loader(props: InspectProps) {
  if (process.env.NODE_ENV === 'production') {
    return props.children;
  }
  return (
    <React.Suspense fallback={null}>
      <Inspect disabled={false} {...props} />
    </React.Suspense>
  );
}

inspx's People

Contributors

huv1k avatar raunofreiberg avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

inspx's Issues

Disabled is ignored if NODE_ENV=production

Hello and thank you for the great library.

I have a specific problem, as I would like inspx to stay active on development/qa/preview deploys. This would help people who review and test features on these non-production branches.

But it seems that library itself disables when NODE_ENV is set to production and disabled is ignored.

Code looks something like this:

const isPreviewOrDev =
  process.env.NODE_ENV === 'development' || process.env.PREVIEW_ENV;

<Inspect disabled={!isPreviewOrDev}>
  <Component {...props} {...pageProps} />
</Inspect>

Where PREVIEW_ENV is a env variable which tells the app it runs in a (p)review mode and not in a real production mode.

I hope I was clear enough ๐Ÿ™ˆ

Thank you!

Suporte ao linux?

When recommending to a linux user friend, the alt and alt gr keys do not work.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.