@bitrise/bitkit 12.78.0 → 12.80.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 +1 -1
- package/src/Components/DatePicker/DatePicker.tsx +35 -34
- package/src/Foundations/Colors/Colors.tsx +5 -2
- package/src/Foundations/Colors/CommonTokens.tsx +21 -0
- package/src/Foundations/Colors/SystemTokens.tsx +3 -2
- package/src/Foundations/docComponents/TokenTable.tsx +18 -5
- package/src/tokens/tokens.json +1 -11
- package/src/tokens/tokens.ts +27 -35
- package/src/tokens/tokensUtils.ts +20 -0
package/package.json
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { useCallback, useEffect, useMemo,
|
|
1
|
+
import { useCallback, useEffect, useMemo, useState } from 'react';
|
|
2
2
|
import { DateTime } from 'luxon';
|
|
3
3
|
import FocusLock from 'react-focus-lock';
|
|
4
4
|
import { PopoverAnchor } from '@chakra-ui/react';
|
|
@@ -44,8 +44,6 @@ export type DatePickerProps = {
|
|
|
44
44
|
const DatePicker = (props: DatePickerProps) => {
|
|
45
45
|
const { children, onApply, onClose, onClear, visible, selectable, selected, mode, variant = 'default' } = props;
|
|
46
46
|
|
|
47
|
-
const isSelectionHappened = useRef(false);
|
|
48
|
-
|
|
49
47
|
const { isMobile } = useResponsive();
|
|
50
48
|
const today = DateTime.now().startOf('day');
|
|
51
49
|
|
|
@@ -73,12 +71,12 @@ const DatePicker = (props: DatePickerProps) => {
|
|
|
73
71
|
setDateFrom(undefined);
|
|
74
72
|
};
|
|
75
73
|
|
|
76
|
-
const handleApply = () => {
|
|
74
|
+
const handleApply = (from: typeof dateFrom, to: typeof dateTo) => {
|
|
77
75
|
if (onApply) {
|
|
78
76
|
if (mode === 'day') {
|
|
79
|
-
onApply(
|
|
77
|
+
onApply(from);
|
|
80
78
|
} else {
|
|
81
|
-
onApply(new DateRange(
|
|
79
|
+
onApply(new DateRange(from, to));
|
|
82
80
|
}
|
|
83
81
|
}
|
|
84
82
|
|
|
@@ -113,46 +111,49 @@ const DatePicker = (props: DatePickerProps) => {
|
|
|
113
111
|
|
|
114
112
|
const handleSelect = useCallback(
|
|
115
113
|
(date: DateTime) => {
|
|
116
|
-
|
|
114
|
+
let previewNew: 'from' | 'to' | undefined;
|
|
115
|
+
let dateFromNew = dateFrom;
|
|
116
|
+
let dateToNew = dateTo;
|
|
117
117
|
|
|
118
|
-
setPreview(undefined);
|
|
119
118
|
if (mode === 'day') {
|
|
120
|
-
|
|
119
|
+
dateFromNew = date;
|
|
121
120
|
} else if (dateFrom && dateTo) {
|
|
122
121
|
if (!preview) {
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
122
|
+
previewNew = 'from';
|
|
123
|
+
dateFromNew = date;
|
|
124
|
+
dateToNew = undefined;
|
|
126
125
|
}
|
|
127
126
|
} else if (dateTo && date > dateTo) {
|
|
128
|
-
|
|
129
|
-
|
|
127
|
+
dateFromNew = dateTo;
|
|
128
|
+
dateToNew = date;
|
|
130
129
|
} else if (dateFrom && date < dateFrom) {
|
|
131
|
-
|
|
132
|
-
|
|
130
|
+
dateFromNew = date;
|
|
131
|
+
dateToNew = dateFrom;
|
|
133
132
|
} else if (dateFrom) {
|
|
134
|
-
|
|
133
|
+
dateToNew = date;
|
|
135
134
|
} else {
|
|
136
|
-
|
|
137
|
-
|
|
135
|
+
previewNew = 'from';
|
|
136
|
+
dateFromNew = date;
|
|
138
137
|
}
|
|
139
|
-
},
|
|
140
|
-
[dateFrom, dateTo, preview],
|
|
141
|
-
);
|
|
142
138
|
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
return;
|
|
147
|
-
}
|
|
139
|
+
setPreview(previewNew);
|
|
140
|
+
setDateFrom(dateFromNew);
|
|
141
|
+
setDateTo(dateToNew);
|
|
148
142
|
|
|
149
|
-
if (
|
|
150
|
-
|
|
151
|
-
|
|
143
|
+
if (variant === 'default') {
|
|
144
|
+
if (!dateFromNew || previewNew) {
|
|
145
|
+
return;
|
|
146
|
+
}
|
|
152
147
|
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
148
|
+
if (mode !== 'day' && !dateToNew) {
|
|
149
|
+
return;
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
handleApply(dateFromNew, dateToNew);
|
|
153
|
+
}
|
|
154
|
+
},
|
|
155
|
+
[dateFrom, dateTo, preview],
|
|
156
|
+
);
|
|
156
157
|
|
|
157
158
|
const currentSelected = useDateRange([dateFrom, dateTo]);
|
|
158
159
|
const ctx = useObjectMemo({
|
|
@@ -213,7 +214,7 @@ const DatePicker = (props: DatePickerProps) => {
|
|
|
213
214
|
</Box>
|
|
214
215
|
{variant === 'filter' && (
|
|
215
216
|
<DatePickerFooter
|
|
216
|
-
onApply={handleApply}
|
|
217
|
+
onApply={() => handleApply(dateFrom, dateTo)}
|
|
217
218
|
onClose={handleClose}
|
|
218
219
|
onClear={onClear}
|
|
219
220
|
selected={currentSelected}
|
|
@@ -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
|
|
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
|
-
<
|
|
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
|
|
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
|
-
{
|
|
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
|
|
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
|
-
{
|
|
36
|
+
{hexa}
|
|
25
37
|
</Text>
|
|
26
38
|
<Text size="2">({value})</Text>
|
|
27
39
|
</>
|
|
28
40
|
</Td>
|
|
29
41
|
<Td>
|
|
30
|
-
<Dot backgroundColor={
|
|
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={
|
|
69
|
+
<Row key={token} token={`${tokenPrefix}${groupName}.${token}`} value={`${value}`} />
|
|
57
70
|
))}
|
|
58
71
|
</Tbody>
|
|
59
72
|
</Table>
|
package/src/tokens/tokens.json
CHANGED
|
@@ -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",
|
package/src/tokens/tokens.ts
CHANGED
|
@@ -1,29 +1,37 @@
|
|
|
1
1
|
import tokensJson from './tokens.json';
|
|
2
|
+
import { looper } from './tokensUtils';
|
|
2
3
|
|
|
3
|
-
const
|
|
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: '
|
|
6
|
+
primary: 'pal.purple.30',
|
|
18
7
|
},
|
|
19
8
|
text: {
|
|
20
|
-
body: '
|
|
21
|
-
secondary: '
|
|
22
|
-
link: '
|
|
23
|
-
linkHover: '
|
|
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: '
|
|
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
|
+
};
|