Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up

A CLI toolkit for aiding design tokens adoption.

License

NotificationsYou must be signed in to change notification settings

michaelmang/tempera

Repository files navigation

tempera

A CLI toolkit for aiding design tokens adoption.

View Docs

OclifNetlify StatusVersionDownloadsDownloads

Usage

Install

$npm install -g tempera$yarn add global tempera

Run Commands

Note: This package is experimental. You may have better success by running the command locally:

USAGE  $ git clone https://github.com/michaelmang/tempera.git  $ yarn install  $ ./bin/run [COMMAND]

Scorecard

Gather metrics around the adoption of a design system.

USAGE  $ tempera scorecard -s https://www.figma.com/developers -t ./tokens.jsOPTIONS  -s, --site=site  site url to analyze  -t, --tokens=tokens  relative path to tokens file  -j, --json=json  (optional) flag to enable printing output as a JSON blob; requires -o, --output to be set  -o, --output=output  (optional) relative path for a JSON file to output; requires -j, --json to be enabledDESCRIPTION  ...  Scorecard analyzes a web app or web page,  collecting design system adoption metrics  and insights for adoption.

Tokens

Design tokens are key-value pairs that represent a specification (aka "spec") of a design system.

If you are new to design tokens,here's a good place to start.

Tempera'sscorecard command expects these tokens to be in thejavascript/es6 format which you can generate using Style Dictionary except exported as CommonJS modules.

In other words, flat CommonJS modules in PascalCase are expected.

Example:

module.exports.ColorBackgroundBase="#ffffff";module.exports.ColorBackgroundAlt="#fcfcfcfc";

Support for tokens in ES6 format is on the roadmap.

Thescorecard command expects the tokens to match against one of the following matchers after being transformed to kebab case:

module.exports.BORDER_RADIUS=/border-radius/g;module.exports.BREAKPOINT=/max-width/g;module.exports.COLOR=/color/g;module.exports.DELAY=/delay/g;module.exports.DURATION=/duration/g;module.exports.FONT_FAMILY=/font-family/g;module.exports.FONT_SIZE=/font-size/g;module.exports.FONT_WEIGHT=/font-weight/g;module.exports.LINE_HEIGHT=/line-height/g;module.exports.SPACING=/margin|padding/g;module.exports.TIMING=/timing/g;

You can learn more about the underlyingcss-types package that utilizes these matchers.

Output

design-scorecard

JSON Report

Useful for creating custom reporters and tooling.

