@bitrise/bitkit 12.77.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 +2 -1
- package/src/Components/DatePicker/DatePicker.tsx +41 -9
- package/src/Components/DatePicker/DatePickerFooter.tsx +4 -2
- 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,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bitrise/bitkit",
|
|
3
3
|
"description": "Bitrise React component library",
|
|
4
|
-
"version": "12.
|
|
4
|
+
"version": "12.79.0",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
7
7
|
"url": "git+ssh://git@github.com/bitrise-io/bitkit.git"
|
|
@@ -11,6 +11,7 @@
|
|
|
11
11
|
"scripts": {
|
|
12
12
|
"build-storybook": "storybook build",
|
|
13
13
|
"lint": "eslint src --ext ts,tsx",
|
|
14
|
+
"lint:fix": "eslint src --ext ts,tsx --fix",
|
|
14
15
|
"release": "release-it minor --ci",
|
|
15
16
|
"release-alpha": "release-it --preRelease=alpha --ci",
|
|
16
17
|
"start": "npm run storybook",
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { useCallback, useEffect, useMemo, useState } from 'react';
|
|
1
|
+
import { useCallback, useEffect, useMemo, useRef, 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';
|
|
@@ -7,6 +7,7 @@ import Popover from '../Popover/Popover';
|
|
|
7
7
|
import PopoverContent from '../Popover/PopoverContent';
|
|
8
8
|
import Box from '../Box/Box';
|
|
9
9
|
import useResponsive from '../../hooks/useResponsive';
|
|
10
|
+
import Button from '../Button/Button';
|
|
10
11
|
import DatePickerMonth from './DatePickerMonth';
|
|
11
12
|
import { DatePickerContext } from './DatePicker.context';
|
|
12
13
|
import DatePickerMonthSelector from './DatePickerMonthSelector';
|
|
@@ -22,6 +23,7 @@ export type DatePickerProps = {
|
|
|
22
23
|
onClose: () => void;
|
|
23
24
|
onClear?: () => void;
|
|
24
25
|
visible: boolean;
|
|
26
|
+
variant?: 'default' | 'filter';
|
|
25
27
|
} & (
|
|
26
28
|
| {
|
|
27
29
|
selected?: DateRange;
|
|
@@ -40,7 +42,9 @@ export type DatePickerProps = {
|
|
|
40
42
|
* range selection.
|
|
41
43
|
*/
|
|
42
44
|
const DatePicker = (props: DatePickerProps) => {
|
|
43
|
-
const { children, onApply, onClose, onClear, visible, selectable, selected, mode } = props;
|
|
45
|
+
const { children, onApply, onClose, onClear, visible, selectable, selected, mode, variant = 'default' } = props;
|
|
46
|
+
|
|
47
|
+
const isSelectionHappened = useRef(false);
|
|
44
48
|
|
|
45
49
|
const { isMobile } = useResponsive();
|
|
46
50
|
const today = DateTime.now().startOf('day');
|
|
@@ -89,6 +93,7 @@ const DatePicker = (props: DatePickerProps) => {
|
|
|
89
93
|
|
|
90
94
|
const [preview, setPreview] = useState<'from' | 'to' | undefined>(undefined);
|
|
91
95
|
const [isMonthSelector, setIsMonthSelector] = useState<'left' | 'right' | undefined>(undefined);
|
|
96
|
+
|
|
92
97
|
const handlePreview = useCallback(
|
|
93
98
|
(date: DateTime) => {
|
|
94
99
|
if (!preview) {
|
|
@@ -105,8 +110,11 @@ const DatePicker = (props: DatePickerProps) => {
|
|
|
105
110
|
},
|
|
106
111
|
[preview, dateFrom, dateTo],
|
|
107
112
|
);
|
|
113
|
+
|
|
108
114
|
const handleSelect = useCallback(
|
|
109
115
|
(date: DateTime) => {
|
|
116
|
+
isSelectionHappened.current = true;
|
|
117
|
+
|
|
110
118
|
setPreview(undefined);
|
|
111
119
|
if (mode === 'day') {
|
|
112
120
|
setDateFrom(date);
|
|
@@ -131,6 +139,21 @@ const DatePicker = (props: DatePickerProps) => {
|
|
|
131
139
|
},
|
|
132
140
|
[dateFrom, dateTo, preview],
|
|
133
141
|
);
|
|
142
|
+
|
|
143
|
+
useEffect(() => {
|
|
144
|
+
if (variant === 'default') {
|
|
145
|
+
if (!dateFrom || !isSelectionHappened.current || preview) {
|
|
146
|
+
return;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
if (mode !== 'day' && !dateTo) {
|
|
150
|
+
return;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
handleApply();
|
|
154
|
+
}
|
|
155
|
+
}, [dateFrom, dateTo, preview, isSelectionHappened.current]);
|
|
156
|
+
|
|
134
157
|
const currentSelected = useDateRange([dateFrom, dateTo]);
|
|
135
158
|
const ctx = useObjectMemo({
|
|
136
159
|
selectable,
|
|
@@ -188,13 +211,22 @@ const DatePicker = (props: DatePickerProps) => {
|
|
|
188
211
|
/>
|
|
189
212
|
)}
|
|
190
213
|
</Box>
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
214
|
+
{variant === 'filter' && (
|
|
215
|
+
<DatePickerFooter
|
|
216
|
+
onApply={handleApply}
|
|
217
|
+
onClose={handleClose}
|
|
218
|
+
onClear={onClear}
|
|
219
|
+
selected={currentSelected}
|
|
220
|
+
mode={mode || 'range'}
|
|
221
|
+
/>
|
|
222
|
+
)}
|
|
223
|
+
{variant === 'default' && mode === 'day' && (
|
|
224
|
+
<Box display="flex" justifyContent="space-around">
|
|
225
|
+
<Button onClick={() => handleSelect(DateTime.now())} variant="tertiary">
|
|
226
|
+
Today
|
|
227
|
+
</Button>
|
|
228
|
+
</Box>
|
|
229
|
+
)}
|
|
198
230
|
</>
|
|
199
231
|
)}
|
|
200
232
|
</Box>
|
|
@@ -22,12 +22,14 @@ const DatePickerFooter = ({
|
|
|
22
22
|
|
|
23
23
|
const styleGrid = (mobile: string, desktop: string) => (mode === 'day' ? mobile : [mobile, desktop]);
|
|
24
24
|
|
|
25
|
+
const displayDate = selected?.from || selected?.to;
|
|
26
|
+
|
|
25
27
|
return (
|
|
26
28
|
<Box
|
|
27
29
|
display="grid"
|
|
28
30
|
gridTemplateColumns="1fr auto 1fr"
|
|
29
|
-
gridTemplateRows={styleGrid(
|
|
30
|
-
gap={
|
|
31
|
+
gridTemplateRows={styleGrid(displayDate ? '1.25rem 2rem' : '0 2rem', 'unset')}
|
|
32
|
+
gap={displayDate ? 24 : 0}
|
|
31
33
|
data-testid="footer"
|
|
32
34
|
>
|
|
33
35
|
{!!onClear && (
|
|
@@ -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
|
+
};
|