0.10.0 • Published 9 months ago

react-base16-styling v0.10.0

Weekly downloads
431,299
License
MIT
Repository
github
Last release
9 months ago

react-base16-styling Latest Stable Version

React styling with base16 color scheme support

Inspired by react-themeable, this utility provides flexible theming for your component with base16 theme support.

Install

yarn add react-base16-styling

Usage

import { createStyling } from 'react-base16-styling';
import base16Themes from './base16Themes';

function getStylingFromBase16(base16Theme) {
  return {
    myComponent: {
      backgroundColor: base16Theme.base00,
    },

    myComponentToggleColor({ style, className }, clickCount) {
      return {
        style: {
          ...style,
          backgroundColor: clickCount % 2 ? 'red' : 'blue',
        },
      };
    },
  };
}

const createStylingFromTheme = createStyling(getStylingFromBase16, {
  defaultBase16: base16Themes.solarized,
  base16Themes,
});

class MyComponent extends Component {
  state = { clickCount: 0 };
  render() {
    const { theme } = this.props;
    const { clickCount } = this.state;

    const styling = createStylingFromTheme(theme);

    return (
      <div {...styling('myComponent')}>
        <a onClick={() => this.setState({ clickCount: clickCount + 1 })}>
          Click Me
        </a>
        <div {...styling('myComponentToggleColor', clickCount)}>
          {clickCount}
        </div>
      </div>
    );
  }
}

createStyling

function(getStylingFromBase16, defaultStylingOptions, themeOrStyling)
ArgumentSignatureDescription
getStylingFromBase16function(base16Theme)creates object with default stylings for your component, using provided base16 theme.
defaultStylingOptions{ defaultBase16, base16Themes }optional parameters, allow to set default base16 theme and additional base16 themes for component.
themeOrStylingstring or objectbase16 theme name, base16 theme object or styling object. Theme name can have a modifier: "themeName:inverted" to invert theme colors (see [#invertTheme])

Styling object values could be: - objects (treated as style definitions) - strings (class names) - functions (they may be provided with additional parameters and should return object { style, className })

getBase16Theme

function(themeOrStyling, base16Themes)

Helper method that returns base16 theme object if themeOrStyling is base16 theme name or theme object.

invertBase16Theme

function(base16Theme)

Helper method that inverts base16 theme colors, creating light theme out of dark one or vice versa.

invertTheme

function(theme)

Helper method that inverts a theme or styling object to be passed into the themeOrStyling parameter of createStyling.

@marketmuse/redux-devtools-inspectorredux-devtools-inspector-maintainedreact-json-tree-testing@dxos/react-json-tree@grapherjs/react-json-view@infinitebrahmanuniverse/nolb-react-ba@everything-registry/sub-chunk-2541@seesemichaelj/react-json-viewtariff-react-json-viewreactotron-appseacrest-react-json-viewsearchable-react-json-node-viewsearchable-react-json-viewremotedev-inspector-monitorremotedev-inspector-monitor-support-navigatiomvalue-mirror-inspectorvitra-react-json-viewmobx-react-json-treelm-json-treejson-view-sdkjson-view-linkagelp-rjvjson-data-viewjotai-devtoolspraesentiumnecessitatibuspolicy-managerredux-devtools-inspector-check-type-fixreact-day-picker-themeablereact-entity-managerreact-extreme-json-viewreact-input-enhancementsreact-object-editorrc-json-viewreact-native-redux-devtoolsreact-native-json-treereact-native-logger-fastreact-json-explorerreact-json-treereact-json-tree-asyncanupreact-json-tree-editablereact-json-view-keywordreact-json-view-repairreact-json-view-ssrreact-json-view-tsreact-json-view-with-togglereact-json-view-xreact-json-view-c2react-json-view-callbackreact-json-view-commonreact-json-view-enhancedreact-json-view-extendedreact-json-view-forkreact-json-view-highlightingreact-json-view-key-selectreact-json-viewreact-json-view-18react-json-view-2react-json-view-antdreact-json-tree-pravidhareact-json-tree-with-onexpandreact-json-tree-zavattaredux-devtools-inspector-ie8redux-devtools-inspector2redux-devtools-inspectorredux-inspector-monitorrjview@ark-us/react-json-view@arokiajustus/searchable-json-node-react@akshays/react-json-view@aliyun-sls/react-json-tree@adileo/react-json-view@a-b-r-o-w-n/react-json-view@quarks/magnetron-dm-viewer@darwin808/search-json-viewerxtrailai-react-json-view@heliosphere/react-json-view@hanzo/react-json-view@henok_g_d/react-json-view@ganache/react-json-view@ggascoigne/react-json-view@lucataglia/react-json-tree@microlink/react-json-view@mfellner/react-json-tree@matpool/vue-json-view@neonfuz/react-json-view@meetelise/searchable-react-json-view@jimpick/preact-json-tree@img-arena/img-ui-mui-theme@img-arena/ui-core@rwdt/react-json-view@rafaelsilva81/react-json-view@redux-devtools/inspector-monitor@redux-devtools/inspector-monitor-trace-tab@redux-devtools/log-monitor@redux-devtools/rtk-query-monitor@redux-devtools/slider-monitor@redux-devtools/ui@redux-devtools/chart-monitor@onshinpei/react-json-view@openfn/react-json-view
0.10.0

9 months ago

0.9.0

3 years ago

0.9.1

3 years ago

0.8.2

3 years ago

0.8.1

3 years ago

0.8.0

4 years ago

0.7.0

4 years ago

0.6.0

7 years ago

0.5.3

8 years ago

0.5.2

8 years ago

0.5.1

8 years ago

0.5.0

8 years ago

0.4.7

8 years ago

0.4.6

8 years ago

0.4.5

8 years ago

0.4.4

8 years ago

0.4.3

8 years ago

0.4.1

8 years ago

0.4.0

8 years ago

0.3.0

8 years ago

0.2.3

9 years ago

0.2.2

9 years ago

0.2.1

9 years ago

0.2.0

9 years ago

0.1.0

9 years ago