@bitrise/bitkit 12.100.0 → 12.101.1-alpha.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.
- package/package.json +13 -11
- package/src/Components/Badge/Badge.theme.ts +4 -6
- package/src/Components/ColorButton/ColorButton.theme.ts +1 -1
- package/src/Components/ColorButton/ColorButton.tsx +1 -1
- package/src/Components/Dialog/Dialog.tsx +18 -4
- package/src/Components/Filter/Filter.theme.ts +1 -1
- package/src/Components/Form/Form.theme.ts +4 -6
- package/src/Components/Form/Input/Input.tsx +1 -1
- package/src/Components/Link/Link.theme.ts +2 -2
- package/src/Components/Link/Link.tsx +1 -1
- package/src/Components/Menu/MenuItem.tsx +1 -1
- package/src/Components/Notification/Notification.tsx +1 -1
- package/src/Components/Ribbon/Ribbon.tsx +1 -1
- package/src/Components/SegmentedControl/SegmentedControl.theme.ts +1 -1
- package/src/Components/Sidebar/SidebarItem.theme.ts +1 -1
- package/src/Components/Tabs/ContainedTab.tsx +4 -3
- package/src/Components/Tabs/Tabs.theme.ts +2 -3
- package/src/Components/Tag/Tag.theme.ts +3 -8
- package/src/Components/Tag/Tag.tsx +1 -1
- package/src/Components/Text/Text.theme.ts +46 -2
- package/src/Components/Text/Text.tsx +8 -17
- package/src/Components/components.theme.ts +103 -0
- package/src/Foundations/Colors/Colors.tsx +30 -4
- package/src/Foundations/Themes/Alert.theme.ts +4 -6
- package/src/Foundations/Typography/Typography.tsx +30 -0
- package/src/Foundations/docComponents/DocTitle.tsx +11 -0
- package/src/Foundations/docComponents/TokenTable.tsx +24 -9
- package/src/index.ts +2 -1
- package/src/theme.ts +13 -105
- package/src/tokens/colorTokens.ts +9 -0
- package/src/tokens/semanticTokens.ts +29 -0
- package/src/tokens/textTokens.ts +96 -0
- package/src/tokens/tokens.json +203 -203
- package/src/tokens/tokens.ts +14 -43
- package/src/tokens/tokensUtils.ts +47 -4
- package/src/types/colors.ts +12 -0
- package/src/types/typography.ts +19 -0
- package/src/utils/utils.ts +14 -0
- package/src/Foundations/Colors/CommonTokens.tsx +0 -21
- package/src/Foundations/Colors/SystemTokens.tsx +0 -27
- package/src/Foundations/Typography/Typography.ts +0 -69
package/src/tokens/tokens.ts
CHANGED
|
@@ -1,49 +1,20 @@
|
|
|
1
1
|
import tokensJson from './tokens.json';
|
|
2
|
-
import { looper } from './tokensUtils';
|
|
2
|
+
import { getFontSizes, looper } from './tokensUtils';
|
|
3
3
|
|
|
4
|
-
const
|
|
5
|
-
|
|
6
|
-
|
|
4
|
+
const tokens = {
|
|
5
|
+
fonts: {
|
|
6
|
+
body: `"Figtree", sans-serif`,
|
|
7
|
+
mono: `"Source Code Pro", monospace`,
|
|
7
8
|
},
|
|
8
|
-
|
|
9
|
-
|
|
9
|
+
fontSizes: getFontSizes(tokensJson.core.fontSizes),
|
|
10
|
+
fontWeights: {
|
|
11
|
+
bold: 700,
|
|
12
|
+
demiBold: 600,
|
|
13
|
+
normal: 400,
|
|
14
|
+
semibold: 600,
|
|
10
15
|
},
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
link: 'pal.purple.50',
|
|
14
|
-
linkHover: 'pal.purple.30',
|
|
15
|
-
secondary: 'pal.neutral.40',
|
|
16
|
-
},
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
const commonColors = (({ background, border, icon, text }) => ({ background, border, icon, text }))(
|
|
20
|
-
tokensJson.comp.color,
|
|
21
|
-
);
|
|
22
|
-
|
|
23
|
-
const paletteColors = looper(tokensJson.core.color.pal);
|
|
24
|
-
|
|
25
|
-
export const colors = {
|
|
26
|
-
pal: paletteColors,
|
|
27
|
-
...paletteColors,
|
|
16
|
+
letterSpacings: looper(tokensJson.core.letterSpacings),
|
|
17
|
+
lineHeights: looper(tokensJson.core.lineHeights),
|
|
28
18
|
};
|
|
29
19
|
|
|
30
|
-
export
|
|
31
|
-
colors: {
|
|
32
|
-
...legacyTokens,
|
|
33
|
-
sys: looper(tokensJson.system.color.sys),
|
|
34
|
-
...looper(commonColors),
|
|
35
|
-
},
|
|
36
|
-
};
|
|
37
|
-
|
|
38
|
-
export type TypeColors = `${
|
|
39
|
-
| 'neutral'
|
|
40
|
-
| 'purple'
|
|
41
|
-
| 'red'
|
|
42
|
-
| 'orange'
|
|
43
|
-
| 'yellow'
|
|
44
|
-
| 'green'
|
|
45
|
-
| 'turquoise'
|
|
46
|
-
| 'purple'
|
|
47
|
-
| 'blue'}.${'10' | '20' | '30' | '40' | '50' | '60' | '70' | '80' | '90' | '93' | '95' | '100'}`;
|
|
48
|
-
|
|
49
|
-
export type ColorScheme = 'blue' | 'red' | 'orange' | 'yellow' | 'green' | 'purple' | 'neutral';
|
|
20
|
+
export default tokens;
|
|
@@ -3,18 +3,61 @@ type JsonValue = {
|
|
|
3
3
|
value: string;
|
|
4
4
|
};
|
|
5
5
|
|
|
6
|
-
const
|
|
7
|
-
|
|
6
|
+
const VALUE_REGEXPS = {
|
|
7
|
+
color: /\{color\.(.*)\}/,
|
|
8
|
+
typography: /\{typography\.(.*)\}/,
|
|
8
9
|
};
|
|
9
10
|
|
|
10
|
-
|
|
11
|
+
const VALUE_FORMATTERS = {
|
|
12
|
+
color: (value: string) => value.replace(VALUE_REGEXPS.color, '$1'),
|
|
13
|
+
fontSize: (value: string) => {
|
|
14
|
+
const number = value.split('*')[1] || '1';
|
|
15
|
+
return `${number.trim()}rem`;
|
|
16
|
+
},
|
|
17
|
+
typography: (value: string) => {
|
|
18
|
+
if (!value) {
|
|
19
|
+
return value;
|
|
20
|
+
}
|
|
21
|
+
return value.replace(VALUE_REGEXPS.typography, '$1').replace(/\{(.*)\}/, '$1');
|
|
22
|
+
},
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
export const looper = (
|
|
26
|
+
obj: any,
|
|
27
|
+
formatterType?: keyof typeof VALUE_FORMATTERS,
|
|
28
|
+
formatterFunction?: (key: string, value: string) => any,
|
|
29
|
+
) => {
|
|
30
|
+
const returnObject: any = {};
|
|
31
|
+
Object.keys(obj).forEach((key) => {
|
|
32
|
+
const val: JsonValue | string = obj[key];
|
|
33
|
+
let finalValue = typeof val === 'string' ? val : val.value;
|
|
34
|
+
if (formatterType) {
|
|
35
|
+
finalValue = VALUE_FORMATTERS[formatterType](finalValue);
|
|
36
|
+
}
|
|
37
|
+
if (formatterFunction) {
|
|
38
|
+
finalValue = formatterFunction(key, finalValue);
|
|
39
|
+
}
|
|
40
|
+
if (finalValue) {
|
|
41
|
+
returnObject[key] = finalValue;
|
|
42
|
+
}
|
|
43
|
+
});
|
|
44
|
+
return returnObject;
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
export const colorLooper = (obj: any) => {
|
|
11
48
|
const returnObject: any = {};
|
|
12
49
|
Object.keys(obj).forEach((color) => {
|
|
13
50
|
returnObject[color] = {};
|
|
14
51
|
Object.keys(obj[color]).forEach((key: string) => {
|
|
15
52
|
const valueObj: JsonValue = obj[color][key];
|
|
16
|
-
returnObject[color][key] =
|
|
53
|
+
returnObject[color][key] = VALUE_FORMATTERS.color(valueObj.value);
|
|
17
54
|
});
|
|
18
55
|
});
|
|
19
56
|
return returnObject;
|
|
20
57
|
};
|
|
58
|
+
|
|
59
|
+
export const getFontSizes = (json: any) => {
|
|
60
|
+
const returnObj: Record<string, string> = looper(json, 'fontSize');
|
|
61
|
+
|
|
62
|
+
return returnObj;
|
|
63
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export type TypeColors = `${
|
|
2
|
+
| 'neutral'
|
|
3
|
+
| 'purple'
|
|
4
|
+
| 'red'
|
|
5
|
+
| 'orange'
|
|
6
|
+
| 'yellow'
|
|
7
|
+
| 'green'
|
|
8
|
+
| 'turquoise'
|
|
9
|
+
| 'purple'
|
|
10
|
+
| 'blue'}.${'10' | '20' | '30' | '40' | '50' | '60' | '70' | '80' | '90' | '93' | '95' | '100'}`;
|
|
11
|
+
|
|
12
|
+
export type ColorScheme = 'blue' | 'red' | 'orange' | 'yellow' | 'green' | 'purple' | 'neutral';
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export const TOKEN_STRINGS = [
|
|
2
|
+
'heading.h1',
|
|
3
|
+
'heading.h2',
|
|
4
|
+
'heading.h3',
|
|
5
|
+
'heading.h4',
|
|
6
|
+
'heading.h5',
|
|
7
|
+
'heading.h6',
|
|
8
|
+
'body.lg.regular',
|
|
9
|
+
'body.lg.semibold',
|
|
10
|
+
'body.lg.underline',
|
|
11
|
+
'body.md.regular',
|
|
12
|
+
'body.md.semibold',
|
|
13
|
+
'body.sm.regular',
|
|
14
|
+
'body.sm.semibold',
|
|
15
|
+
'code.lg',
|
|
16
|
+
'code.md',
|
|
17
|
+
] as const;
|
|
18
|
+
|
|
19
|
+
export type TokenStrings = (typeof TOKEN_STRINGS)[number];
|
package/src/utils/utils.ts
CHANGED
|
@@ -36,3 +36,17 @@ export function useDebounce<T>(value: T, delay?: number): T {
|
|
|
36
36
|
|
|
37
37
|
return debouncedValue;
|
|
38
38
|
}
|
|
39
|
+
|
|
40
|
+
export function isObject(value: any): boolean {
|
|
41
|
+
return typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export function getTokenValue(tokenString: string, tokenObject: any) {
|
|
45
|
+
let returnValue = {};
|
|
46
|
+
try {
|
|
47
|
+
returnValue = tokenString.split('.').reduce((o, i) => o[i], tokenObject);
|
|
48
|
+
} catch (e) {
|
|
49
|
+
returnValue = {};
|
|
50
|
+
}
|
|
51
|
+
return isObject(returnValue) ? returnValue : {};
|
|
52
|
+
}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { semanticTokens } from '../../tokens/tokens';
|
|
2
|
-
import Card from '../../Components/Card/Card';
|
|
3
|
-
import Text from '../../Components/Text/Text';
|
|
4
|
-
import TokenTable from '../docComponents/TokenTable';
|
|
5
|
-
|
|
6
|
-
const commonColorKeys = ['background', 'border', 'icon', 'text'];
|
|
7
|
-
|
|
8
|
-
const CommonTokens = () => (
|
|
9
|
-
<>
|
|
10
|
-
<Text as="h2" color="pal.purple.10" fontWeight="normal" marginBlockEnd="8" size="8">
|
|
11
|
-
Common Tokens
|
|
12
|
-
</Text>
|
|
13
|
-
<Card boxShadow="medium" padding="24">
|
|
14
|
-
{commonColorKeys.map((groupName) => (
|
|
15
|
-
<TokenTable key={groupName} data={semanticTokens.colors[groupName]} groupName={groupName} marginBottom="24" />
|
|
16
|
-
))}
|
|
17
|
-
</Card>
|
|
18
|
-
</>
|
|
19
|
-
);
|
|
20
|
-
|
|
21
|
-
export default CommonTokens;
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { semanticTokens } from '../../tokens/tokens';
|
|
2
|
-
import Card from '../../Components/Card/Card';
|
|
3
|
-
import Text from '../../Components/Text/Text';
|
|
4
|
-
import TokenTable from '../docComponents/TokenTable';
|
|
5
|
-
|
|
6
|
-
const systemColorKeys = Object.keys(semanticTokens.colors.sys);
|
|
7
|
-
|
|
8
|
-
const SystemTokens = () => (
|
|
9
|
-
<>
|
|
10
|
-
<Text as="h2" color="pal.purple.10" fontWeight="normal" marginBlockEnd="8" size="8">
|
|
11
|
-
System Tokens
|
|
12
|
-
</Text>
|
|
13
|
-
<Card boxShadow="medium" padding="24">
|
|
14
|
-
{systemColorKeys.map((groupName) => (
|
|
15
|
-
<TokenTable
|
|
16
|
-
key={groupName}
|
|
17
|
-
data={semanticTokens.colors.sys[groupName]}
|
|
18
|
-
groupName={groupName}
|
|
19
|
-
marginBottom="24"
|
|
20
|
-
tokenPrefix="sys."
|
|
21
|
-
/>
|
|
22
|
-
))}
|
|
23
|
-
</Card>
|
|
24
|
-
</>
|
|
25
|
-
);
|
|
26
|
-
|
|
27
|
-
export default SystemTokens;
|
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
const typography = {
|
|
2
|
-
fonts: {
|
|
3
|
-
body: `"TT Norms Pro", sans-serif`,
|
|
4
|
-
mono: `"Source Code Pro Bitrise", monospace`,
|
|
5
|
-
},
|
|
6
|
-
fontSizes: {
|
|
7
|
-
'1': '0.6875rem',
|
|
8
|
-
'2': '0.875rem',
|
|
9
|
-
'3': '1rem',
|
|
10
|
-
'4': '1.1875rem',
|
|
11
|
-
'5': '1.5rem',
|
|
12
|
-
'6': '1.875rem',
|
|
13
|
-
'7': '2.25rem',
|
|
14
|
-
'8': '3rem',
|
|
15
|
-
},
|
|
16
|
-
fontWeights: {
|
|
17
|
-
bold: 700,
|
|
18
|
-
demiBold: 600,
|
|
19
|
-
normal: 400,
|
|
20
|
-
},
|
|
21
|
-
letterSpacings: {
|
|
22
|
-
'1': '0.00625rem',
|
|
23
|
-
'2': '0.009375rem',
|
|
24
|
-
'3': '0.0175rem',
|
|
25
|
-
'4': '0.0375rem',
|
|
26
|
-
'5': '0.05rem',
|
|
27
|
-
},
|
|
28
|
-
};
|
|
29
|
-
|
|
30
|
-
export const textSizes = {
|
|
31
|
-
sizes: {
|
|
32
|
-
'1': {
|
|
33
|
-
fontSize: '1',
|
|
34
|
-
lineHeight: '1rem',
|
|
35
|
-
},
|
|
36
|
-
'2': {
|
|
37
|
-
fontSize: '2',
|
|
38
|
-
lineHeight: '1.25rem',
|
|
39
|
-
},
|
|
40
|
-
'3': {
|
|
41
|
-
fontSize: '3',
|
|
42
|
-
lineHeight: '1.5rem',
|
|
43
|
-
},
|
|
44
|
-
'4': {
|
|
45
|
-
fontSize: '4',
|
|
46
|
-
lineHeight: '1.75rem',
|
|
47
|
-
},
|
|
48
|
-
'5': {
|
|
49
|
-
fontSize: '5',
|
|
50
|
-
lineHeight: '2.25rem',
|
|
51
|
-
},
|
|
52
|
-
'6': {
|
|
53
|
-
fontSize: '6',
|
|
54
|
-
lineHeight: '2.5rem',
|
|
55
|
-
},
|
|
56
|
-
'7': {
|
|
57
|
-
fontSize: '7',
|
|
58
|
-
lineHeight: '3rem',
|
|
59
|
-
},
|
|
60
|
-
'8': {
|
|
61
|
-
fontSize: '8',
|
|
62
|
-
lineHeight: '3.75rem',
|
|
63
|
-
},
|
|
64
|
-
},
|
|
65
|
-
};
|
|
66
|
-
|
|
67
|
-
export type TextSizes = keyof typeof textSizes.sizes;
|
|
68
|
-
|
|
69
|
-
export default typography;
|