@bitrise/bitkit 9.35.0 → 9.36.0-alpha-chakra.1
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/Avatar/Avatar.stories.tsx +15 -0
- package/src/Components/Avatar/Avatar.theme.ts +66 -0
- package/src/Components/Avatar/Avatar.tsx +24 -0
- package/src/index.ts +2 -0
- package/src/old.ts +0 -3
- package/src/theme.ts +2 -0
- package/src/tsconfig.tsbuildinfo +1 -1
package/package.json
CHANGED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { ComponentStory, ComponentMeta } from '@storybook/react';
|
|
2
|
+
import Avatar from './Avatar';
|
|
3
|
+
|
|
4
|
+
export default {
|
|
5
|
+
title: 'Components/Avatar',
|
|
6
|
+
component: Avatar,
|
|
7
|
+
} as ComponentMeta<typeof Avatar>;
|
|
8
|
+
|
|
9
|
+
export const WithProps: ComponentStory<typeof Avatar> = ({ contentProps, ...props }) => <Avatar {...props} />;
|
|
10
|
+
|
|
11
|
+
WithProps.args = {
|
|
12
|
+
...Avatar.defaultProps,
|
|
13
|
+
name: 'Bitrise website',
|
|
14
|
+
src: 'https://bitrise-public-content-production.s3.amazonaws.com/org-icons/default_avatar-02.png',
|
|
15
|
+
};
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import type { ComponentStyleConfig } from '@chakra-ui/theme';
|
|
2
|
+
import { AvatarSizes } from './Avatar';
|
|
3
|
+
|
|
4
|
+
const BACKGROUND_COLORS = [
|
|
5
|
+
'#68442c',
|
|
6
|
+
'#86d641',
|
|
7
|
+
'#a775db',
|
|
8
|
+
'#df5ac3',
|
|
9
|
+
'#46bee8',
|
|
10
|
+
'#63c99a',
|
|
11
|
+
'#19937c',
|
|
12
|
+
'#ed544c',
|
|
13
|
+
'#ff931e',
|
|
14
|
+
'#107ec1',
|
|
15
|
+
'#48e1ed',
|
|
16
|
+
'#743da5',
|
|
17
|
+
'#f9d128',
|
|
18
|
+
'#ff931e',
|
|
19
|
+
'#9e4b39',
|
|
20
|
+
'#b51c98',
|
|
21
|
+
'#b20202',
|
|
22
|
+
'#bf8a66',
|
|
23
|
+
'#2c3f50',
|
|
24
|
+
'#441f62',
|
|
25
|
+
'#0c5b4c',
|
|
26
|
+
'#391401',
|
|
27
|
+
'#27ae61',
|
|
28
|
+
'#ef7bef',
|
|
29
|
+
];
|
|
30
|
+
|
|
31
|
+
const getSize = (size: AvatarSizes) => {
|
|
32
|
+
const sizeAsNumber = Number(size);
|
|
33
|
+
const fontSizes = {
|
|
34
|
+
16: '9px',
|
|
35
|
+
24: '1',
|
|
36
|
+
32: '3',
|
|
37
|
+
40: '3',
|
|
38
|
+
48: '4',
|
|
39
|
+
64: '5',
|
|
40
|
+
96: '7',
|
|
41
|
+
128: '8',
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
return {
|
|
45
|
+
fontSize: fontSizes[sizeAsNumber as keyof typeof fontSizes],
|
|
46
|
+
height: `${sizeAsNumber / 16}rem`,
|
|
47
|
+
width: `${sizeAsNumber / 16}rem`,
|
|
48
|
+
};
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
const AvatarTheme: ComponentStyleConfig = {
|
|
52
|
+
baseStyle: ({ name, size }) => {
|
|
53
|
+
const str = name.toUpperCase();
|
|
54
|
+
const seed = str.charCodeAt(0) + str.charCodeAt(str.length - 1);
|
|
55
|
+
|
|
56
|
+
return {
|
|
57
|
+
container: {
|
|
58
|
+
backgroundColor: BACKGROUND_COLORS[seed % BACKGROUND_COLORS.length],
|
|
59
|
+
color: 'neutral.100',
|
|
60
|
+
...getSize(size),
|
|
61
|
+
},
|
|
62
|
+
};
|
|
63
|
+
},
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
export default AvatarTheme;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { Avatar as ChakraAvatar, AvatarProps as ChakraAvatarProps, forwardRef } from '@chakra-ui/react';
|
|
2
|
+
import { Radii } from '../../Foundations/Radii/Radii';
|
|
3
|
+
|
|
4
|
+
export type AvatarSizes = '16' | '24' | '32' | '40' | '48' | '64' | '96' | '128';
|
|
5
|
+
|
|
6
|
+
export interface AvatarProps extends ChakraAvatarProps {
|
|
7
|
+
borderRadius?: keyof Radii;
|
|
8
|
+
size?: AvatarSizes;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
const getInitials = (name: string) => {
|
|
12
|
+
return `${name.charAt(0)}${name.charAt(name.length - 1)}`;
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
const Avatar = forwardRef<AvatarProps, 'span'>((props, ref) => (
|
|
16
|
+
<ChakraAvatar getInitials={getInitials} {...props} ref={ref} />
|
|
17
|
+
));
|
|
18
|
+
|
|
19
|
+
Avatar.defaultProps = {
|
|
20
|
+
borderRadius: '8',
|
|
21
|
+
size: '32',
|
|
22
|
+
} as AvatarProps;
|
|
23
|
+
|
|
24
|
+
export default Avatar;
|
package/src/index.ts
CHANGED
|
@@ -110,3 +110,5 @@ export { default as PopoverTrigger } from './Components/Popover/PopoverTrigger';
|
|
|
110
110
|
export type { PopoverContentProps } from './Components/Popover/PopoverContent';
|
|
111
111
|
export { default as PopoverContent } from './Components/Popover/PopoverContent';
|
|
112
112
|
|
|
113
|
+
export type { AvatarProps } from './Components/Avatar/Avatar';
|
|
114
|
+
export { default as Avatar } from './Components/Avatar/Avatar';
|
package/src/old.ts
CHANGED
|
@@ -34,9 +34,6 @@ export { default as AppLayoutMain } from './Old/AppLayout/AppLayoutMain';
|
|
|
34
34
|
export type { Props as AppLayoutSidebarProps } from './Old/AppLayout/AppLayoutSidebar';
|
|
35
35
|
export { default as AppLayoutSidebar } from './Old/AppLayout/AppLayoutSidebar';
|
|
36
36
|
|
|
37
|
-
export type { Props as AvatarProps } from './Old/Avatar/Avatar';
|
|
38
|
-
export { default as Avatar } from './Old/Avatar/Avatar';
|
|
39
|
-
|
|
40
37
|
export type { Props as BaseProps } from './Old/Base/Base';
|
|
41
38
|
export type { TypeBorderRadius } from './Old/Base/Base';
|
|
42
39
|
export type { TypeColors } from './Old/Base/Base';
|
package/src/theme.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import Avatar from './Components/Avatar/Avatar.theme';
|
|
1
2
|
import Badge from './Components/Badge/Badge.theme';
|
|
2
3
|
import Button from './Components/Button/Button.theme';
|
|
3
4
|
import Card from './Components/Card/Card.theme';
|
|
@@ -59,6 +60,7 @@ const theme = {
|
|
|
59
60
|
},
|
|
60
61
|
},
|
|
61
62
|
components: {
|
|
63
|
+
Avatar,
|
|
62
64
|
Badge,
|
|
63
65
|
Button,
|
|
64
66
|
Card,
|