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

Draper

v1.1.0

Published

Atomic, functional and modular styling for React Native. Inspired by Basscss and Tachyons.

Downloads

76

Readme

Draper

Atomic, functional and modular styling for React Native. Inspired by Basscss and Tachyons.

Usage

npm i Draper -S

Build draper styles in a styles.js module:

import draper from 'Draper';
export default draper();

Then to use them:

import s from './styles';

<View style={[ s.bgWhite, s.p2, s.mt2, s.rounded ]}>
  { ... }
</View>

Customizing

The base config contains defaults for rem, borderWidth, typeScale, (whitespace)scale, lineHeightScale and clrs. You can modify these by passing in options to the build function. For example:

import draper from 'Draper';
export default draper({
  clrs: { mauve: '#E0B0FF' },
  scale: [1, 2, 3, 4],
  typeScale: {
    f2: 1.5,
    f3: 1.25,
  },
});

Extending

import draper from 'Draper';
import { StyleSheet } from 'react-native';

export default {
  ...draper(),
  ...StyleSheet.create({
    myCustomClass: { color: 'magenta' },
    o0: { opacity: 0 },
    o10: { opacity: 0.1 },
    o20: { opacity: 0.2 },
    o30: { opacity: 0.3 },
    o40: { opacity: 0.4 },
    o50: { opacity: 0.5 },
    o60: { opacity: 0.6 },
    o70: { opacity: 0.7 },
    o80: { opacity: 0.8 },
    o90: { opacity: 0.9 },
    o100: { opacity: 1 },
  }),
};

Modules

Absolute

Absolute positioning and zIndex utilities. It also aliases StyleSheet.absoluteFill.

📑source

Border

Border radius and sizing utilities. Border radius scale: 1rem, 2rem, 3rem, 4rem, 8rem, 16rem. Border sizing supports three options:

  • 0
  • StyleSheet.hairlineWidth
  • config.borderWidth

📑source

#### Colors

Text, border and background colour utilities. The colour values used in this module are from mrmrs/colors. For example:

{ black:        { color: '#515163' } }
{ bgBlack:      { backgroundColor: '#515163' } }
{ borderBlack:  { borderColor: '#515163' } }

📑source

Dimensions

Width and height utilities using this scale: 1rem, 2rem, 3rem, 4rem, 8rem, 16rem.

📑source

Flexbox

These entire flexbox module as utilities.

📑source

Typography

Font style, weight and size utilities. Font weight: normal, bold, 100 - 900. Font sizes are generated using a type scale.

const typeScale = {
  f1: 2, // * rem
  f2: 1.5, // * rem
  f3: 1.25, // * rem
  f4: 1, // * rem
  f5: 0.875, // * rem
  f6: 0.75, // * rem
};

📑source

In React Native lineHeight is not a multiplier. This makes it hard to create line height utilities. Instead you can create text components which have all the fontSize and lineHeight stylings. See text.js for an example.

Whitespace

Margin and padding utilities.

Padding
	base: p
	modifiers: h, v, t, r, b, l
	scale: 0, 1, 2, 3, 4, 5, 6

Margin
	base: m
	modifiers: h, v, t, r, b, l
	scale: 0, 1, 2, 3, 4, 5, 6

Example:
	mb1 = marginBottom: 0.5 * rem
	ph1 = paddingHorizontal: 4 * rem

📑source

Example

To run the example:

  • npm install
  • npm run dev:ios for iOS and npm run dev:android for Android.

Credits