Giter Site home page Giter Site logo

brentvatne / react-native-debug-stylesheet Goto Github PK

View Code? Open in Web Editor NEW
89.0 5.0 7.0 82 KB

Stylesheet that helps you debug layout problems in react-native, because we're all still not that good at flexbox

Home Page: https://www.npmjs.com/package/react-native-debug-stylesheet

JavaScript 100.00%

react-native-debug-stylesheet's Introduction

react-native-debug-stylesheet

When you want to debug layout problems, use this instead of the normal StyleSheet to get coloured borders (or backgrounds) around views that are affected by the stylesheet.

Demo

Add it to your project

  1. Run npm install react-native-debug-stylesheet --save
  2. When you want to debug a layout problem, do something like this:
var { PixelRatio, StyleSheet } = require('react-native');
// Drop this in to override the above StyleSheet var and use the
// DebugStyleSheet class instead.
var StyleSheet = require('react-native-debug-stylesheet');

// Business as usual
StyleSheet.create({
  // ....
});

If you prefer to use coloured backgrounds, then do this:

var StyleSheet = require('react-native-debug-stylesheet').Backgrounds;

Customize

If you'd rather make your own debug stylesheet than use the default border/background color options, you can do this easily too.

var { createDebugStylesheet, randomHexColor } = require('react-native-debug-stylesheet');

var doubleHeaderFontSize = function(styleClass, cssProperty, cssValue) {
  if (cssValue && styleClass.match(/header/)) {
    return cssValue * 2;
  }
  return cssValue;
}

var StyleSheet = createDebugStylesheet({
  backgroundColor: randomHexColor, fontSize: doubleHeaderFontSize,
  borderColor: randomHexColor, borderWidth: 0.5,
});

MIT Licensed

react-native-debug-stylesheet's People

Contributors

brentvatne avatar dustinblackman 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

Watchers

 avatar  avatar  avatar  avatar  avatar

react-native-debug-stylesheet's Issues

Support for React 0.5.0?

This looks really useful, but it doesn't work with the latest version of React anymore?

It would be awesome if it did.

Thanks,

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.