@atlaskit/tokens 0.3.0 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (103) hide show
  1. package/CHANGELOG.md +20 -0
  2. package/README.md +28 -0
  3. package/babel-plugin/package.json +7 -0
  4. package/css/atlassian-dark.css +24 -23
  5. package/css/atlassian-light.css +21 -20
  6. package/dist/cjs/artifacts/rename-mapping.js +23 -0
  7. package/dist/cjs/{tokens → artifacts}/token-default-values.js +22 -21
  8. package/dist/cjs/{tokens → artifacts}/token-names.js +2 -1
  9. package/dist/cjs/artifacts/tokens-raw/atlassian-dark.js +1786 -0
  10. package/dist/cjs/artifacts/tokens-raw/atlassian-light.js +1766 -0
  11. package/dist/cjs/artifacts/types.js +5 -0
  12. package/dist/cjs/{entry-points/token-default-values.js → babel-plugin/index.js} +2 -2
  13. package/dist/cjs/babel-plugin/plugin.js +176 -0
  14. package/dist/cjs/entry-points/rename-mapping.js +1 -1
  15. package/dist/cjs/entry-points/token-names.js +1 -1
  16. package/dist/cjs/figma/synchronize-figma-tokens.js +41 -39
  17. package/dist/cjs/get-token.js +1 -1
  18. package/dist/cjs/tokens/atlassian-dark/utility/utility.js +3 -0
  19. package/dist/cjs/tokens/atlassian-light/utility/utility.js +3 -0
  20. package/dist/cjs/tokens/default/color/accent.js +13 -0
  21. package/dist/cjs/tokens/default/color/background.js +49 -0
  22. package/dist/cjs/tokens/default/color/border.js +2 -0
  23. package/dist/cjs/tokens/default/color/icon-border.js +5 -0
  24. package/dist/cjs/tokens/default/color/overlay.js +2 -0
  25. package/dist/cjs/tokens/default/color/text.js +14 -0
  26. package/dist/cjs/tokens/default/shadow/shadow.js +2 -0
  27. package/dist/cjs/tokens/default/utility/utility.js +10 -2
  28. package/dist/cjs/tokens/palette.js +145 -260
  29. package/dist/cjs/version.json +1 -1
  30. package/dist/es2019/artifacts/rename-mapping.js +16 -0
  31. package/dist/es2019/{tokens → artifacts}/token-default-values.js +22 -21
  32. package/dist/es2019/{tokens → artifacts}/token-names.js +2 -1
  33. package/dist/es2019/artifacts/tokens-raw/atlassian-dark.js +1779 -0
  34. package/dist/es2019/artifacts/tokens-raw/atlassian-light.js +1759 -0
  35. package/dist/es2019/artifacts/types.js +1 -0
  36. package/dist/es2019/babel-plugin/index.js +1 -0
  37. package/dist/es2019/babel-plugin/plugin.js +151 -0
  38. package/dist/es2019/entry-points/rename-mapping.js +1 -1
  39. package/dist/es2019/entry-points/token-names.js +1 -1
  40. package/dist/es2019/figma/synchronize-figma-tokens.js +41 -39
  41. package/dist/es2019/get-token.js +1 -1
  42. package/dist/es2019/tokens/atlassian-dark/utility/utility.js +3 -0
  43. package/dist/es2019/tokens/atlassian-light/utility/utility.js +3 -0
  44. package/dist/es2019/tokens/default/color/accent.js +13 -0
  45. package/dist/es2019/tokens/default/color/background.js +49 -0
  46. package/dist/es2019/tokens/default/color/border.js +2 -0
  47. package/dist/es2019/tokens/default/color/icon-border.js +5 -0
  48. package/dist/es2019/tokens/default/color/overlay.js +2 -0
  49. package/dist/es2019/tokens/default/color/text.js +14 -0
  50. package/dist/es2019/tokens/default/shadow/shadow.js +2 -0
  51. package/dist/es2019/tokens/default/utility/utility.js +10 -2
  52. package/dist/es2019/tokens/palette.js +145 -260
  53. package/dist/es2019/version.json +1 -1
  54. package/dist/esm/artifacts/rename-mapping.js +16 -0
  55. package/dist/esm/{tokens → artifacts}/token-default-values.js +22 -21
  56. package/dist/esm/{tokens → artifacts}/token-names.js +2 -1
  57. package/dist/esm/artifacts/tokens-raw/atlassian-dark.js +1779 -0
  58. package/dist/esm/artifacts/tokens-raw/atlassian-light.js +1759 -0
  59. package/dist/esm/artifacts/types.js +1 -0
  60. package/dist/esm/babel-plugin/index.js +1 -0
  61. package/dist/esm/babel-plugin/plugin.js +158 -0
  62. package/dist/esm/entry-points/rename-mapping.js +1 -1
  63. package/dist/esm/entry-points/token-names.js +1 -1
  64. package/dist/esm/figma/synchronize-figma-tokens.js +41 -39
  65. package/dist/esm/get-token.js +1 -1
  66. package/dist/esm/tokens/atlassian-dark/utility/utility.js +3 -0
  67. package/dist/esm/tokens/atlassian-light/utility/utility.js +3 -0
  68. package/dist/esm/tokens/default/color/accent.js +13 -0
  69. package/dist/esm/tokens/default/color/background.js +49 -0
  70. package/dist/esm/tokens/default/color/border.js +2 -0
  71. package/dist/esm/tokens/default/color/icon-border.js +5 -0
  72. package/dist/esm/tokens/default/color/overlay.js +2 -0
  73. package/dist/esm/tokens/default/color/text.js +14 -0
  74. package/dist/esm/tokens/default/shadow/shadow.js +2 -0
  75. package/dist/esm/tokens/default/utility/utility.js +10 -2
  76. package/dist/esm/tokens/palette.js +145 -260
  77. package/dist/esm/version.json +1 -1
  78. package/dist/types/artifacts/rename-mapping.d.ts +17 -0
  79. package/dist/types/{tokens → artifacts}/token-default-values.d.ts +21 -20
  80. package/dist/types/{tokens → artifacts}/token-names.d.ts +2 -0
  81. package/dist/types/artifacts/tokens-raw/atlassian-dark.d.ts +80 -0
  82. package/dist/types/artifacts/tokens-raw/atlassian-light.d.ts +56 -0
  83. package/dist/types/artifacts/types.d.ts +4 -0
  84. package/dist/types/babel-plugin/index.d.ts +1 -0
  85. package/dist/types/babel-plugin/plugin.d.ts +14 -0
  86. package/dist/types/entry-points/babel-plugin.d.ts +1 -0
  87. package/dist/types/entry-points/rename-mapping.d.ts +1 -1
  88. package/dist/types/entry-points/token-names.d.ts +2 -2
  89. package/dist/types/get-token.d.ts +1 -1
  90. package/dist/types/index.d.ts +1 -1
  91. package/dist/types/tokens/atlassian-dark/utility/utility.d.ts +10 -2
  92. package/dist/types/tokens/atlassian-light/utility/utility.d.ts +10 -2
  93. package/dist/types/tokens/default/utility/utility.d.ts +138 -2
  94. package/dist/types/types.d.ts +49 -14
  95. package/package.json +17 -6
  96. package/dist/cjs/tokens/rename-mapping.js +0 -29
  97. package/dist/es2019/entry-points/token-default-values.js +0 -1
  98. package/dist/es2019/tokens/rename-mapping.js +0 -21
  99. package/dist/esm/entry-points/token-default-values.js +0 -1
  100. package/dist/esm/tokens/rename-mapping.js +0 -21
  101. package/dist/types/entry-points/token-default-values.d.ts +0 -1
  102. package/dist/types/tokens/rename-mapping.d.ts +0 -24
  103. package/token-default-values/package.json +0 -7
