A place where OpenTable engineers and designers openly work together
Switch branches/tags
theo-cli@0.0.6 theo-cli@0.0.5 theo-cli@0.0.4 theo-cli@0.0.3 theo-cli@0.0.2 style-guide@0.0.8 style-guide@0.0.7 style-guide@0.0.6 style-guide@0.0.5 style-guide@0.0.4 style-guide@0.0.3 ottheme-spacing@1.0.4 ottheme-spacing@1.0.3 ottheme-spacing@1.0.2 ottheme-spacing@1.0.1 ottheme-colors@1.2.1 ottheme-colors@1.2.0 ottheme-colors@1.1.2 ottheme-colors@1.1.1 ottheme-colors@1.0.5 ottheme-colors@1.0.3 ottheme-colors@1.0.2 ottheme-colors@1.0.1 otkit-typography@2.0.1 otkit-typography@2.0.0 otkit-typography@1.0.2 otkit-typography@1.0.1 otkit-typography-desktop@3.1.0 otkit-typography-desktop@3.0.0 otkit-typography-desktop@2.1.0 otkit-typography-desktop@2.0.0 otkit-typography-desktop@1.1.0 otkit-typography-desktop@1.0.1 otkit-typography-desktop@1.0.0 otkit-ticketing-desktop@1.0.0 otkit-spacing@2.0.2 otkit-spacing@2.0.1 otkit-spacing@2.0.0 otkit-spacing@1.0.2 otkit-spacing@1.0.1 otkit-shadows@1.0.3 otkit-shadows@1.0.0 otkit-icons@4.10.0 otkit-icons@4.9.0 otkit-icons@4.8.0 otkit-icons@4.7.0 otkit-icons@4.6.0 otkit-icons@4.5.0 otkit-icons@4.4.0 otkit-icons@4.3.0 otkit-icons@4.2.0 otkit-icons@4.1.0 otkit-icons@4.0.0 otkit-icons@3.1.0 otkit-icons@3.0.0 otkit-icons@2.1.0 otkit-icons@2.0.0 otkit-icons@1.1.0 otkit-icons@1.0.1 otkit-icons@0.2.1 otkit-icons@0.2.0 otkit-icons@0.1.2 otkit-icons@0.1.0 otkit-desktop-typography@2.0.1 otkit-desktop-typography@2.0.0 otkit-colors@3.1.0 otkit-colors@2.2.2 otkit-colors@2.2.1 otkit-colors@2.2.0 otkit-colors@2.1.0 otkit-colors@2.0.2 otkit-colors@2.0.0 otkit-colors@1.0.2 otkit-colors@1.0.1 otkit-breakpoints@4.0.2 otkit-breakpoints@4.0.1 otkit-breakpoints@4.0.0 otkit-breakpoints@3.0.0 otkit-breakpoints@2.0.2 otkit-breakpoints@2.0.1 otkit-breakpoints@2.0.0 otkit-breakpoints@1.0.6 otkit-breakpoints@1.0.5 otkit-breakpoints@1.0.4 otkit-breakpoints@1.0.3 otkit-borders@1.0.3 otkit-borders@1.0.0 delete
Nothing to show
Clone or download

README.md

design-tokens

Design Tokens repository is the central location to store shared design attributes such as colors, fonts, widths, animations, etc. These attributes can then be transformed and formatted to meet the needs of different projects, teams and platforms.


Table of Contents generated with DocToc

Project structure

A token is a set of design attributes bundled together around a common theme.

We have two sets of design tokens available to consume.

OTKit

Standard design tokens. Use them if you are following the new design guidelines.

Token Available Formats Version
otkit-borders scss, cssmodules.css, common.js npm version
otkit-breakpoints scss, cssmodules.css, common.js npm version
otkit-colors scss, cssmodules.css, common.js npm version
otkit-icons scss, cssmodules.css npm version
otkit-shadows scss, cssmodules.css, common.js npm version
otkit-spacing scss, cssmodules.css, common.js npm version
otkit-typography (DEPRECATED) scss, cssmodules.css, common.js npm version
otkit-typography-desktop scss, cssmodules.css, common.js npm version

OTTheme

Legacy design tokens. Use them if you need the classic look and feel of OpenTable Theme.

Token Available Formats Version
ottheme-colors scss, cssmodules.css, common.js npm version
ottheme-spacing scss, cssmodules.css, common.js npm version

Usage

Install the token

$ npm install --save-dev <token-name>

Use the token

A Token exposes multiple available formats (listed above). The format needs to be explicitly referenced upon requiring/importing the token:

require('<token-name>/token.<format>')

Example: using different formats

// cssmodules example:
@value color-primary from 'otkit-colors/token.cssmodules.css';

// common.js require/import examples:
const color = require('otkit-colors/token.common.js');
import color from 'otkit-colors/token.common.js';

// scss example:
@import '../node_modules/ottheme-colors/token.scss';

Example: set your base font size

@value font-size-base from 'otkit-typography/token.cssmodules.css';

html {
  font-size: font-size-base;
}

Pixel to Rem conversion

All contributions to this project should be in pixels. For users of these tokens, you will have to install postcss-pxtorem to handle the pixel to rem conversion in your CSS files.

npm install --save-dev postcss-pxtorem

Then add it to your postcss processors with the following recommended configuration:

import pxtorem from 'postcss-pxtorem';
import { fontSizeBase } from 'otkit-typography/token.cssmodules.css';

const processors = [
  pxtorem({
    // fontSizeBase = '16px'.  Need to convert to 16.
    rootValue: parseInt(fontSizeBase, 10),
    selectorBlackList: [/^html$/],
    replace: true
  })
];

Note that depending on how you use postcss, your processors array may be in a JSON configuration file instead.

If you're not already using postcss, you will either have to use it as an additional build step after you transform your CSS with your current tool or use it as a complete replacement for your current CSS transformation process.

Development

Preview and debug

Executing npm run build will generate the token values in each token's folder, such as token.scss or other available formats you specified.

When you publish a token (more on that below), this step is executed as part of the publishing.

If you are using a token in your project, you can execute npm link '<token-name>' in node_modules folder to test the token values before publishing.


Contribution

Please refer to the contributing doc