Skip to content

Commit

Permalink
rename type to tier
Browse files Browse the repository at this point in the history
  • Loading branch information
gossi committed Sep 21, 2021
1 parent e812977 commit 7b9201c
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 46 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
"esm": "3.2.25",
"figma-api": "^1.7.0",
"lodash.isempty": "^4.4.0",
"node-fetch": "^3.0.0",
"node-fetch": "~2.6.2",
"style-dictionary": "^3.0.2"
},
"devDependencies": {
Expand All @@ -75,7 +75,7 @@
"@types/jest-expect-message": "^1.0.3",
"@types/lodash.isempty": "^4.4.6",
"@types/mock-fs": "^4.13.1",
"@types/node-fetch": "^3.0.2",
"@types/node-fetch": "~2.5.12",
"@typescript-eslint/eslint-plugin": "^4.31.1",
"@typescript-eslint/parser": "^4.31.1",
"chokidar": "^3.5.2",
Expand Down
6 changes: 5 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,11 @@ main();
export default Theemo;

export type { default as TheemoConfig } from './config';
export type { default as Token, BaseToken, TokenType } from './token';
export type {
default as Token,
BaseToken,
TokenTier as TokenType
} from './token';

// config
export type { default as SyncConfig } from './sync/config';
Expand Down
8 changes: 4 additions & 4 deletions src/token.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@
* - {@link https://dev.to/ynab/a-semantic-color-system-the-theory-hk7
* | The Theory: A Semantic Color System (Carlin)}
*/
export enum TokenType {
export enum TokenTier {
/**
* The default token type is unknown, until classified by you
*/
Unknown = 'unknown',

/**
* A very low-level token type, e.g. a color of your palette
* A very low-level token tier, e.g. a color of your palette
*/
Basic = 'basic',

Expand Down Expand Up @@ -117,9 +117,9 @@ export interface BaseToken {
*/
export default interface Token extends BaseToken {
/**
* The type describes the usage level of a token
* The tier describes the usage level of a token
*/
type: TokenType;
tier: TokenTier;

/**
* The tokens computed value
Expand Down
6 changes: 3 additions & 3 deletions src/tools/figma/referencers/theemo-plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import Color from 'color';
import isEmpty from 'lodash.isempty';
import fetch from 'node-fetch';

import Token, { TokenType } from '../../../token';
import Token, { TokenTier } from '../../../token';
import { ColorConfig } from '../config';
import { FigmaToken, getValue, colorToValue } from '../token';
import Referencer from './referencer';
Expand Down Expand Up @@ -59,7 +59,7 @@ export default class TheemoPluginReferencer implements Referencer {

async setup(): Promise<void> {
if (!this.references) {
this.references = await this.load();
this.references = (await this.load()) as ReferenceDoc;
}
}

Expand Down Expand Up @@ -120,7 +120,7 @@ export default class TheemoPluginReferencer implements Referencer {
const computed: Token = {
name: token.name,
description: token.description,
type: TokenType.Unknown,
tier: TokenTier.Unknown,
category: token.category,
colorScheme: token.colorScheme,
reference: token.reference,
Expand Down
12 changes: 6 additions & 6 deletions test/fixtures/hokulea/theemo-config.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { TheemoConfig } from '../../../src';
import { TokenType } from '../../../src/token';
import Token, { TokenTier } from '../../../src/token';
import {
ColorAlphaFormat,
ColorFormat,
Expand All @@ -14,13 +14,13 @@ function pathForToken(token) {
return path;
}

function isTransient(token, tokens) {
function isTransient(token: Token, tokens) {
const hasColorSchemes = tokens.some(
t => t.colorScheme && t.name === token.name
);
const isReference = !token.colorScheme && hasColorSchemes;

return token.type === 'purpose' && isReference;
return token.tier === 'purpose' && isReference;
}

function isRatioScalingToken(name) {
Expand Down Expand Up @@ -150,9 +150,9 @@ export function makeHokuleaConfig({ dev = false } = {}): TheemoConfig {

classifyToken(token, tokens) {
const t = { ...token };
t.type = token.name.startsWith('.')
? TokenType.Basic
: TokenType.Purpose;
t.tier = token.name.startsWith('.')
? TokenTier.Basic
: TokenTier.Purpose;

// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
Expand Down
41 changes: 11 additions & 30 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1468,12 +1468,13 @@
dependencies:
"@types/node" "*"

"@types/node-fetch@^3.0.2":
version "3.0.3"
resolved "https://registry.yarnpkg.com/@types/node-fetch/-/node-fetch-3.0.3.tgz#9d969c9a748e841554a40ee435d26e53fa3ee899"
integrity sha512-HhggYPH5N+AQe/OmN6fmhKmRRt2XuNJow+R3pQwJxOOF9GuwM7O2mheyGeIrs5MOIeNjDEdgdoyHBOrFeJBR3g==
"@types/node-fetch@~2.5.12":
version "2.5.12"
resolved "https://registry.yarnpkg.com/@types/node-fetch/-/node-fetch-2.5.12.tgz#8a6f779b1d4e60b7a57fb6fd48d84fb545b9cc66"
integrity sha512-MKgC4dlq4kKNa/mYrwpKfzQMB5X3ee5U6fSprkKpToBqBmX4nFZL9cW5jl6sWn+xpRJ7ypWh2yyqqr8UUCstSw==
dependencies:
node-fetch "*"
"@types/node" "*"
form-data "^3.0.0"

"@types/node@*":
version "15.6.0"
Expand Down Expand Up @@ -2694,11 +2695,6 @@ cssstyle@^2.3.0:
dependencies:
cssom "~0.3.6"

data-uri-to-buffer@^3.0.1:
version "3.0.1"
resolved "https://registry.yarnpkg.com/data-uri-to-buffer/-/data-uri-to-buffer-3.0.1.tgz#594b8973938c5bc2c33046535785341abc4f3636"
integrity sha512-WboRycPNsVw3B3TL559F7kuBUM4d8CgMEvk6xEJlOp7OBPjt6G7z8WMWlD2rOFZLk6OYfFIUGsCOWzcQH9K2og==

data-urls@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/data-urls/-/data-urls-2.0.0.tgz#156485a72963a970f5d5821aaf642bef2bf2db9b"
Expand Down Expand Up @@ -3534,13 +3530,6 @@ fb-watchman@^2.0.0:
dependencies:
bser "2.1.1"

fetch-blob@^3.1.2:
version "3.1.2"
resolved "https://registry.yarnpkg.com/fetch-blob/-/fetch-blob-3.1.2.tgz#6bc438675f3851ecea51758ac91f6a1cd1bacabd"
integrity sha512-hunJbvy/6OLjCD0uuhLdp0mMPzP/yd2ssd1t2FCJsaA7wkWhpbp9xfuNVpv7Ll4jFhzp6T4LAupSiV9uOeg0VQ==
dependencies:
web-streams-polyfill "^3.0.3"

figgy-pudding@^3.5.1:
version "3.5.2"
resolved "https://registry.yarnpkg.com/figgy-pudding/-/figgy-pudding-3.5.2.tgz#b4eee8148abb01dcf1d1ac34367d59e12fa61d6e"
Expand Down Expand Up @@ -5734,19 +5723,16 @@ no-case@^3.0.4:
lower-case "^2.0.2"
tslib "^2.0.3"

node-fetch@*, node-fetch@^3.0.0:
version "3.0.0"
resolved "https://registry.yarnpkg.com/node-fetch/-/node-fetch-3.0.0.tgz#79da7146a520036f2c5f644e4a26095f17e411ea"
integrity sha512-bKMI+C7/T/SPU1lKnbQbwxptpCrG9ashG+VkytmXCPZyuM9jB6VU+hY0oi4lC8LxTtAeWdckNCTa3nrGsAdA3Q==
dependencies:
data-uri-to-buffer "^3.0.1"
fetch-blob "^3.1.2"

node-fetch@^2.6.1:
version "2.6.1"
resolved "https://registry.yarnpkg.com/node-fetch/-/node-fetch-2.6.1.tgz#045bd323631f76ed2e2b55573394416b639a0052"
integrity sha512-V4aYg89jEoVRxRb2fJdAg8FHvI7cEyYdVAh94HH0UIK8oJxUfkjlDQN9RbMx+bEjP7+ggMiFRprSti032Oipxw==

node-fetch@~2.6.2:
version "2.6.2"
resolved "https://registry.yarnpkg.com/node-fetch/-/node-fetch-2.6.2.tgz#986996818b73785e47b1965cc34eb093a1d464d0"
integrity sha512-aLoxToI6RfZ+0NOjmWAgn9+LEd30YCkJKFSyWacNZdEKTit/ZMcKjGkTRo8uWEsnIb/hfKecNPEbln02PdWbcA==

node-int64@^0.4.0:
version "0.4.0"
resolved "https://registry.yarnpkg.com/node-int64/-/node-int64-0.4.0.tgz#87a9065cdb355d3182d8f94ce11188b825c68a3b"
Expand Down Expand Up @@ -7769,11 +7755,6 @@ wcwidth@^1.0.1:
dependencies:
defaults "^1.0.3"

web-streams-polyfill@^3.0.3:
version "3.1.1"
resolved "https://registry.yarnpkg.com/web-streams-polyfill/-/web-streams-polyfill-3.1.1.tgz#1516f2d4ea8f1bdbfed15eb65cb2df87098c8364"
integrity sha512-Czi3fG883e96T4DLEPRvufrF2ydhOOW1+1a6c3gNjH2aIh50DNFBdfwh2AKoOf1rXvpvavAoA11Qdq9+BKjE0Q==

webidl-conversions@^5.0.0:
version "5.0.0"
resolved "https://registry.yarnpkg.com/webidl-conversions/-/webidl-conversions-5.0.0.tgz#ae59c8a00b121543a2acc65c0434f57b0fc11aff"
Expand Down

0 comments on commit 7b9201c

Please sign in to comment.