Package detail

@devtools-ds/themes

intuit1.2mMIT1.2.1

Each of the UI components in this project contains themes for multiple browsers. These themes are built using the postcss-themed package, which allows us to specify themes for multiple browsers in light and dark

readme

@devtools-ds/themes

Each of the UI components in this project contains themes for multiple browsers. These themes are built using the postcss-themed package, which allows us to specify themes for multiple browsers in light and dark mode.

This package contains colors, types, and React utilities for using browser themes.

Installation

npm i @devtools-ds/themes
# or with yarn
yarn add @devtools-ds/themes

Examples

ThemeProvider

You can use the ThemeProvider component to set the theme for all @devtools-ds components underneath it.

import { ThemeProvider } from "@devtools-ds/themes";

<ThemeProvider theme={"chrome"} colorScheme={"light"}>
  <YourApp />
</ThemeProvider>;

AutoThemeProvider

We also provide an AutoThemeProvider, which will automatically set the theme and color scheme of @devtools-ds components based on the users browser and preferred color scheme.

<AutoThemeProvider>
  <div id="my-app">
    <ObjectInspector />
  </div>
</AutoThemeProvider>

You can always override the AutoThemeProvider like a normal ThemeProvider.

<AutoThemeProvider theme="firefox">
  <div id="my-app">
    <ObjectInspector />
  </div>
</AutoThemeProvider>

You can also have the AutoThemeProvider automatically change the background color and text color to match the current browser and color scheme. In dark mode, this means the background color will be the browser's dark background and light text.

<AutoThemeProvider autoStyle>
  <div id="my-app">
    <ObjectInspector />
  </div>
</AutoThemeProvider>

useTheme

If you want to build your own component that leverages the ThemeProvider, we have a hook that allows you to get the current theme.

import { useTheme } from "@devtools-ds/themes";

const { currentTheme, currentColorScheme } = useTheme(
  { theme, colorScheme },
  styles
);

Variables

We have created a number of theme variables that have the common colors for different browsers. These are stored as JS objects. You can view the available variables in the Browser Themes story in Storybook.

import { chrome, firefox } from "@devtools-ds/themes";

chrome.light.gray01;
firefox.dark.blue02;

changelog

v1.2.0 (Fri Apr 22 2022)

:tada: This release contains work from a new contributor! :tada:

Thank you, Adrian de la Rosa (@mormubis), for all your work!

🚀 Enhancement

🐛 Bug Fix

Authors: 2


v1.0.4 (Sun Apr 25 2021)

:tada: This release contains work from a new contributor! :tada:

Thank you, Andrew Lisowski (@hipstersmoothie), for all your work!

🐛 Bug Fix

Authors: 1


v1.0.3 (Thu Feb 25 2021)

🐛 Bug Fix

Authors: 1


v1.0.0 (Tue Feb 02 2021)

💥 Breaking Change

🐛 Bug Fix

Authors: 1


v0.130.5 (Sun Jan 24 2021)

⚠️ Pushed to master

Authors: 1


v0.130.4 (Sun Jan 24 2021)

⚠️ Pushed to master

Authors: 1


vnull (Sun Jan 24 2021)

🐛 Bug Fix

  • Bump version to: v0.130.1 [skip ci] (tylerkrupicka@gmail.com)

⚠️ Pushed to master

  • set access in package json (tylerkrupicka@gmail.com)

Authors: 1

  • Tyler Krupicka (tylerkrupicka@gmail.com)