This package has been deprecated

Author message:

This package is deprecated. Used @hig/theme-context instead.

@hig/themes-poc

1.0.0-alpha • Public • Published

ThemeContext component

Themable HIG components within a ThemeContext.Provider will have access to the provided theme.

Getting started

yarn add @hig/themes

Provide a theme to components

import HIGDarkBlueTheme from '@hig/theme-data-poc/build/darkBlueMediumDensity/theme.json';
import ThemeContext from '@hig/theme-context';

function MyApp() {
  <ThemeContext.Provider value={HIGDarkBlueTheme}>
    <TheRestOfMyApp />
  </ThemeContext.Provider>
}

Consume theme values in a component

import ThemeContext from '@hig/themes';

function MyThemedComponent() {
  <ThemeContext.Consumer>{({ resolvedRoles, name }) => (
    <div style={{
      backgroundColor: resolvedRoles["colorScheme.surfaceLevel20Color"],
      borderRadius: resolvedRoles["basics.borderRadii.small"],
      color: resolvedRoles["colorScheme.textColor"],
      padding: resolvedRoles["density.spacings.medium"],
    }}>
      The current theme is "{name}".
    </div>
  )}</ThemeContext.Consumer>
}

Readme

Keywords

none

Package Sidebar

Install

npm i @hig/themes-poc

Weekly Downloads

0

Version

1.0.0-alpha

License

Apache-2.0

Unpacked Size

18.9 kB

Total Files

5

Last publish

Collaborators

  • hig-bot
  • nfiniteset
  • staceyshk
  • wmui51