USAGE  $ tempera scorecard -s https://www.figma.com/developers -t ./tokens.js -j -o report.json
Output
{"unofficial":[{"type":"border-radius","attribute":"border-radius","unofficialValue":"0.500rem","nearestOfficialValue":"0.375rem"},// ...],"summary":[{"category":"Font Family","correct":0,"incorrect":79,"percentage":"0.00"},{"category":"Color","correct":159,"incorrect":195,"percentage":"44.92"},{"category":"Font Size","correct":73,"incorrect":104,"percentage":"41.24"},{"category":"Spacing","correct":264,"incorrect":322,"percentage":"45.05"},{"category":"Max Width","correct":1,"incorrect":25,"percentage":"3.85"},{"category":"Line Height","correct":112,"incorrect":14,"percentage":"88.89"},{"category":"Border Radius","correct":16,"incorrect":13,"percentage":"55.17"},{"category":"Font Weight","correct":78,"incorrect":2,"percentage":"97.50"}],"total":{"correct":703,"incorrect":754,"percentage":"48.25","grade":"F"}}

Help

$tempera --help [COMMAND]USAGE  $ tempera COMMAND

Contributing

🤠 Howdy, developer! Thanks for being willing to contribute!

Project setup

  1. Fork and clone the repo
  2. Runyarn install to install dependencies
  3. Create a branch for your PR withgit checkout -b pr/your-branch-name
  4. Run.bin/run/ [COMMAND] in the root of the repo to run commands locally

Tip: Keep yourmaster branch pointing at the original repository and makepull requests from branches on your fork. To do this, run:

git remote add upstream https://github.com/michaelmang/tempera.gitgit fetch upstreamgit branch --set-upstream-to=upstream/master master

Committing and Pushing changes

There are currently no tests but please document manual testing on PRs with your changes.

Help needed

Please checkout thethe open issues.

Also, please watch the repo and respond to questions/bug reports/featurerequests! Thanks!

Packages

Tools

In addition to a CLI, Tempera offers other tools to improve design tokens adoption.

stylelint-tokens

A Stylelint plugin that helps avoid the adoption of unofficial design specifications.

Installation

yarn add @tempera/stylelint-tokens

Usage

InstallStylelint and update your configuration file to utilize the plugin.

// stylelint.config.jsconsttokens=require("./fixtures/example-tokens");module.exports={// ...plugins:["@tempera/stylelint-tokens"],rules:{"@tempera/official-specs":tokens,},};
Tokens

The plugin expects these tokens to be in thejavascript/es6 format which you can generate using Style Dictionary except exported as CommonJS modules.

In other words, flat CommonJS modules in PascalCase are expected.

Example:

module.exports.ColorBackgroundBase="#ffffff";module.exports.ColorBackgroundAlt="#fcfcfcfc";

Support for tokens in ES6 format is on the roadmap.

View the source

Supporting Packages

The underlying packages that support Tempera are publicly accessible.

You are welcome and encouraged to use these packages directly should you need a custom solution.

🚀Contributing to these packages is also welcome.

css-types

Utilities to categorize your CSS.

Installation

yarn add @tempera/css-types

Usage

const{// Example: matchers.SPACING// Contains a list of regex matchers to help match common types in CSS  matchers,// example: getMatcher(postcssProperty)// Returns a regex matcher fitting for the provided property  getMatcher,// Example: types.SPACING// Contains a list of common types in CSS  types,// Example: getType(postcssProperty)// Returns a common type fitting for the provided property  getType,}=require("@tempera/css-types");

View the source

postcss-scorecard

A PostCSS plugin that exposes hooks into design token adoption validation.

Installation

yarn add @tempera/postcss-scorecard

Usage

constpxToRem=require("postcss-pxtorem");constexpandShorthand=require("postcss-shorthand-expand");awaitpostcss().use(pxToRem()).use(expandShorthand).use(scorecard({onInvalid:(score)=>{// do something when CSS property is not an official spec},onValid:(score)=>{// do something when CSS property is an official spec},onFinished:()=>{// do something after validation finishes},      specs,// the official design tokens})).process(css,{from:undefined});
Specs

The plugin expects these specs/tokens to be in thejavascript/es6 format which you can generate using Style Dictionary except exported as CommonJS modules.

In other words, flat CommonJS modules in PascalCase are expected.

Example:

module.exports.ColorBackgroundBase="#ffffff";module.exports.ColorBackgroundAlt="#fcfcfcfc";

Support for tokens in ES6 format is on the roadmap.

View the source

tailwind-config

An API that generates a Tailwind configuration from a set of design tokens.

Installation

yarn add @tempera/tailwind-config

Usage

importgetTailwindConfigfrom"@tempera/tailwind-config";consttailwindConfig=getTailwindConfig(tokens);// do something with the tailwind config
Tokens

The plugin expects these specs/tokens to be in thejavascript/es6 format which you can generate using Style Dictionary.

In other words, flat modules in PascalCase are expected.

Example:

exportconstColorPrimary=blue;exportconstColorSecondary=yellow;

View the source

twind

An API that generates a Twind instance from a set of design tokens.

Installation

yarn add @tempera/twind

Usage

importgetTwindfrom"@tempera/twind";const{ tw}=getTwind(tokens);functionDemo(){return(<divclassName={tw`text-primary`}>  );}
Tokens

The plugin expects these specs/tokens to be in thejavascript/es6 format which you can generate using Style Dictionary.

In other words, flat modules in PascalCase are expected.

Example:

exportconstColorPrimary=blue;exportconstColorSecondary=yellow;

View the source

stitches

An API that generates twind/style shapes from a set of design tokens.

Demo

View On CodeSandbox

Installation

yarn add @tempera/stitches

Usage

importgetStitchesfrom'@tempera/stitches';importgetTwindfrom'@tempera/twind';import{style}from'twind/style';importtokensfrom'./tokens';conststitches=getStitches(tokens);const{ tw}=getTwind(tokens);functionDemo(){constbutton=style(stitches.button);return(<div><buttonclassName={tw(button())}>Base Button</button><buttonclassName={tw(button({variant:'secondary'}))}>        Secondary Button</button></div>);}
Tokens

The plugin expects these specs/tokens to be in thejavascript/es6 format which you can generate using Style Dictionary.

In other words, flat modules in PascalCase are expected.

The tokens should follow the following format:

// base formatexportconstComponent[COMPONENT]Base[LONGHAND_CSS_PROPERTY];// size formatexportconstComponent[COMPONENT][SIZE][LONGHAND_CSS_PROPERTY];// variant formatexportconstComponent[COMPONENT][VARIANT][UI_STATE][LONGHAND_CSS_PROPERTY];

Examples:

exportconstComponentButtonBaseFontSize='1rem';exportconstComponentButtonBaseColor='red';exportconstComponentButtonSmallFontSize='0.75rem';exportconstComponentButtonSecondaryDefaultBackgroundColor='red';exportconstComponentButtonSecondaryDefaultColor='white';exportconstComponentButtonSecondaryDefaultFontSize='0.875rem';exportconstComponentButtonSecondaryHoverFontSize='0.75rem';exportconstColorPrimary='red';exportconstColorWhite='white';exportconstFontSizeTiny='0.75rem';exportconstFontSizeSmall='0.875rem';exportconstFontSizeMedium='1rem';exportconstLineHeightTiny='1rem';exportconstLineHeightSmall='1.25rem';exportconstLineHeightMedium='1.5rem';

View the source

About

A CLI toolkit for aiding design tokens adoption.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

[8]ページ先頭

©2009-2025 Movatter.jp