@atlaskit/tokens 0.8.0 → 0.8.1
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.
- package/CHANGELOG.md +6 -0
- package/dist/cjs/constants.js +18 -0
- package/dist/cjs/entry-points/token-ids.js +25 -0
- package/dist/cjs/get-token.js +1 -1
- package/dist/cjs/token-ids.js +75 -0
- package/dist/cjs/version.json +4 -2
- package/dist/es2019/constants.js +8 -0
- package/dist/es2019/entry-points/token-ids.js +1 -0
- package/dist/es2019/get-token.js +1 -1
- package/dist/es2019/token-ids.js +51 -0
- package/dist/es2019/version.json +4 -2
- package/dist/esm/constants.js +8 -0
- package/dist/esm/entry-points/token-ids.js +1 -0
- package/dist/esm/get-token.js +1 -1
- package/dist/esm/token-ids.js +58 -0
- package/dist/esm/version.json +4 -2
- package/dist/types/constants.d.ts +4 -0
- package/dist/types/entry-points/token-ids.d.ts +1 -0
- package/dist/types/token-ids.d.ts +43 -0
- package/package.json +5 -2
- package/token-ids/package.json +7 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# @atlaskit/tokens
|
|
2
2
|
|
|
3
|
+
## 0.8.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [`a66253fc6a5`](https://bitbucket.org/atlassian/atlassian-frontend/commits/a66253fc6a5) - Export token ID utility functions with new entrypoint `@atlaskit/tokens/token-ids`
|
|
8
|
+
|
|
3
9
|
## 0.8.0
|
|
4
10
|
|
|
5
11
|
### Minor Changes
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.LONG_SHORT_MAPPING = exports.DEFAULT_THEME = exports.CSS_PREFIX = exports.ALLOWED_THEMES = void 0;
|
|
7
|
+
var ALLOWED_THEMES = ['light', 'dark'];
|
|
8
|
+
exports.ALLOWED_THEMES = ALLOWED_THEMES;
|
|
9
|
+
var DEFAULT_THEME = 'light';
|
|
10
|
+
exports.DEFAULT_THEME = DEFAULT_THEME;
|
|
11
|
+
var CSS_PREFIX = 'ds'; // Maps the longer theme name to a shorthand used in css/code
|
|
12
|
+
|
|
13
|
+
exports.CSS_PREFIX = CSS_PREFIX;
|
|
14
|
+
var LONG_SHORT_MAPPING = {
|
|
15
|
+
'atlassian-light': 'light',
|
|
16
|
+
'atlassian-dark': 'dark'
|
|
17
|
+
};
|
|
18
|
+
exports.LONG_SHORT_MAPPING = LONG_SHORT_MAPPING;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
Object.defineProperty(exports, "getCSSCustomProperty", {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: function get() {
|
|
9
|
+
return _tokenIds.getCSSCustomProperty;
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
Object.defineProperty(exports, "getFullyQualifiedTokenId", {
|
|
13
|
+
enumerable: true,
|
|
14
|
+
get: function get() {
|
|
15
|
+
return _tokenIds.getFullyQualifiedTokenId;
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
Object.defineProperty(exports, "getTokenId", {
|
|
19
|
+
enumerable: true,
|
|
20
|
+
get: function get() {
|
|
21
|
+
return _tokenIds.getTokenId;
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
var _tokenIds = require("../token-ids");
|
package/dist/cjs/get-token.js
CHANGED
|
@@ -12,7 +12,7 @@ var _warnOnce = _interopRequireDefault(require("@atlaskit/ds-lib/warn-once"));
|
|
|
12
12
|
var _tokenNames = _interopRequireDefault(require("./artifacts/token-names"));
|
|
13
13
|
|
|
14
14
|
var name = "@atlaskit/tokens";
|
|
15
|
-
var version = "0.8.
|
|
15
|
+
var version = "0.8.1";
|
|
16
16
|
|
|
17
17
|
function token(path, fallback) {
|
|
18
18
|
var token = _tokenNames.default[path];
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.getTokenId = exports.getFullyQualifiedTokenId = exports.getCSSCustomProperty = void 0;
|
|
9
|
+
|
|
10
|
+
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
11
|
+
|
|
12
|
+
var _constants = require("./constants");
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Transforms a style dictionary token path to a CSS custom property.
|
|
16
|
+
*
|
|
17
|
+
* A css prefix will be prepended and all [default] key words will be omitted
|
|
18
|
+
* from the path
|
|
19
|
+
*
|
|
20
|
+
* @example <caption>Passing a path as an array</caption>
|
|
21
|
+
* // Returns ds-background-bold
|
|
22
|
+
* getCSSCustomProperty(['color', 'background', 'bold', '[default]'])
|
|
23
|
+
*
|
|
24
|
+
* @example <caption>Passing a path as a string</caption>
|
|
25
|
+
* // Returns ds-background-bold
|
|
26
|
+
* getCSSCustomProperty('color.background.bold.[default]')
|
|
27
|
+
*/
|
|
28
|
+
var getCSSCustomProperty = function getCSSCustomProperty(path) {
|
|
29
|
+
var normalizedPath = typeof path === 'string' ? path.split('.') : path;
|
|
30
|
+
return "--".concat([_constants.CSS_PREFIX].concat((0, _toConsumableArray2.default)(normalizedPath.slice(1))).filter(function (el) {
|
|
31
|
+
return el !== '[default]';
|
|
32
|
+
}).join('-'));
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
exports.getCSSCustomProperty = getCSSCustomProperty;
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Transforms a style dictionary token path to a shorthand token id
|
|
39
|
+
* These ids will be typically be how tokens are interacted with via typescript and css
|
|
40
|
+
*
|
|
41
|
+
* All [default] key words will be omitted from the path
|
|
42
|
+
*
|
|
43
|
+
* @example <caption>Passing a path as an array</caption>
|
|
44
|
+
* // Returns color.background.bold
|
|
45
|
+
* getTokenId(['color', 'background', 'bold', '[default]'])
|
|
46
|
+
*
|
|
47
|
+
* @example <caption>Passing a path as a string</caption>
|
|
48
|
+
* // Returns color.background.bold
|
|
49
|
+
* getTokenId('color.background.bold.[default]')
|
|
50
|
+
*/
|
|
51
|
+
var getTokenId = function getTokenId(path) {
|
|
52
|
+
var normalizedPath = typeof path === 'string' ? path.split('.') : path;
|
|
53
|
+
return normalizedPath.filter(function (el) {
|
|
54
|
+
return el !== '[default]';
|
|
55
|
+
}).join('.');
|
|
56
|
+
};
|
|
57
|
+
/**
|
|
58
|
+
* Transforms a style dictionary token path to a fully qualified token id
|
|
59
|
+
* These Ids are intended to be used internal to this package by style-dictionary
|
|
60
|
+
*
|
|
61
|
+
* [default] key words will NOT be omitted from the path
|
|
62
|
+
*
|
|
63
|
+
* @example <caption>Passing a path as a string</caption>
|
|
64
|
+
* // Returns color.background.bold.[default]
|
|
65
|
+
* getFullyQualifiedTokenId(['color', 'background', 'bold', '[default]'])
|
|
66
|
+
*/
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
exports.getTokenId = getTokenId;
|
|
70
|
+
|
|
71
|
+
var getFullyQualifiedTokenId = function getFullyQualifiedTokenId(path) {
|
|
72
|
+
return path.join('.');
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
exports.getFullyQualifiedTokenId = getFullyQualifiedTokenId;
|
package/dist/cjs/version.json
CHANGED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export const ALLOWED_THEMES = ['light', 'dark'];
|
|
2
|
+
export const DEFAULT_THEME = 'light';
|
|
3
|
+
export const CSS_PREFIX = 'ds'; // Maps the longer theme name to a shorthand used in css/code
|
|
4
|
+
|
|
5
|
+
export const LONG_SHORT_MAPPING = {
|
|
6
|
+
'atlassian-light': 'light',
|
|
7
|
+
'atlassian-dark': 'dark'
|
|
8
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { getCSSCustomProperty, getTokenId, getFullyQualifiedTokenId } from '../token-ids';
|
package/dist/es2019/get-token.js
CHANGED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { CSS_PREFIX } from './constants';
|
|
2
|
+
/**
|
|
3
|
+
* Transforms a style dictionary token path to a CSS custom property.
|
|
4
|
+
*
|
|
5
|
+
* A css prefix will be prepended and all [default] key words will be omitted
|
|
6
|
+
* from the path
|
|
7
|
+
*
|
|
8
|
+
* @example <caption>Passing a path as an array</caption>
|
|
9
|
+
* // Returns ds-background-bold
|
|
10
|
+
* getCSSCustomProperty(['color', 'background', 'bold', '[default]'])
|
|
11
|
+
*
|
|
12
|
+
* @example <caption>Passing a path as a string</caption>
|
|
13
|
+
* // Returns ds-background-bold
|
|
14
|
+
* getCSSCustomProperty('color.background.bold.[default]')
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
export const getCSSCustomProperty = path => {
|
|
18
|
+
const normalizedPath = typeof path === 'string' ? path.split('.') : path;
|
|
19
|
+
return `--${[CSS_PREFIX, ...normalizedPath.slice(1)].filter(el => el !== '[default]').join('-')}`;
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Transforms a style dictionary token path to a shorthand token id
|
|
24
|
+
* These ids will be typically be how tokens are interacted with via typescript and css
|
|
25
|
+
*
|
|
26
|
+
* All [default] key words will be omitted from the path
|
|
27
|
+
*
|
|
28
|
+
* @example <caption>Passing a path as an array</caption>
|
|
29
|
+
* // Returns color.background.bold
|
|
30
|
+
* getTokenId(['color', 'background', 'bold', '[default]'])
|
|
31
|
+
*
|
|
32
|
+
* @example <caption>Passing a path as a string</caption>
|
|
33
|
+
* // Returns color.background.bold
|
|
34
|
+
* getTokenId('color.background.bold.[default]')
|
|
35
|
+
*/
|
|
36
|
+
export const getTokenId = path => {
|
|
37
|
+
const normalizedPath = typeof path === 'string' ? path.split('.') : path;
|
|
38
|
+
return normalizedPath.filter(el => el !== '[default]').join('.');
|
|
39
|
+
};
|
|
40
|
+
/**
|
|
41
|
+
* Transforms a style dictionary token path to a fully qualified token id
|
|
42
|
+
* These Ids are intended to be used internal to this package by style-dictionary
|
|
43
|
+
*
|
|
44
|
+
* [default] key words will NOT be omitted from the path
|
|
45
|
+
*
|
|
46
|
+
* @example <caption>Passing a path as a string</caption>
|
|
47
|
+
* // Returns color.background.bold.[default]
|
|
48
|
+
* getFullyQualifiedTokenId(['color', 'background', 'bold', '[default]'])
|
|
49
|
+
*/
|
|
50
|
+
|
|
51
|
+
export const getFullyQualifiedTokenId = path => path.join('.');
|
package/dist/es2019/version.json
CHANGED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export var ALLOWED_THEMES = ['light', 'dark'];
|
|
2
|
+
export var DEFAULT_THEME = 'light';
|
|
3
|
+
export var CSS_PREFIX = 'ds'; // Maps the longer theme name to a shorthand used in css/code
|
|
4
|
+
|
|
5
|
+
export var LONG_SHORT_MAPPING = {
|
|
6
|
+
'atlassian-light': 'light',
|
|
7
|
+
'atlassian-dark': 'dark'
|
|
8
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { getCSSCustomProperty, getTokenId, getFullyQualifiedTokenId } from '../token-ids';
|
package/dist/esm/get-token.js
CHANGED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
|
|
2
|
+
import { CSS_PREFIX } from './constants';
|
|
3
|
+
/**
|
|
4
|
+
* Transforms a style dictionary token path to a CSS custom property.
|
|
5
|
+
*
|
|
6
|
+
* A css prefix will be prepended and all [default] key words will be omitted
|
|
7
|
+
* from the path
|
|
8
|
+
*
|
|
9
|
+
* @example <caption>Passing a path as an array</caption>
|
|
10
|
+
* // Returns ds-background-bold
|
|
11
|
+
* getCSSCustomProperty(['color', 'background', 'bold', '[default]'])
|
|
12
|
+
*
|
|
13
|
+
* @example <caption>Passing a path as a string</caption>
|
|
14
|
+
* // Returns ds-background-bold
|
|
15
|
+
* getCSSCustomProperty('color.background.bold.[default]')
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
export var getCSSCustomProperty = function getCSSCustomProperty(path) {
|
|
19
|
+
var normalizedPath = typeof path === 'string' ? path.split('.') : path;
|
|
20
|
+
return "--".concat([CSS_PREFIX].concat(_toConsumableArray(normalizedPath.slice(1))).filter(function (el) {
|
|
21
|
+
return el !== '[default]';
|
|
22
|
+
}).join('-'));
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Transforms a style dictionary token path to a shorthand token id
|
|
27
|
+
* These ids will be typically be how tokens are interacted with via typescript and css
|
|
28
|
+
*
|
|
29
|
+
* All [default] key words will be omitted from the path
|
|
30
|
+
*
|
|
31
|
+
* @example <caption>Passing a path as an array</caption>
|
|
32
|
+
* // Returns color.background.bold
|
|
33
|
+
* getTokenId(['color', 'background', 'bold', '[default]'])
|
|
34
|
+
*
|
|
35
|
+
* @example <caption>Passing a path as a string</caption>
|
|
36
|
+
* // Returns color.background.bold
|
|
37
|
+
* getTokenId('color.background.bold.[default]')
|
|
38
|
+
*/
|
|
39
|
+
export var getTokenId = function getTokenId(path) {
|
|
40
|
+
var normalizedPath = typeof path === 'string' ? path.split('.') : path;
|
|
41
|
+
return normalizedPath.filter(function (el) {
|
|
42
|
+
return el !== '[default]';
|
|
43
|
+
}).join('.');
|
|
44
|
+
};
|
|
45
|
+
/**
|
|
46
|
+
* Transforms a style dictionary token path to a fully qualified token id
|
|
47
|
+
* These Ids are intended to be used internal to this package by style-dictionary
|
|
48
|
+
*
|
|
49
|
+
* [default] key words will NOT be omitted from the path
|
|
50
|
+
*
|
|
51
|
+
* @example <caption>Passing a path as a string</caption>
|
|
52
|
+
* // Returns color.background.bold.[default]
|
|
53
|
+
* getFullyQualifiedTokenId(['color', 'background', 'bold', '[default]'])
|
|
54
|
+
*/
|
|
55
|
+
|
|
56
|
+
export var getFullyQualifiedTokenId = function getFullyQualifiedTokenId(path) {
|
|
57
|
+
return path.join('.');
|
|
58
|
+
};
|
package/dist/esm/version.json
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { getCSSCustomProperty, getTokenId, getFullyQualifiedTokenId, } from '../token-ids';
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Transforms a style dictionary token path to a CSS custom property.
|
|
3
|
+
*
|
|
4
|
+
* A css prefix will be prepended and all [default] key words will be omitted
|
|
5
|
+
* from the path
|
|
6
|
+
*
|
|
7
|
+
* @example <caption>Passing a path as an array</caption>
|
|
8
|
+
* // Returns ds-background-bold
|
|
9
|
+
* getCSSCustomProperty(['color', 'background', 'bold', '[default]'])
|
|
10
|
+
*
|
|
11
|
+
* @example <caption>Passing a path as a string</caption>
|
|
12
|
+
* // Returns ds-background-bold
|
|
13
|
+
* getCSSCustomProperty('color.background.bold.[default]')
|
|
14
|
+
*/
|
|
15
|
+
export declare const getCSSCustomProperty: GetCssCustomProperty;
|
|
16
|
+
declare type GetCssCustomProperty = (path: string | string[]) => string;
|
|
17
|
+
/**
|
|
18
|
+
* Transforms a style dictionary token path to a shorthand token id
|
|
19
|
+
* These ids will be typically be how tokens are interacted with via typescript and css
|
|
20
|
+
*
|
|
21
|
+
* All [default] key words will be omitted from the path
|
|
22
|
+
*
|
|
23
|
+
* @example <caption>Passing a path as an array</caption>
|
|
24
|
+
* // Returns color.background.bold
|
|
25
|
+
* getTokenId(['color', 'background', 'bold', '[default]'])
|
|
26
|
+
*
|
|
27
|
+
* @example <caption>Passing a path as a string</caption>
|
|
28
|
+
* // Returns color.background.bold
|
|
29
|
+
* getTokenId('color.background.bold.[default]')
|
|
30
|
+
*/
|
|
31
|
+
export declare const getTokenId: (path: string | string[]) => string;
|
|
32
|
+
/**
|
|
33
|
+
* Transforms a style dictionary token path to a fully qualified token id
|
|
34
|
+
* These Ids are intended to be used internal to this package by style-dictionary
|
|
35
|
+
*
|
|
36
|
+
* [default] key words will NOT be omitted from the path
|
|
37
|
+
*
|
|
38
|
+
* @example <caption>Passing a path as a string</caption>
|
|
39
|
+
* // Returns color.background.bold.[default]
|
|
40
|
+
* getFullyQualifiedTokenId(['color', 'background', 'bold', '[default]'])
|
|
41
|
+
*/
|
|
42
|
+
export declare const getFullyQualifiedTokenId: (path: string[]) => string;
|
|
43
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/tokens",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.1",
|
|
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",
|
|
@@ -16,10 +16,13 @@
|
|
|
16
16
|
"module": "dist/esm/index.js",
|
|
17
17
|
"module:es2019": "dist/es2019/index.js",
|
|
18
18
|
"types": "dist/types/index.d.ts",
|
|
19
|
-
"sideEffects":
|
|
19
|
+
"sideEffects": [
|
|
20
|
+
"**/*.css"
|
|
21
|
+
],
|
|
20
22
|
"atlaskit:src": "src/index.tsx",
|
|
21
23
|
"af:exports": {
|
|
22
24
|
".": "./src/index.tsx",
|
|
25
|
+
"./token-ids": "./src/entry-points/token-ids.tsx",
|
|
23
26
|
"./token-names": "./src/entry-points/token-names.tsx",
|
|
24
27
|
"./rename-mapping": "./src/entry-points/rename-mapping.tsx",
|
|
25
28
|
"./babel-plugin": "./src/entry-points/babel-plugin.tsx",
|