@bitrise/bitkit 9.34.1 → 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 CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@bitrise/bitkit",
3
3
  "description": "Bitrise React component library",
4
- "version": "9.34.1",
4
+ "version": "9.36.0-alpha-chakra.1",
5
5
  "repository": "git@github.com:bitrise-io/bitkit.git",
6
6
  "main": "src/index.ts",
7
7
  "license": "UNLICENSED",
@@ -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;
@@ -1,7 +1,7 @@
1
- import type { SystemStyleObject } from '@chakra-ui/theme-tools';
1
+ import type { ComponentStyleConfig } from '@chakra-ui/theme';
2
2
 
3
- const DialogTheme: SystemStyleObject = {
4
- baseStyle: {
3
+ const DialogTheme: ComponentStyleConfig = {
4
+ baseStyle: ({ scrollBehavior }) => ({
5
5
  overlay: {
6
6
  backgroundColor: 'rgba(0, 0, 0, .5)',
7
7
  },
@@ -9,13 +9,15 @@ const DialogTheme: SystemStyleObject = {
9
9
  display: 'flex',
10
10
  justifyContent: 'center',
11
11
  alignItems: 'flex-start',
12
- overflow: 'auto',
12
+ overflow: scrollBehavior === 'inside' ? 'hidden' : 'auto',
13
+ zIndex: 'dialog',
13
14
  },
14
15
  dialog: {
15
16
  borderRadius: '8',
16
17
  backgroundColor: 'neutral.100',
17
18
  boxShadow: 'large',
18
19
  marginY: '128',
20
+ maxH: scrollBehavior === 'inside' ? 'calc(100% - 16rem)' : undefined,
19
21
  },
20
22
  header: {
21
23
  padding: '24',
@@ -42,7 +44,7 @@ const DialogTheme: SystemStyleObject = {
42
44
  padding: '32',
43
45
  paddingTop: '48',
44
46
  },
45
- },
47
+ }),
46
48
  sizes: {
47
49
  small: {
48
50
  dialog: {
@@ -61,7 +63,7 @@ const DialogTheme: SystemStyleObject = {
61
63
  },
62
64
  full: {
63
65
  dialogContainer: {
64
- zIndex: 1000,
66
+ zIndex: 'fullDialog',
65
67
  },
66
68
  dialog: {
67
69
  position: 'absolute',
@@ -71,6 +73,7 @@ const DialogTheme: SystemStyleObject = {
71
73
  right: '32',
72
74
  top: '32',
73
75
  bottom: '32',
76
+ maxH: 'auto',
74
77
  },
75
78
  },
76
79
  mobile: {
@@ -25,17 +25,24 @@ export const useDialog = (): DialogState => {
25
25
  onOpen,
26
26
  };
27
27
  };
28
- export interface DialogProps extends HTMLChakraProps<'section'> {
28
+ export interface DialogProps extends Omit<HTMLChakraProps<'section'>, 'scrollBehavior'> {
29
29
  dataTestid?: string;
30
30
  size?: 'small' | 'medium' | 'large' | 'full';
31
+ scrollBehavior?: 'inside' | 'outside';
31
32
  state: DialogState;
32
33
  title: string;
33
34
  }
34
35
 
35
- const Dialog = ({ children, dataTestid, state, size, title, ...rest }: DialogProps) => {
36
+ const Dialog = ({ children, dataTestid, scrollBehavior, state, size, title, ...rest }: DialogProps) => {
36
37
  const dialogSize = useBreakpointValue({ mobile: 'mobile', desktop: size });
37
38
  return (
38
- <Modal closeOnOverlayClick={false} isOpen={state.isOpen} onClose={state.onClose} size={dialogSize}>
39
+ <Modal
40
+ closeOnOverlayClick={false}
41
+ isOpen={state.isOpen}
42
+ onClose={state.onClose}
43
+ scrollBehavior={scrollBehavior}
44
+ size={dialogSize}
45
+ >
39
46
  <ModalOverlay />
40
47
  <ModalContent data-testid={dataTestid} {...rest}>
41
48
  <ModalHeader>
@@ -53,6 +60,7 @@ const Dialog = ({ children, dataTestid, state, size, title, ...rest }: DialogPro
53
60
  };
54
61
 
55
62
  Dialog.defaultProps = {
63
+ scrollBehavior: 'outside',
56
64
  size: 'medium',
57
65
  } as DialogProps;
58
66
 
@@ -2,9 +2,6 @@ import type { SystemStyleObject } from '@chakra-ui/theme-tools';
2
2
 
3
3
  const PopoverTheme: SystemStyleObject = {
4
4
  baseStyle: {
5
- popper: {
6
- zIndex: 10,
7
- },
8
5
  content: {
9
6
  backgroundColor: 'neutral.100',
10
7
  borderRadius: 8,
@@ -1,13 +1,22 @@
1
- import { ReactNode } from 'react';
1
+ import { ReactNode, Fragment } from 'react';
2
2
  import {
3
3
  PopoverContentProps as ChakraPopoverContentProps,
4
4
  PopoverContent as ChakraPopoverContent,
5
+ Portal,
5
6
  } from '@chakra-ui/react';
6
7
 
7
8
  export interface PopoverContentProps extends ChakraPopoverContentProps {
8
9
  children: ReactNode;
10
+ withoutPortal?: boolean;
9
11
  }
10
12
 
11
- const PopoverContent = (props: PopoverContentProps) => <ChakraPopoverContent {...props} />;
13
+ const PopoverContent = ({ withoutPortal, ...rest }: PopoverContentProps) => {
14
+ const Wrapper = withoutPortal ? Fragment : Portal;
15
+ return (
16
+ <Wrapper>
17
+ <ChakraPopoverContent {...rest} />
18
+ </Wrapper>
19
+ );
20
+ };
12
21
 
13
22
  export default PopoverContent;
@@ -0,0 +1,10 @@
1
+ const zIndices = {
2
+ hide: -1,
3
+ auto: 'auto',
4
+ base: 0,
5
+ header: 1100,
6
+ fullDialog: 1200,
7
+ dialog: 1300,
8
+ };
9
+
10
+ export default zIndices;
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';
@@ -21,6 +22,7 @@ import radii from './Foundations/Radii/Radii';
21
22
  import shadows from './Foundations/Shadows/Shadows';
22
23
  import sizes from './Foundations/Sizes/Sizes';
23
24
  import typography from './Foundations/Typography/Typography';
25
+ import zIndices from './Foundations/Zindex/Zindex';
24
26
 
25
27
  const theme = {
26
28
  config: {
@@ -33,6 +35,7 @@ const theme = {
33
35
  shadows,
34
36
  sizes,
35
37
  space: sizes,
38
+ zIndices,
36
39
  styles: {
37
40
  global: {
38
41
  body: {
@@ -57,6 +60,7 @@ const theme = {
57
60
  },
58
61
  },
59
62
  components: {
63
+ Avatar,
60
64
  Badge,
61
65
  Button,
62
66
  Card,