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

@team-devmonster/react-theme

v1.4.3

Published

This is devmonster's react module for make app easily. This is compatible with devmonster's react-native module.

Downloads

3

Readme

@team-devmonster/react-theme

react-theme was created to easily create a theme in the react environment. Darkmode compatibility is also easy. You can use it in the nextjs environment.

This is under devmonster's react & react-native union project.

This project is part of the react-module & react-native-module projects, that integrate react & react-native by the devmonster team. react-native => @team-devmonster/react-native-theme General react-modules load map => here; General react-native-modules load map => here;

Other react modules

author: devmonster

We are always looking for investment or assistance. hompage: https://devmonster.co.kr email: [email protected]

Getting started

$ npm install @team-devmonster/react-theme@latest

Examples

Easy. Too Easy.

step1. Make Color & Theme

Set Colors & Themes whatever anything you want to use.

// App.theme.tsx => You can use any file name :)
const color = {
  light: {
    // key colors
    primary: '#4a93cf',
    warning: '#ec670b',
    success: '#9cca5a',
    danger: '#eb445a',
    placeholder: '#4d4d4d',
    backgroundColor: '#f2f2f2',
    // color steps
    white: '#ffffff',
    step50: '#f2f2f2',
    step100: '#e6e6e6',
    step200: '#cccccc',
    step300: '#b3b3b3',
    step400: '#999999',
    step500: '#808080',
    step600: '#666666',
    step700: '#4d4d4d',
    step800: '#333333',
    step900: '#191919',
    black: '#111111'
  },
  dark: {
    // key colors
    primary: '#4a93cf',
    warning: '#ec670b',
    success: '#9cca5a',
    danger: '#eb445a',
    placeholder: '#4d4d4d',
    backgroundColor: '#191919',
    // color steps
    white: '#111111',
    step50: '#191919',
    step100: '#333333',
    step200: '#4d4d4d',
    step300: '#666666',
    step400: '#808080',
    step500: '#999999',
    step600: '#b3b3b3',
    step700: '#cccccc',
    step800: '#e6e6e6',
    step900: '#f2f2f2',
    black: '#ffffff'
  }
}

const theme = (color:Color) => {
  const fontSize = {
    xs: 12,
    sm: 13,
    base: 15,
    lg: 16,
    xl: 17,
    x2l: 19,
    x3l: 21
  }
  const { width } = useWindowSize();
  if(width >= container.mobile) {
    fontSize.base = 15;
    fontSize.lg = 16;
    fontSize.xl = 22;
    fontSize.x2l = 28;
    fontSize.x3l = 36;
  }

  const input = {
    position: 'relative',
    backgroundColor: color.white,
    borderColor: color.step300,
    color: color.black,
    borderRadius: 5,
    borderWidth: 1,
    fontSize: fontSize.base,
    paddingTop: 10,
    paddingBottom: 10,
    paddingLeft: 10,
    paddingRight: 10,
    minHeight: 42,
    flex: 1
  }
  const inputError = {
    borderColor: color.warning
  }
  const inputDisabled = {
    backgroundColor: color.step100,
    borderColor: color.step200
  }

  const button = {
    cursor: 'pointer',
    position: 'relative',
    padding: 10,
    alignItems: 'center',
    justifyContent: 'center',
    fontSize: fontSize.base,
    minHeight: 42,
    borderRadius: 5
  }

  return {
    // basic theme
    color, fontSize, 
    // components theme
    input, inputError, inputDisabled,
    button
  }
}

export type Color = typeof color.light;
export type ColorKeys = keyof Color;
export type Theme = ReturnType<typeof theme>;

step2. Set Provider

// App.theme.tsx => You can use any file name :)
import { ThemeProvider } from '@team-devmonster/react-theme';

export const AppThemeProvider = ({children}: {children:React.ReactNode}) => {
  return (
    <ThemeProvider color={color} theme={theme}>
      {children}
    </ThemeProvider>
  )
}
import { AppThemeProvider } from './App.theme';

export default function App() {

  return (
    <AppThemeProvider>
      <Component></Component>
    </AppThemeProvider>
  )
}

step3. Use

import React from "react";
import { useTheme } from '@team-devmonster/react-theme';
import { Theme } from './App.theme';

const ThemeEx = () => {

  const { color, fontSize } = useTheme<Theme>();

  return (
    <div 
      style={{ 
        backgroundColor: color.white, 
        flex: 1, 
        flexDirection: 'row', 
        paddingTop: 18, 
        paddingBottom: 18 
      }}>
      <div style={{ backgroundColor: color.primary, ...style.boxStyle }}>
        <div style={{ color: color.black, fontSize: fontSize.sm }}>primary</div>
      </div>
      <div style={{ backgroundColor: color.danger, ...style.boxStyle }}>
        <div style={{ color: color.black, fontSize: fontSize.sm }}>danger</div>
      </div>
    </div>
  )
}

const style = {
  boxStyle: {
    width: 80, 
    height: 80, 
    margin: 8,
    alignItems: 'center',
    justifyContent: 'center'
  }
}

export default ThemeEx;

extra1. colorScheme

Also you can use colorScheme. It is light or dark.

import { useTheme } from '@team-devmonster/react-theme';
import { Theme } from './App.theme';

import ImgWhite from '@Img/imgWhite.png';
import ImgDark from '@Img/imgDark.png';

const ThemeEx = () => {

  const { colorScheme } = useTheme<Theme>();

  return (
    <div>
      <img src={colorScheme === 'light' ? ImgWhite : ImgDark}>
    </div>
  )
}
export default ThemeEx;

extra2. => CSS property

You can use style in user css property. Property name's rule is --${ColorKey}.

::placeholder {
  color: var(--placeholder);
}
html,
body {
  background-color: var(--backgroundColor);
}

extra3. => color utils

Sometimes we should use lighter, darker, or invert colors. So this library offers some utils.

import { useTheme, darken, lighten, hexToRgb, contrast } from "@local_modules/theme";
import { Theme } from "App.theme";

const ThemeEx = () => {

  const { color, fontSize } = useTheme<Theme>();

  return (
    <div>
      <div style={{ backgroundColor: lighten(color.primary, 50), ...shadow.base, ...style.boxStyle }}>
        <div style={{ color: contrast(color.primary), fontSize: fontSize.sm }}>primary lighter 50</div>
      </div>
      <div style={{ backgroundColor: darken(color.danger, 50), ...shadow.lg, ...style.boxStyle }}>
        <div style={{ color: contrast(color.danger), fontSize: fontSize.sm }}>danger darken 50</div>
      </div>
      <div style={{ backgroundColor: darken(color.step200, 50), ...style.boxStyle }}>
        <div style={{ color: contrast(color.step200), fontSize: fontSize.sm }}>step200 hex:{color.step200} <br></br> rgb: {hexToRgb(color.step200)}</div>
      </div>
    </div>
  )
}
const style = {
  boxStyle: {
    width: 80,
    height: 80, 
    margin: 8,
    alignItems: 'center',
    justifyContent: 'center'
  }
}