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

react-native-lipstick

v1.1.1

Published

Add powerful styling to your react-native components, including scaling, global variables, selectors and more !

Downloads

10

Readme

react-native-lipstick

Add powerful styling to your react-native components, including scaling, global variables, selectors and more !

Why this ?

Working with style in react-native is lovely ! But it's also really painful when it comes to repeat the same things : using colors, scaling sizes, sharing style among multiple components...

This is where Lipstick comes in : it replaces the default StyleSheet object provided by react and allows you to do much more funny things !

Installation

npm install --save react-native-lipstick

OR

yarn add react-native-lipstick

Example

import React from "react";
import { View } from "react-native";
import StyleSheet from "react-native-lipstick";

const styles = StyleSheet.create({
  $blue: "#5a99ee",

  // Reuse of the global $blue
  topBar: {
    backgroundColor: "$blue",
    height: "60@vs",
    width: "100%",
  },

  // @vs scales the value vertically given screen height
  // @s scales horizontally given screen width
  profilePicture: {
    height: "25@vs",
    width: "25@s",
  },

  // apply a borderWidth of 1 to both topBar and profilePicture
  'topBar|profilePicture': {
    borderWidth: 1,
  }
});

export const Element = () => (
  <View style={styles.topBar}>
    <Image style={styles.profilePicture} source={{ uri: "https://..." }} />
  </View>
)

Plugins

Lipstick works with a plugin system : actually, everything is a plugin in Lipstick ! By default are provided three plugins :

  • globalVariablePlugin : allows the usage of global variables
  • multiSelectorsPlugin : handle the use of selectors (like 'topBar|profilePicture')
  • scalePlugin : scales the values according to the screen dimensions so your app looks the same on every screen (inspired by react-native-size-matters)

Write your own plugin !

A plugin is a simple function that takes a style in, and spit a style out. It's really easy to add your own !

import StyleSheet from "react-native-lipstick";

StyleSheet.addPlugin((object) => {
  // Do whatever you want with the object and return the modified style !
  return object;
});

Performances ?

I really don't know if it's a threat in terms of performance, because in depth every plugin loops through every keys of the style object. I think it's gonna add a few ms to launch time, so it's really not noticeable.

If you have ideas or anything on this please share :)