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

@humayunkabir/react-native-theme

v0.2.2

Published

A customizable theme for React Native apps

Downloads

1

Readme

@humayunkabir/react-native-theme

A customizable theme for React Native apps

Installation

npm install @humayunkabir/react-native-theme

or

yarn add @humayunkabir/react-native-theme

Usage

import { View, Text } from 'react-native';
import { ICustomTheme, ThemeProvider, pallets, useThemeContext } from '@humayunkabir/react-native-theme';

const theme: ICustomTheme = {
  colors: {
    primary: pallets.indigo,
  },
  typography: {
    fonts: {
      heading: 'Montserrat-Regular',
      body: 'Poppins-Regular',
      mono: 'FiraCode-Regular',
    },
    fontWeights: {
      Thin: {
        fontFamily: 'Poppins-Thin',
      },
      ExtraLight: {
        fontFamily: 'Poppins-ExtraLight',
      },
      Light: {
        fontFamily: 'Poppins-Light',
      },
      Regular: {
        fontFamily: 'Poppins-Regular',
      },
      Medium: {
        fontFamily: 'Poppins-Medium',
      },
      SemiBold: {
        fontFamily: 'Poppins-SemiBold',
      },
      Bold: {
        fontFamily: 'Poppins-Bold',
      },
      ExtraBold: {
        fontFamily: 'Poppins-ExtraBold',
      },
      Black: {
        fontFamily: 'Poppins-Black',
      },
    },
  },
};

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

function App() {
  const {
    colors,
    getColor,
    typography,
    getFont,
    getFontSize,
    getFontWeight,
    getTypo,
    shadows,
    getShadow,
  } = useThemeContext();

  return (
    <View 
      style={[
        {backgroundColor: getColor('secondary', '800')},
        getShadow('lg')
      ]}
    >
      <Text
        style={[
          {color: getColor('primary', '600')},
          getFontWeight('SemiBold'),
        ]}>
        React Native Theme
      </Text>
    </View>
  );
}

Methods

Exported methods from useThemeContext are following:

  • getColor: getColor(color, shade)
    • color: primary*, secondary, success, danger, warning, info
    • shade: 50, 100, 200, 300, 400, 500*, 600, 700, 800, 900, 950
  • getFont: getFont(font)
    • font: heading, body*, mono
  • getFontSize: getFontSize(size)
    • size: xs, sm, base*, lg, xl, 2xl, 3xl, 4xl, 5xl, 6xl, 7xl, 8xl, 9xl
  • getFontWeight: getFontWeight(weight)
    • weight: Thin, ExtraLight, Light, Regular*, Medium, SemiBold, Bold, ExtraBold, Black
  • getTypo: getTypo(size, weight, font)
    • size: xs, sm, base*, lg, xl, 2xl, 3xl, 4xl, 5xl, 6xl, 7xl, 8xl, 9xl
    • weight: Thin, ExtraLight, Light, Regular*, Medium, SemiBold, Bold, ExtraBold, Black
    • font: heading, body*, mono
  • getShadow: getShadow(size, color, customShadow)
    • size: sm, base*, md, lg, xl, 2xl;
    • color: any valid color (default: #000)
    • customShadow:
      {
        width?: number;
        height?: number;
        opacity?: number;
        radius?: number;
        elevation?: number;
      }

Note: * mark is used to denote default value.

Values

Exported values from useThemeContext are followings:

  • colors: primary, secondary, success, danger, warning, info
    {
      primary: {
        50: 'colorValue',
        100: 'colorValue',
        200: 'colorValue',
        300: 'colorValue',
        400: 'colorValue',
        500: 'colorValue',
        600: 'colorValue',
        700: 'colorValue',
        800: 'colorValue',
        900: 'colorValue',
        950: 'colorValue',
      }
      ...
    }
  • typography: fonts, fontSizes, fontWeights
    • fonts: heading, body*, mono
    • fontSizes: xs, sm, base*, lg, xl, 2xl, 3xl, 4xl, 5xl, 6xl, 7xl, 8xl, 9xl
    • fontWeights: Thin, ExtraLight, Light, Regular*, Medium, SemiBold, Bold, ExtraBold, Black
    {
      fonts: {
        heading: 'Font Name',
        ...
      },
      fontSizes: {
        'xs': {
          fontSize: 12,
          lineHeight: 16,
        },
        ...
      },
      fontWeights: {
        Thin: {
          fontWeight: '100',
        },
        ...
      },
    }
  • shadows: sm, base, md, lg, xl, 2xl
    {
      'sm': {
        shadowOffset: {
          width: 0,
          height: 1,
        },
        shadowOpacity: 0.05,
        shadowRadius: 1,
        elevation: 1,
      },
      ...
    }

Pallets

This Includes an expertly-crafted default color palette out-of-the-box that is a great starting point if you don’t have your own specific branding in mind. They are following: slate, gray, zinc, neutral, stone, red, orange, amber, yellow, lime, green, emerald, teal, cyan, sky, blue, indigo, violet, purple, fuchsia, pink, rose

{
  slate: {
    50: '#f8fafc',
    100: '#f1f5f9',
    200: '#e2e8f0',
    300: '#cbd5e1',
    400: '#94a3b8',
    500: '#64748b',
    600: '#475569',
    700: '#334155',
    800: '#1e293b',
    900: '#0f172a',
    950: '#020617',
  }
  ...
}

PalletsCredit: TailwindCSS

License

MIT


Made with create-react-native-library