@@ -1,24 +1,57 @@
1
- export interface Token<TValue, Group extends string> {
1
+ import { ActiveTokens } from './artifacts/types';
2
+ export declare type Groups = 'raw' | 'paint' | 'shadow' | 'palette';
3
+ export declare type ActiveTokenStates = 'active';
4
+ export declare type ReplacedTokenStates = 'deprecated' | 'deleted';
5
+ export declare type TokenState = ActiveTokenStates | ReplacedTokenStates;
6
+ export declare type Replacement = ActiveTokens[];
7
+ export interface Token<TValue, Group extends Groups> {
2
8
  value: TValue;
3
9
  attributes: {
4
- group?: Group;
10
+ group: Group;
5
11
  description?: string;
12
+ state?: TokenState;
13
+ replacement?: Replacement;
6
14
  };
7
15
  }
8
- export declare type ColorPalette = keyof PaletteColorTokenSchema['color']['palette'];
9
- export declare type PaintToken<Value extends string = ColorPalette> = Token<Value, 'paint'>;
10
- export declare type PaletteToken = Token<string, 'paint'> & {
16
+ /**
17
+ * Base tokens define the raw values consumed by Design Tokens. They are a context-agnostic
18
+ * name:value pairing (for example, the base token N0 represents the value #FFFFFF ).
19
+ */
20
+ export interface BaseToken<TValue, Group extends Groups> extends Token<TValue, Group> {
11
21
  attributes: {
12
- isPalette: true;
22
+ group: Group;
13
23
  };
24
+ }
25
+ /**
26
+ * Design tokens represent single sources of truth to name and store semantic design decisions.
27
+ * They map a semantic name (color.background.default) to a base token (N0).
28
+ */
29
+ export interface DesignToken<TValue, Group extends Groups> extends Token<TValue, Group> {
30
+ attributes: {
31
+ group: Group;
32
+ description: string;
33
+ state: ActiveTokenStates;
34
+ replacement?: undefined;
35
+ } | {
36
+ group: Group;
37
+ description: string;
38
+ state: ReplacedTokenStates;
39
+ replacement?: Replacement;
40
+ };
41
+ }
42
+ declare type OmitDistributive<T, K extends PropertyKey> = T extends any ? T extends object ? Id<DeepOmit<T, K>> : T : never;
43
+ declare type Id<T> = {} & {
44
+ [P in keyof T]: T[P];
14
45
  };
15
- export declare type ValueSchema<Schema extends object> = {
16
- [Key in keyof Schema]: ValueSchema<Omit<Schema[Key], 'attributes'>>;
17
- };
18
- export declare type AttributeSchema<Schema extends object> = {
19
- [Key in keyof Schema]: AttributeSchema<Omit<Schema[Key], 'value'>>;
20
- };
21
- export declare type ShadowToken<Value extends string = ColorPalette> = Token<Array<{
46
+ declare type DeepOmit<T extends any, K extends PropertyKey> = Omit<{
47
+ [P in keyof T]: OmitDistributive<T[P], K>;
48
+ }, K>;
49
+ export declare type ValueSchema<Schema extends object> = DeepOmit<Schema, 'attributes'>;
50
+ export declare type AttributeSchema<Schema extends object> = DeepOmit<Schema, 'value'>;
51
+ export declare type PaletteToken = BaseToken<string, 'palette'>;
52
+ export declare type ColorPalette = keyof PaletteColorTokenSchema['color']['palette'];
53
+ export declare type PaintToken<Value extends string = ColorPalette> = DesignToken<Value, 'paint'>;
54
+ export declare type ShadowToken<Value extends string = ColorPalette> = DesignToken<Array<{
22
55
  color: Value;
23
56
  opacity: number;
24
57
  offset: {
@@ -29,7 +62,7 @@ export declare type ShadowToken<Value extends string = ColorPalette> = Token<Arr
29
62
  spread?: number;
30
63
  inset?: boolean;
31
64
  }>, 'shadow'>;
32
- export declare type RawToken = Token<string, 'raw'>;
65
+ export declare type RawToken = DesignToken<string, 'raw'>;
33
66
  export interface PaletteColorTokenSchema {
34
67
  color: {
35
68
  palette: {
@@ -313,7 +346,9 @@ export interface ShadowTokenSchema {
313
346
  export interface UtilTokenSchema {
314
347
  UNSAFE_util: {
315
348
  transparent: RawToken;
349
+ MISSING_TOKEN: RawToken;
316
350
  };
317
351
  }
318
352
  export declare type ColorTokenSchema = BackgroundColorTokenSchema & BorderColorTokenSchema & IconBorderColorTokenSchema & TextColorTokenSchema & AccentColorTokenSchema & UtilTokenSchema;
319
353
  export declare type TokenSchema = PaletteColorTokenSchema & ColorTokenSchema & ShadowTokenSchema;
354
+ export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/tokens",
3
- "version": "0.3.0",
3
+ "version": "0.4.0",
4
4
  "author": "Atlassian Pty Ltd",
5
5
  "description": "Tokens are a single source of truth to name and store Atlassian design decisions.",
6
6
  "license": "Apache-2.0",
@@ -21,8 +21,8 @@
21
21
  "af:exports": {
22
22
  ".": "./src/index.tsx",
23
23
  "./token-names": "./src/entry-points/token-names.tsx",
24
- "./token-default-values": "./src/entry-points/token-default-values.tsx",
25
- "./rename-mapping": "./src/entry-points/rename-mapping.tsx"
24
+ "./rename-mapping": "./src/entry-points/rename-mapping.tsx",
25
+ "./babel-plugin": "./src/entry-points/babel-plugin.tsx"
26
26
  },
27
27
  "scripts": {
28
28
  "ak-postbuild": "yarn codegen-tokens && yarn check-clean-git",
@@ -30,12 +30,20 @@
30
30
  "codegen-tokens": "ts-node --project ../../../tsconfig.node.json ./scripts/style-dictionary/build"
31
31
  },
32
32
  "dependencies": {
33
- "@babel/runtime": "^7.0.0"
33
+ "@babel/runtime": "^7.0.0",
34
+ "@babel/traverse": "^7.15.0",
35
+ "@babel/types": "^7.15.0"
34
36
  },
35
37
  "devDependencies": {
38
+ "@atlaskit/code": "*",
39
+ "@atlaskit/lozenge": "*",
40
+ "@atlaskit/tabs": "*",
36
41
  "@atlassian/atlassian-frontend-prettier-config-1.0.1": "npm:@atlassian/atlassian-frontend-prettier-config@1.0.1",
42
+ "@babel/core": "^7.12.3",
43
+ "@emotion/core": "^10.0.9",
37
44
  "lodash": "^4.17.15",
38
45
  "prettier": "^2.1.1",
46
+ "react": "^16.8.0",
39
47
  "style-dictionary": "^3.0.0",
40
48
  "ts-node": "^10.0.0",
41
49
  "typescript": "3.9.6"
@@ -48,8 +56,11 @@
48
56
  "@repo/internal": {
49
57
  "design-system": "v1",
50
58
  "ui-components": "lite-mode",
51
- "deprecation": "no-deprecated-imports"
59
+ "deprecation": "no-deprecated-imports",
60
+ "styling": [
61
+ "emotion"
62
+ ]
52
63
  }
53
64
  },
54
65
  "prettier": "@atlassian/atlassian-frontend-prettier-config-1.0.1"
55
- }
66
+ }
@@ -1,29 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = void 0;
7
-
8
- /**
9
- * This file is intended to help create automation on top of renaming of tokens.
10
- *
11
- * When renaming tokens, you must first update the token at its source of truth.
12
- * For example: packages/design-system/tokens/src/tokens/atlassian-dark/color/accent.tsx
13
- *
14
- * That token might go from `color.accentBlueSubtle` to `color.accentBluePrimary`
15
- * which is totally acceptable on its own but for some platform targets, such as Figma,
16
- * we need to provide additional metadata to tell figma that this is a rename and not a removal/addition.
17
- *
18
- * To create a rename mapping:
19
- *
20
- * 1. Get the fully object path, separated by a '.', i.e. color.background.primary
21
- * 2. Create a key value pair to the renameMapping below, with key representing the old token and value representing the new token.
22
- * 3. Update the token at its source of truth
23
- * 4. run `yarn build tokens`
24
- * 5. The artifact containing the automation should now be available in the `/dist` folder. i.e. packages/design-system/tokens/dist/figma/atlassian-light/sync-figma-tokens.js
25
- * 6. After building make sure to remove the mapping from this file before checking it in
26
- */
27
- var renameMapping = {};
28
- var _default = renameMapping;
29
- exports.default = _default;
@@ -1 +0,0 @@
1
- export { default } from '../tokens/token-default-values';
@@ -1,21 +0,0 @@
1
- /**
2
- * This file is intended to help create automation on top of renaming of tokens.
3
- *
4
- * When renaming tokens, you must first update the token at its source of truth.
5
- * For example: packages/design-system/tokens/src/tokens/atlassian-dark/color/accent.tsx
6
- *
7
- * That token might go from `color.accentBlueSubtle` to `color.accentBluePrimary`
8
- * which is totally acceptable on its own but for some platform targets, such as Figma,
9
- * we need to provide additional metadata to tell figma that this is a rename and not a removal/addition.
10
- *
11
- * To create a rename mapping:
12
- *
13
- * 1. Get the fully object path, separated by a '.', i.e. color.background.primary
14
- * 2. Create a key value pair to the renameMapping below, with key representing the old token and value representing the new token.
15
- * 3. Update the token at its source of truth
16
- * 4. run `yarn build tokens`
17
- * 5. The artifact containing the automation should now be available in the `/dist` folder. i.e. packages/design-system/tokens/dist/figma/atlassian-light/sync-figma-tokens.js
18
- * 6. After building make sure to remove the mapping from this file before checking it in
19
- */
20
- const renameMapping = {};
21
- export default renameMapping;
@@ -1 +0,0 @@
1
- export { default } from '../tokens/token-default-values';
@@ -1,21 +0,0 @@
1
- /**
2
- * This file is intended to help create automation on top of renaming of tokens.
3
- *
4
- * When renaming tokens, you must first update the token at its source of truth.
5
- * For example: packages/design-system/tokens/src/tokens/atlassian-dark/color/accent.tsx
6
- *
7
- * That token might go from `color.accentBlueSubtle` to `color.accentBluePrimary`
8
- * which is totally acceptable on its own but for some platform targets, such as Figma,
9
- * we need to provide additional metadata to tell figma that this is a rename and not a removal/addition.
10
- *
11
- * To create a rename mapping:
12
- *
13
- * 1. Get the fully object path, separated by a '.', i.e. color.background.primary
14
- * 2. Create a key value pair to the renameMapping below, with key representing the old token and value representing the new token.
15
- * 3. Update the token at its source of truth
16
- * 4. run `yarn build tokens`
17
- * 5. The artifact containing the automation should now be available in the `/dist` folder. i.e. packages/design-system/tokens/dist/figma/atlassian-light/sync-figma-tokens.js
18
- * 6. After building make sure to remove the mapping from this file before checking it in
19
- */
20
- var renameMapping = {};
21
- export default renameMapping;
@@ -1 +0,0 @@
1
- export { default } from '../tokens/token-default-values';
@@ -1,24 +0,0 @@
1
- import tokens from './token-names';
2
- declare type Token = keyof typeof tokens | string;
3
- declare type RenameMapping = Partial<Record<Token, Token>>;
4
- /**
5
- * This file is intended to help create automation on top of renaming of tokens.
6
- *
7
- * When renaming tokens, you must first update the token at its source of truth.
8
- * For example: packages/design-system/tokens/src/tokens/atlassian-dark/color/accent.tsx
9
- *
10
- * That token might go from `color.accentBlueSubtle` to `color.accentBluePrimary`
11
- * which is totally acceptable on its own but for some platform targets, such as Figma,
12
- * we need to provide additional metadata to tell figma that this is a rename and not a removal/addition.
13
- *
14
- * To create a rename mapping:
15
- *
16
- * 1. Get the fully object path, separated by a '.', i.e. color.background.primary
17
- * 2. Create a key value pair to the renameMapping below, with key representing the old token and value representing the new token.
18
- * 3. Update the token at its source of truth
19
- * 4. run `yarn build tokens`
20
- * 5. The artifact containing the automation should now be available in the `/dist` folder. i.e. packages/design-system/tokens/dist/figma/atlassian-light/sync-figma-tokens.js
21
- * 6. After building make sure to remove the mapping from this file before checking it in
22
- */
23
- declare const renameMapping: RenameMapping;
24
- export default renameMapping;
@@ -1,7 +0,0 @@
1
- {
2
- "name": "@atlaskit/tokens/token-default-values",
3
- "main": "../dist/cjs/entry-points/token-default-values.js",
4
- "module": "../dist/esm/entry-points/token-default-values.js",
5
- "module:es2019": "../dist/es2019/entry-points/token-default-values.js",
6
- "types": "../dist/types/entry-points/token-default-values.d.ts"
7
- }