UNPKG

@primer/primitives

Version:

Typography, spacing, and color primitives for Primer design system

27 lines (26 loc) 1.48 kB
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } return new (P || (P = Promise))(function (resolve, reject) { function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); }; import { format } from 'prettier'; import { fileHeader, sortByName } from 'style-dictionary/utils'; /** * @description Converts `StyleDictionary.dictionary.tokens` to css with @custom-media * @param arguments [FormatterArguments](https://github.com/amzn/style-dictionary/blob/main/types/Format.d.ts) * @returns formatted `string` */ export const cssCustomMedia = (_a) => __awaiter(void 0, [_a], void 0, function* ({ dictionary, options: _options, file }) { // add file header const output = [yield fileHeader({ file })]; // add single theme css dictionary.allTokens.sort(sortByName).map(({ name, $value }) => { output.push(`@custom-media --${name} ${$value};`); }); // return prettified return format(output.join('\n'), { parser: 'css', printWidth: 500 }); });