@bitrise/bitkit 13.90.0 → 13.92.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,66 +1,237 @@
|
|
|
1
1
|
import type { ComponentStyleConfig } from '@chakra-ui/theme';
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
2
|
+
import { rem } from '../../utils/utils';
|
|
3
|
+
import { AvatarSizes, AvatarVariant } from './Avatar';
|
|
4
|
+
|
|
5
|
+
const COLORS = [
|
|
6
|
+
{
|
|
7
|
+
backgroundColor: 'sys/neutral/subtle',
|
|
8
|
+
color: 'sys/neutral/strong',
|
|
9
|
+
},
|
|
10
|
+
{
|
|
11
|
+
backgroundColor: 'sys/success/subtle',
|
|
12
|
+
color: 'sys/success/strong',
|
|
13
|
+
},
|
|
14
|
+
{
|
|
15
|
+
backgroundColor: 'sys/warning/subtle',
|
|
16
|
+
color: 'sys/warning/strong',
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
backgroundColor: 'sys/orange/subtle',
|
|
20
|
+
color: 'sys/orange/strong',
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
backgroundColor: 'sys/info/subtle',
|
|
24
|
+
color: 'sys/info/strong',
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
backgroundColor: 'sys/critical/subtle',
|
|
28
|
+
color: 'sys/critical/strong',
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
backgroundColor: 'sys/interactive/subtle',
|
|
32
|
+
color: 'sys/interactive/strong',
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
backgroundColor: 'sys/turquoise/subtle',
|
|
36
|
+
color: 'sys/turquoise/strong',
|
|
37
|
+
},
|
|
29
38
|
];
|
|
30
39
|
|
|
31
|
-
const
|
|
32
|
-
const
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
40
|
+
const getStyleForUserVariant = (size: AvatarSizes) => {
|
|
41
|
+
const borderRadius = {
|
|
42
|
+
24: '12',
|
|
43
|
+
32: '16',
|
|
44
|
+
40: '24',
|
|
45
|
+
48: '24',
|
|
46
|
+
64: '12',
|
|
47
|
+
128: '24',
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
return {
|
|
51
|
+
borderRadius: borderRadius[size],
|
|
52
|
+
};
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
const getStyleForWorkspaceVariant = (size: AvatarSizes) => {
|
|
56
|
+
const borderRadius = {
|
|
57
|
+
24: '24',
|
|
58
|
+
32: '8',
|
|
59
|
+
40: '8',
|
|
60
|
+
48: '12',
|
|
61
|
+
64: '12',
|
|
62
|
+
128: '24',
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
return {
|
|
66
|
+
borderRadius: borderRadius[size],
|
|
67
|
+
};
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
const getStyleForBrandVariant = (size: AvatarSizes) => {
|
|
71
|
+
const style = {
|
|
72
|
+
24: {
|
|
73
|
+
borderRadius: '4',
|
|
74
|
+
svg: {
|
|
75
|
+
height: '16',
|
|
76
|
+
width: '16',
|
|
77
|
+
},
|
|
78
|
+
},
|
|
79
|
+
32: {
|
|
80
|
+
borderRadius: '8',
|
|
81
|
+
svg: {
|
|
82
|
+
height: '20',
|
|
83
|
+
width: '20',
|
|
84
|
+
},
|
|
85
|
+
},
|
|
86
|
+
40: {
|
|
87
|
+
borderRadius: '8',
|
|
88
|
+
svg: {
|
|
89
|
+
height: '24',
|
|
90
|
+
width: '24',
|
|
91
|
+
},
|
|
92
|
+
},
|
|
93
|
+
48: {
|
|
94
|
+
borderRadius: '12',
|
|
95
|
+
svg: {
|
|
96
|
+
height: '32',
|
|
97
|
+
width: '32',
|
|
98
|
+
},
|
|
99
|
+
},
|
|
100
|
+
64: {
|
|
101
|
+
borderRadius: '12',
|
|
102
|
+
svg: {
|
|
103
|
+
height: '48',
|
|
104
|
+
width: '48',
|
|
105
|
+
},
|
|
106
|
+
},
|
|
107
|
+
128: {
|
|
108
|
+
borderRadius: '12',
|
|
109
|
+
svg: {
|
|
110
|
+
height: '96',
|
|
111
|
+
width: '96',
|
|
112
|
+
},
|
|
113
|
+
},
|
|
114
|
+
};
|
|
115
|
+
|
|
116
|
+
return {
|
|
117
|
+
...style[size],
|
|
118
|
+
};
|
|
119
|
+
};
|
|
120
|
+
|
|
121
|
+
const getStyleForLettersVariant = (size: AvatarSizes) => {
|
|
122
|
+
const borderRadius = {
|
|
123
|
+
24: '12',
|
|
124
|
+
32: '8',
|
|
125
|
+
40: '8',
|
|
126
|
+
48: '12',
|
|
127
|
+
64: '12',
|
|
128
|
+
128: '12',
|
|
129
|
+
};
|
|
130
|
+
|
|
131
|
+
return {
|
|
132
|
+
borderRadius: borderRadius[size],
|
|
133
|
+
padding: size === '128' ? '16' : undefined,
|
|
134
|
+
};
|
|
135
|
+
};
|
|
136
|
+
|
|
137
|
+
const getStyleForProjectVariant = (size: AvatarSizes) => {
|
|
138
|
+
const borderRadius = {
|
|
139
|
+
24: '8',
|
|
140
|
+
32: '8',
|
|
141
|
+
40: '8',
|
|
142
|
+
48: '12',
|
|
143
|
+
64: '12',
|
|
144
|
+
128: '24',
|
|
145
|
+
};
|
|
146
|
+
|
|
147
|
+
return {
|
|
148
|
+
borderRadius: borderRadius[size],
|
|
149
|
+
};
|
|
150
|
+
};
|
|
151
|
+
|
|
152
|
+
const getStyleForStepVariant = (size: AvatarSizes) => {
|
|
153
|
+
const borderRadius = {
|
|
154
|
+
24: '4',
|
|
155
|
+
32: '4',
|
|
156
|
+
40: '4',
|
|
38
157
|
48: '4',
|
|
39
|
-
64: '
|
|
40
|
-
|
|
41
|
-
128: '8',
|
|
158
|
+
64: '8',
|
|
159
|
+
128: '12',
|
|
42
160
|
};
|
|
43
161
|
|
|
44
162
|
return {
|
|
45
|
-
|
|
46
|
-
height: `${sizeAsNumber / 16}rem`,
|
|
47
|
-
width: `${sizeAsNumber / 16}rem`,
|
|
163
|
+
borderRadius: borderRadius[size],
|
|
48
164
|
};
|
|
49
165
|
};
|
|
50
166
|
|
|
167
|
+
const getSizeBasedTextStyle = (size: AvatarSizes) => {
|
|
168
|
+
const textStyles = {
|
|
169
|
+
24: 'heading/h5',
|
|
170
|
+
32: 'heading/h3',
|
|
171
|
+
40: 'heading/h2',
|
|
172
|
+
48: 'heading/h1',
|
|
173
|
+
64: 'display/sm',
|
|
174
|
+
128: 'display/lg',
|
|
175
|
+
};
|
|
176
|
+
|
|
177
|
+
return {
|
|
178
|
+
textStyle: textStyles[size],
|
|
179
|
+
fontWeight: 'bold',
|
|
180
|
+
};
|
|
181
|
+
};
|
|
182
|
+
|
|
183
|
+
const getStyleBySizeAndType = (size: AvatarSizes, variant: AvatarVariant) => {
|
|
184
|
+
switch (variant) {
|
|
185
|
+
case 'user':
|
|
186
|
+
return {
|
|
187
|
+
...getStyleForUserVariant(size),
|
|
188
|
+
};
|
|
189
|
+
case 'workspace':
|
|
190
|
+
return {
|
|
191
|
+
...getStyleForWorkspaceVariant(size),
|
|
192
|
+
};
|
|
193
|
+
case 'brand':
|
|
194
|
+
return {
|
|
195
|
+
...getStyleForBrandVariant(size),
|
|
196
|
+
};
|
|
197
|
+
case 'letters':
|
|
198
|
+
return {
|
|
199
|
+
...getStyleForLettersVariant(size),
|
|
200
|
+
};
|
|
201
|
+
case 'project':
|
|
202
|
+
return {
|
|
203
|
+
...getStyleForProjectVariant(size),
|
|
204
|
+
};
|
|
205
|
+
case 'step':
|
|
206
|
+
return {
|
|
207
|
+
...getStyleForStepVariant(size),
|
|
208
|
+
};
|
|
209
|
+
}
|
|
210
|
+
};
|
|
211
|
+
|
|
51
212
|
const AvatarTheme: ComponentStyleConfig = {
|
|
52
|
-
baseStyle: ({ name,
|
|
53
|
-
|
|
54
|
-
|
|
213
|
+
baseStyle: ({ name, variant, size }) => {
|
|
214
|
+
let colors = {};
|
|
215
|
+
if (name) {
|
|
216
|
+
const str = name.toUpperCase();
|
|
217
|
+
const seed = str.charCodeAt(0) + str.charCodeAt(str.length - 1);
|
|
218
|
+
colors = COLORS[seed % COLORS.length];
|
|
219
|
+
} else if (variant === 'brand') {
|
|
220
|
+
colors = { backgroundColor: 'sys/neutral/subtle', color: 'text/secondary' };
|
|
221
|
+
}
|
|
55
222
|
|
|
56
223
|
return {
|
|
57
224
|
container: {
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
225
|
+
...colors,
|
|
226
|
+
overflow: 'hidden',
|
|
227
|
+
height: rem(size),
|
|
228
|
+
width: rem(size),
|
|
229
|
+
...getSizeBasedTextStyle(size),
|
|
230
|
+
...getStyleBySizeAndType(size, variant),
|
|
61
231
|
},
|
|
62
232
|
};
|
|
63
233
|
},
|
|
234
|
+
parts: ['container'],
|
|
64
235
|
};
|
|
65
236
|
|
|
66
237
|
export default AvatarTheme;
|
|
@@ -1,10 +1,24 @@
|
|
|
1
1
|
import { Avatar as ChakraAvatar, AvatarProps as ChakraAvatarProps, forwardRef } from '@chakra-ui/react';
|
|
2
|
+
import Icon, { TypeIconName } from '../Icon/Icon';
|
|
2
3
|
|
|
3
|
-
export type AvatarSizes = '
|
|
4
|
+
export type AvatarSizes = '24' | '32' | '40' | '48' | '64' | '128';
|
|
5
|
+
export type AvatarVariant = 'user' | 'workspace' | 'brand' | 'letters' | 'project' | 'step';
|
|
4
6
|
|
|
5
|
-
export
|
|
6
|
-
|
|
7
|
-
|
|
7
|
+
export type AvatarProps = (
|
|
8
|
+
| {
|
|
9
|
+
iconName: TypeIconName;
|
|
10
|
+
name?: never;
|
|
11
|
+
size?: AvatarSizes;
|
|
12
|
+
variant?: 'brand';
|
|
13
|
+
}
|
|
14
|
+
| {
|
|
15
|
+
iconName?: never;
|
|
16
|
+
name: string;
|
|
17
|
+
size?: AvatarSizes;
|
|
18
|
+
variant?: 'user' | 'workspace' | 'letters' | 'project' | 'step';
|
|
19
|
+
}
|
|
20
|
+
) &
|
|
21
|
+
ChakraAvatarProps;
|
|
8
22
|
|
|
9
23
|
const getInitials = (name: string) => {
|
|
10
24
|
if (name.length < 3) {
|
|
@@ -16,8 +30,15 @@ const getInitials = (name: string) => {
|
|
|
16
30
|
return `${nameArray[0]}${nameArray[nameArray.length - 1]}`;
|
|
17
31
|
};
|
|
18
32
|
|
|
19
|
-
const Avatar = forwardRef<AvatarProps, 'span'>((props, ref) =>
|
|
20
|
-
|
|
21
|
-
|
|
33
|
+
const Avatar = forwardRef<AvatarProps, 'span'>((props, ref) => {
|
|
34
|
+
const { iconName, variant = 'user', size = '32', ...rest } = props;
|
|
35
|
+
|
|
36
|
+
let icon;
|
|
37
|
+
if (iconName) {
|
|
38
|
+
icon = <Icon color="sys/neutral/strong" name={iconName} />;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
return <ChakraAvatar getInitials={getInitials} icon={icon} size={size} variant={variant} {...rest} ref={ref} />;
|
|
42
|
+
});
|
|
22
43
|
|
|
23
44
|
export default Avatar;
|
|
@@ -62,7 +62,7 @@ const Sidebar = forwardRef<SidebarProps, 'nav'>(({ children, title, ...boxProps
|
|
|
62
62
|
return (
|
|
63
63
|
<SidebarContext value={theme}>
|
|
64
64
|
<Box as="nav" display="flex" flexDirection="column" {...boxProps} ref={ref}>
|
|
65
|
-
<SidebarHeader title={title} />
|
|
65
|
+
{title && <SidebarHeader title={title} />}
|
|
66
66
|
{children}
|
|
67
67
|
</Box>
|
|
68
68
|
</SidebarContext>
|