Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@microsoft/arbutus.style-utilities

Package Overview
Dependencies
Maintainers
2
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@microsoft/arbutus.style-utilities

Collection of utilities for styling with Griffel.

  • 1.0.4
  • latest
  • npm
  • Socket score

Version published
Maintainers
2
Created
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

Package last updated on 29 Nov 2023

Did you know?

Socket

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
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc