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

rn-theme-wrapper

v1.6.5-beta

Published

React Native Theme Warpper

Downloads

4

Readme

rn-theme-wrapper

This library will use to manage multi themes in react native app

Installing

Installation of the package is easy and this library will not link with a native so it will be lightweight and high-performance compared to another package.

We can install this package with the use of Npm and Yarn and it's described below.

Using npm:

$ npm install rn-theme-wrapper

Using yarn:

$ yarn add rn-theme-wrapper

Amazing Features

  • Easy for integration and lightweight library
    • The library is easy to integrate and developer friendly we only focus in require functionality which is a basic need of all applications and we are not providing unwanted functionality that's why our library is light weighted and provides high performance to the app.
  • Theme Provider component for the whole app.
    • We are providing one Provider component that component will help to serve the theme to the whole app and this component will warn only in the main file of the app so the developer doesn't need to do duplicate code for the same functionality.
  • Hooks for managing style and theme.
    • Package is providing two custom hooks useThemedStyles and useTheme which are used for getting active theme colors and changing theme functionality.
  • Can manage theme with a single config file.
    • Yes, the Whole app theme will define in a single JSON config file in that file developer will define colors in JSON and our provider component will serve those colors to the required places.
    • With help of this app and theme will be separate from the code and in the future if is there any need for a changing theme then we can do it easily.

Demo

Demo source code is here

Quick Start

import { ThemeProvider, useThemedStyles, useTheme } from "rn-theme-wrapper";

Provide default color theme to ThemeProvider

const App = () => {
  const defaultColors = {
    id: 1,
    BACKGROUND: "#ecf0f1",
    BACKGROUND_SECONDARY: "#ffffff",
    TEXT: "#171717",
    TEXT_SECONDARY: "#686D76",
    PRIMARY: "#FF5714",
    SECONDRY: "#6EEB83",
  };

  const typography = {
    size: {
      S: 16,
      M: 20,
      L: 30,
    },
    letterSpacing: {
      S: 2,
      M: 5,
      L: 10,
    },
  };

  return (
    <ThemeProvider defaultTheme={{ colors: defaultColors, typography }}>
      <YOUR_NAVIGATION_STACK />
    </ThemeProvider>
  );
};

Use theme into stylesheet

import { View, StyleSheet, Image, Text } from "react-native";
import { useThemedStyles, useTheme } from "rn-theme-wrapper";

export const Item = ({ data, loading }) => {
  const style = useThemedStyles(styles);
  const theme = useTheme();
  return (
    <View style={style.mainBox}>
      <Text>Applyed theme</Text>
    </View>
  );
};

const styles = (theme) =>
  StyleSheet.create({
    mainBox: {
      height: 130,
      width: 130,
      borderRadius: 12,
      justifyContent: "center",
      alignItems: "center",
      backgroundColor: theme.colors.PRIMARY,
      marginRight: 22,
      shadowColor: "#000",
      shadowOffset: { width: 1, height: 1 },
      shadowOpacity: 0.4,
      shadowRadius: 3,
      elevation: 5,
      marginBottom: 8,
    },
  });

Change theme

const darkTheme = {
  id: 2,
  BACKGROUND: "#2c2b2e",
  BACKGROUND_SECONDARY: "#141414",
  TEXT: "#ecf0f1",
  TEXT_SECONDARY: "#bdc3c7",
  PRIMARY: "#FF5714",
  SECONDRY: "#6EEB83",
};

const theme = useTheme();

//This function will change a theme in the theme provider
theme.customeTheme(darkTheme);

FAQ

Q: Why should I need to use this? A: Because this theme wrapper can directly serve the theme to the app style sheet another library is not providing these facilities so as a developer it will reduce development time for theme management functionality.

Q: How does the package lightweight and provides high performance? A: We are only providing the required functionality which is a basic need of all apps so we avoid unwanted theme features that's why the package is lightweight. And package logic and function are dependent on javascript and ES6 modules so this package will not link to the native platform and this will provide high performance.

Q: How it will help to improve code quality? A: Yes this library will help you to maintain code quality because the whole app theme will be managed in a single config file and we will not provide any hardcoded color to any component so the coding standard and code quality will improve.

Support

This library will support all es6 supported react-native versions and functional components.

People