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

reskin

v3.4.1

Published

Responsive, theme-based library for ReactJs, Expo, React Native

Downloads

6

Readme

RESKIN

Responsive, theme-based library for ReactJs, Expo, React Native

Installation

NPM

npm i reskin --save

YARN

yarn add reskin

Getting started

Create your theme

const theme = {
  fonts: {
    body: "system-ui, sans-serif",
    heading: '"Avenir Next", sans-serif',
    monospace: "Menlo, monospace",
  },
  colors: {
    text: "#000",
    background: "#fff",
    primary: "#33e",
  },
};

Style your UI

function Heading({ children }) {
  const { theme } = useTheme();
  return (
    <h1
      style={{
        color: theme.colors.primary,
        fontFamily: theme.fonts.heading,
      }}
    >
      {children}
    </h1>
  );
}

function App() {
  return (
    <ThemeProvider theme={theme}>
      <Heading />
    </ThemeProvider>
  );
}

Features

  • Responsive styles
  • No special configurations needed
  • Universal (Android, iOS, Web, & more)
  • Works with Expo
  • Works with Vanilla React Native
  • Works with Next.js
  • Full theme support
  • Super easy to custom theme (The theme object is just plain object)
  • Super flexible, can use with many purposes (i18n module..)
  • TypeScript support

Examples

Changing theme at Provider level

import { ThemeProvider } from "reskin";
import { useState } from "react";

const lightTheme = {};
const darkTheme = {};

function App() {
  const [theme, setTheme] = useState(lightTheme);

  return (
    <ThemeProvider theme={theme}>
      <button onClick={() => setTheme(darkTheme)}>Dark</button>
      <button onClick={() => setTheme(lightTheme)}>Light</button>
    </ThemeProvider>
  );
}

Changing theme at component level

import { useTheme, ThemeProvider } from "reskin";
import { useState } from "react";

const lightTheme = {};
const darkTheme = {};

function ThemeToggler() {
  const { set } = useTheme();
  return (
    <div>
      <button onClick={() => set(darkTheme)}>Dark</button>
      <button onClick={() => set(lightTheme)}>Light</button>
    </div>
  );
}

function App() {
  const [theme, setTheme] = useState(lightTheme);

  return (
    <ThemeProvider theme={theme} onChange={setTheme}>
      <ThemeToggler />
    </ThemeProvider>
  );
}

Chaging theme by name

import { useTheme, ThemeProvider } from "reskin";
import { useState } from "react";

const lightTheme = { name: "light" };
const darkTheme = { name: "dark" };

function ThemeToggler() {
  const { theme, set } = useTheme();
  return (
    <button onClick={() => set(theme.name === "dark" ? "light" : "dark")}>
      {theme.name}
    </button>
  );
}

function App() {
  const [theme, setTheme] = useState(lightTheme);

  return (
    <ThemeProvider
      theme={theme}
      onChange={(name) => setTheme(name === "dark" ? darkTheme : lightTheme)}
    >
      <ThemeToggler />
    </ThemeProvider>
  );
}

Using responsive values

import { useTheme, ThemeProvider } from "reskin";

import { useEffect } from "react";

const theme = {
  normalValue: 1,
  // responsive value
  fontSize: [
    // base value
    12,
    // for medium screen
    16,
    // for large screen
    24,
    // for extra large screen
    32,
  ],
};

function Heading() {
  const { theme } = useTheme();
  return <h1 style={{ fontSize: theme.fontSize }} />;
}

function App() {
  const screenSize = window.innerWidth;
  // calculate breakpoint base on screen size
  // the breakpoint is use to select correct responsive value
  const breakpoint =
    screenSize >= 1024 ? 3 : screenSize >= 768 ? 2 : screenSize >= 480 ? 1 : 0;

  useEffect(() => {
    // can use useWindowDimensions() in react native or window.addEventListener('resize') to update breakpoint
  }, []);

  return (
    <ThemeProvider theme={theme} breakpoint={breakpoint}>
      <Heading />
    </ThemeProvider>
  );
}

Using query specific values

import { useTheme, ThemeProvider } from "reskin";

const theme = {
  // query specific value
  fontSize: {
    $is: {
      // value for android
      android: 16,
      // value for safari
      safari: 17,
      // value for ios11
      'ios11': 15,
      // value for any ios version
      'ios.+': 15,
    },
  },
};

function Heading() {
  const { theme } = useTheme();
  return <h1 style={{ fontSize: theme.fontSize }} />;
}

function App() {
  return (
    <ThemeProvider theme={theme} query="ios12">
      <Heading />
    </ThemeProvider>
  );
}

Using reskin as i18n module

import { useTheme, ThemeProvider } from "reskin";
import { useState } from "react";

const en = { hello: "Hello" };
const fr = { hello: "Bonjour" };

function Heading() {
  const { theme } = useTheme();
  return <h1>{theme.hello}</h1>;
}

function App() {
  const [theme, setTheme] = useState(en);
  return (
    <ThemeProvider theme={theme}>
      <button onClick={() => setTheme(en)}>EN</button>
      <button onClick={() => setTheme(fr)}>FR</button>
      <Heading />
    </ThemeProvider>
  );
}

Dynamic values

const data = {
  // the dynamic value is evaluated once
  now: () => new Date(),
}

const styles = {
  reactNode: () => <View/>,
  styles: (sx) => StyleCreator.create({
    heading: {
      fontWeight: 'bold',
      fontSize: 30,
      // select value according to breakpoint
      margin: sx([10, 20, 30])
    }
  })
}

const en = {
  hello: 'Hello',
  world: 'World',
  // iterpolation
  greeting: ({ theme }) => `${theme.hello} ${theme.world}`
}