@bitrise/bitkit 12.78.0 → 12.79.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@bitrise/bitkit",
3
3
  "description": "Bitrise React component library",
4
- "version": "12.78.0",
4
+ "version": "12.79.0",
5
5
  "repository": {
6
6
  "type": "git",
7
7
  "url": "git+ssh://git@github.com/bitrise-io/bitkit.git"
@@ -2,16 +2,19 @@
2
2
  import { Unstyled } from '@storybook/blocks';
3
3
  import Provider from '../../Components/Provider/Provider';
4
4
  import Divider from '../../Components/Divider/Divider';
5
- import Palette from './Palette';
5
+ import CommonTokens from './CommonTokens';
6
6
  import SystemTokens from './SystemTokens';
7
+ import Palette from './Palette';
7
8
 
8
9
  const Colors = () => {
9
10
  return (
10
11
  <Unstyled>
11
12
  <Provider>
12
- <Palette />
13
+ <CommonTokens />
13
14
  <Divider marginTop="48" marginBottom="32" size="1" />
14
15
  <SystemTokens />
16
+ <Divider marginTop="48" marginBottom="32" size="1" />
17
+ <Palette />
15
18
  </Provider>
16
19
  </Unstyled>
17
20
  );
@@ -0,0 +1,21 @@
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" size="8" color="pal.purple.10" fontWeight="normal" marginBlockEnd="8">
11
+ Common Tokens
12
+ </Text>
13
+ <Card boxShadow="medium" padding="24">
14
+ {commonColorKeys.map((groupName) => (
15
+ <TokenTable data={semanticTokens.colors[groupName]} groupName={groupName} key={groupName} marginBottom="24" />
16
+ ))}
17
+ </Card>
18
+ </>
19
+ );
20
+
21
+ export default CommonTokens;
@@ -3,7 +3,7 @@ import Card from '../../Components/Card/Card';
3
3
  import Text from '../../Components/Text/Text';
4
4
  import TokenTable from '../docComponents/TokenTable';
5
5
 
6
- const SystemColorKeys = Object.keys(semanticTokens.colors.sys);
6
+ const systemColorKeys = Object.keys(semanticTokens.colors.sys);
7
7
 
8
8
  const SystemTokens = () => (
9
9
  <>
@@ -11,12 +11,13 @@ const SystemTokens = () => (
11
11
  System Tokens
12
12
  </Text>
13
13
  <Card boxShadow="medium" padding="24">
14
- {SystemColorKeys.map((groupName) => (
14
+ {systemColorKeys.map((groupName) => (
15
15
  <TokenTable
16
16
  data={semanticTokens.colors.sys[groupName]}
17
17
  groupName={groupName}
18
18
  key={groupName}
19
19
  marginBottom="24"
20
+ tokenPrefix="sys."
20
21
  />
21
22
  ))}
22
23
  </Card>
@@ -1,3 +1,5 @@
1
+ /* eslint-disable react-hooks/rules-of-hooks */
2
+ import { useEffect, useRef, useState } from 'react';
1
3
  import { useToken } from '@chakra-ui/react';
2
4
  import CodeSnippet from '../../Components/CodeSnippet/CodeSnippet';
3
5
  import Dot from '../../Components/Dot/Dot';
@@ -12,7 +14,17 @@ import Thead from '../../Components/Table/Thead';
12
14
  import Tr from '../../Components/Table/Tr';
13
15
 
14
16
  const Row = ({ token, value }: { token: string; value: string }) => {
15
- const finalValue = useToken('colors', value);
17
+ const themeValue = useToken('colors', value);
18
+ const [hexa, setHexa] = useState(themeValue);
19
+
20
+ const dotRef = useRef<HTMLDivElement>(null);
21
+
22
+ useEffect(() => {
23
+ if (dotRef.current && hexa.includes('var(')) {
24
+ setHexa(getComputedStyle(dotRef.current).getPropertyValue(hexa.replace('var(', '').replace(')', '')));
25
+ }
26
+ }, []);
27
+
16
28
  return (
17
29
  <Tr role="group">
18
30
  <Td>
@@ -21,13 +33,13 @@ const Row = ({ token, value }: { token: string; value: string }) => {
21
33
  <Td>
22
34
  <>
23
35
  <Text marginBottom="8" size="2">
24
- {finalValue}
36
+ {hexa}
25
37
  </Text>
26
38
  <Text size="2">({value})</Text>
27
39
  </>
28
40
  </Td>
29
41
  <Td>
30
- <Dot backgroundColor={token.replace('colors.', '')} size="48" />
42
+ <Dot backgroundColor={value} border="1px solid" ref={dotRef} size="48" />
31
43
  </Td>
32
44
  </Tr>
33
45
  );
@@ -36,10 +48,11 @@ const Row = ({ token, value }: { token: string; value: string }) => {
36
48
  export interface TokenTableProps extends TableContainerProps {
37
49
  data: Record<string, string>;
38
50
  groupName: string;
51
+ tokenPrefix?: string;
39
52
  }
40
53
 
41
54
  const TokenTable = (props: TokenTableProps) => {
42
- const { data, groupName, ...rest } = props;
55
+ const { data, groupName, tokenPrefix = '', ...rest } = props;
43
56
  return (
44
57
  <TableContainer {...rest}>
45
58
  <Table>
@@ -53,7 +66,7 @@ const TokenTable = (props: TokenTableProps) => {
53
66
  </Thead>
54
67
  <Tbody>
55
68
  {Object.entries(data).map(([token, value]) => (
56
- <Row key={token} token={`colors.sys.${groupName}.${token}`} value={`colors.pal.${value}`} />
69
+ <Row key={token} token={`${tokenPrefix}${groupName}.${token}`} value={`${value}`} />
57
70
  ))}
58
71
  </Tbody>
59
72
  </Table>
@@ -2038,7 +2038,7 @@
2038
2038
  "type": "color"
2039
2039
  },
2040
2040
  "border": {
2041
- "value": "{color.border.strong}",
2041
+ "value": "{color.sys.border.strong}",
2042
2042
  "type": "color"
2043
2043
  },
2044
2044
  "border-hover": {
@@ -2543,14 +2543,6 @@
2543
2543
  "value": "{typography.font.sans.size-2.semibold}",
2544
2544
  "type": "typography"
2545
2545
  },
2546
- "placeholder": {
2547
- "value": "{typography.font.sans.size-3.normal}",
2548
- "type": "typography"
2549
- },
2550
- "inputText": {
2551
- "value": "{typography.font.sans.size-3.normal}",
2552
- "type": "typography"
2553
- },
2554
2546
  "helperText": {
2555
2547
  "value": "{typography.font.sans.size-1.normal}",
2556
2548
  "type": "typography"
@@ -3255,7 +3247,6 @@
3255
3247
  "typography.body.lg.regular": "S:761ca424abf734733758e62320deb038f5e88885,",
3256
3248
  "color.border.regular": "S:b1ef812dec0b5b963251cc48508c80b3e97b245b,",
3257
3249
  "typography.comp.input.label": "S:87701688b92f359799411878297f10d6c1da47c3,",
3258
- "typography.comp.input.placeholder": "S:437580d08e3247d2c795945eed9d21f63887d3aa,",
3259
3250
  "typography.comp.link.md": "S:327fca25b0d32f4948307ab84bc2db8ded39c0cb,",
3260
3251
  "typography.comp.link.md-hover": "S:3b782ebd3d90936152fec66173dbe656fb4a4918,",
3261
3252
  "typography.comp.link.lg": "S:38f56a952cdae2cb4bd7957979665b9c7597b351,",
@@ -3271,7 +3262,6 @@
3271
3262
  "typography.comp.badge.sm": "S:3f60adbdc0ff523f2a6c1188ff302ff5850161ae,",
3272
3263
  "typography.comp.dialog.title": "S:8e6cc40095c9c98726e0c6c155293cd43576af80,",
3273
3264
  "typography.comp.dialog.label": "S:230bbdcc7e7ea1b7dfc0809e0c83ee0a198eb7f9,",
3274
- "typography.comp.input.inputText": "S:b425a2b3d5a6886083fec7efc720d17d2e6c8c4a,",
3275
3265
  "typography.comp.input.helperText": "S:d9657de25ff4b6edc66af3a13a0c8294b1f6a2f2,"
3276
3266
  },
3277
3267
  "$figmaCollectionId": "VariableCollectionId:996:4339",
@@ -1,29 +1,37 @@
1
1
  import tokensJson from './tokens.json';
2
+ import { looper } from './tokensUtils';
2
3
 
3
- const paletteColors: any = {
4
- ...tokensJson.core.color.pal,
5
- };
6
-
7
- Object.keys(paletteColors).forEach((color) => {
8
- Object.entries(paletteColors[color]).forEach(([shade, { value }]: any) => {
9
- paletteColors[color][shade] = value;
10
- });
11
- });
12
-
13
- export const colors = {
14
- ...paletteColors,
15
- pal: paletteColors,
4
+ const legacyTokens = {
16
5
  brand: {
17
- primary: '#5C2A7E', // purple.30
6
+ primary: 'pal.purple.30',
18
7
  },
19
8
  text: {
20
- body: '#201B22', // neutral.10
21
- secondary: '#6B6071', // neutral.40
22
- link: '#9247C2', // purple.50
23
- linkHover: '#5C2A7E', // purple.30
9
+ body: 'pal.neutral.10',
10
+ secondary: 'pal.neutral.40',
11
+ link: 'pal.purple.50',
12
+ linkHover: 'pal.purple.30',
24
13
  },
25
14
  separator: {
26
- primary: '#DFDAE1', // neutral.90,
15
+ primary: 'pal.neutral.90',
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,
28
+ };
29
+
30
+ export const semanticTokens = {
31
+ colors: {
32
+ ...looper(commonColors),
33
+ ...legacyTokens,
34
+ sys: looper(tokensJson.system.color.sys),
27
35
  },
28
36
  };
29
37
 
@@ -39,19 +47,3 @@ export type TypeColors = `${
39
47
  | 'blue'}.${'10' | '20' | '30' | '40' | '50' | '60' | '70' | '80' | '90' | '93' | '95' | '100'}`;
40
48
 
41
49
  export type ColorScheme = 'blue' | 'red' | 'orange' | 'yellow' | 'green' | 'purple' | 'neutral';
42
-
43
- const sysColors: any = {
44
- ...tokensJson.system.color.sys,
45
- };
46
-
47
- Object.keys(sysColors).forEach((color) => {
48
- Object.entries(sysColors[color]).forEach(([shade, { value }]: any) => {
49
- sysColors[color][shade] = value.replace(/\{color\.pal\.(.*)\}/, '$1');
50
- });
51
- });
52
-
53
- export const semanticTokens = {
54
- colors: {
55
- sys: sysColors,
56
- },
57
- };
@@ -0,0 +1,20 @@
1
+ type JsonValue = {
2
+ type: string;
3
+ value: string;
4
+ };
5
+
6
+ const valueFormatter = (obj: JsonValue) => {
7
+ return obj.value.replace(/\{color\.(.*)\}/, '$1');
8
+ };
9
+
10
+ export const looper = (obj: any) => {
11
+ const returnObject: any = {};
12
+ Object.keys(obj).forEach((color) => {
13
+ returnObject[color] = {};
14
+ Object.keys(obj[color]).forEach((key: string) => {
15
+ const valueObj: JsonValue = obj[color][key];
16
+ returnObject[color][key] = valueFormatter(valueObj);
17
+ });
18
+ });
19
+ return returnObject;
20
+ };