Socket
Socket
Sign inDemoInstall

@microsoft/arbutus.style-utilities

Package Overview
Dependencies
13
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @microsoft/arbutus.style-utilities

Collection of utilities for styling with Griffel.


Version published
Weekly downloads
5
decreased by-83.87%
Maintainers
1
Created
Weekly downloads
 

Readme

Source

Style: Utilities

Collection of utilities for styling with Griffel.

Get Started

npm i @microsoft/arbutus.style-utilities

Usage

mapToStyles

mapToStyles is designed to help generating styles variants. It generates Griffel classes from a map of values.

import { mapToStyles } from "@microsoft/arbutus.style-utilities";
Parameters
  • map An object, where the key will become a class name, and the value will be passed to the styleFunction.
  • styleFunction A function that takes the value from the map and returns a GriffelStyle.
Returns

An object with keys from the map and values as GriffelStyle returned by the styleFunction.

Example
Step 1: Create a map of variants for your component.
type ColorValue = string;
const textColors = { primary: 'red', secondary: 'blue' }
const textStyleFunction = (color: ColorValue) => ({
  color,
  '&:visited': { color }
})
const textColorClasses = mapToStyles<ColorValue, typeof textColors>(textColors, textStyleFunction);
// Output
// {
//   primary: {
//     color: 'red',
//     '&:visited: { color: 'red'}}
//   },
//   secondary: {
//     color: 'blue',
//     '&:visited: { color: 'blue'}}
//   },
// }
Step 2: Pass to the makeStyles() function.

FAQs

Last updated on 16 Mar 2023

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc