@bitrise/bitkit 10.16.1 → 10.16.4

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": "10.16.1",
4
+ "version": "10.16.4",
5
5
  "repository": "git@github.com:bitrise-io/bitkit.git",
6
6
  "main": "src/index.ts",
7
7
  "license": "UNLICENSED",
@@ -56,5 +56,8 @@ export const DefaultVariant: ComponentStory<typeof Accordion> = (props) => (
56
56
  Content - you can use any style prop on AccordionItem
57
57
  </AccordionItem>
58
58
  <AccordionItem buttonContent={<ButtonContentElement title="Without children" />} id="third" />
59
+ <AccordionItem buttonContent="Fourth, enabled element" fontSize="2" id="fourth">
60
+ Fourth, enabled element
61
+ </AccordionItem>
59
62
  </Accordion>
60
63
  );
@@ -1,5 +1,22 @@
1
1
  import type { ComponentStyleConfig } from '@chakra-ui/theme';
2
2
 
3
+ const buttonStyle = {
4
+ display: 'flex',
5
+ alignItems: 'center',
6
+ justifyContent: 'space-between',
7
+ width: '100%',
8
+ padding: '16',
9
+ borderBottom: '1px solid',
10
+ borderColor: 'neutral.93',
11
+ borderRadius: '8',
12
+ };
13
+
14
+ const iconStyle = {
15
+ width: '24',
16
+ height: '24',
17
+ marginLeft: '16',
18
+ };
19
+
3
20
  const AccordionTheme: ComponentStyleConfig = {
4
21
  baseStyle: ({ colorScheme }) => ({
5
22
  item: {
@@ -9,28 +26,29 @@ const AccordionTheme: ComponentStyleConfig = {
9
26
  boxShadow: 'small',
10
27
  marginBottom: '16',
11
28
  },
12
- button: {
13
- display: 'flex',
14
- alignItems: 'center',
15
- justifyContent: 'space-between',
16
- width: '100%',
17
- padding: '16',
29
+ enabledButton: {
30
+ ...buttonStyle,
18
31
  background: colorScheme === 'gray' ? 'neutral.95' : 'neutral.100',
19
- borderBottom: '1px solid',
20
- borderColor: 'neutral.93',
21
- borderRadius: '8',
22
- '&[type="button"]:hover': {
32
+ _hover: {
23
33
  background: 'purple.95',
24
34
  },
25
- '&[aria-expanded="true"]': {
35
+ _expanded: {
26
36
  borderBottomLeftRadius: '0',
27
37
  borderBottomRightRadius: '0',
28
38
  },
29
39
  },
30
- icon: {
31
- width: '24',
32
- height: '24',
33
- marginLeft: '16',
40
+ disabledButton: {
41
+ ...buttonStyle,
42
+ background: colorScheme === 'gray' ? 'neutral.95' : 'neutral.100',
43
+ cursor: 'default',
44
+ },
45
+ enabledIcon: {
46
+ ...iconStyle,
47
+ },
48
+ disabledIcon: {
49
+ ...iconStyle,
50
+ opacity: '0.4',
51
+ transform: 'none',
34
52
  },
35
53
  panel: {
36
54
  padding: '16',
@@ -8,7 +8,6 @@ import {
8
8
  AccordionIcon,
9
9
  useAccordionStyles,
10
10
  } from '@chakra-ui/react';
11
- import Box from '../Box/Box';
12
11
  import Text from '../Text/Text';
13
12
 
14
13
  export interface AccordionItemProps extends AccordionPanelProps {
@@ -21,14 +20,12 @@ const AccordionItem = (props: AccordionItemProps) => {
21
20
  const { buttonContent, children, id, ...rest } = props;
22
21
  const styles = useAccordionStyles();
23
22
 
24
- const ButtonComponent = children ? AccordionButton : Box;
25
-
26
23
  return (
27
24
  <ChakraAccordionItem sx={styles.item} id={id}>
28
- <ButtonComponent sx={styles.button}>
25
+ <AccordionButton sx={children ? styles.enabledButton : styles.disabledButton}>
29
26
  {isValidElement(buttonContent) ? buttonContent : <Text as="span">{buttonContent}</Text>}
30
- <AccordionIcon opacity={children ? 1 : 0.4} />
31
- </ButtonComponent>
27
+ <AccordionIcon sx={children ? styles.enabledIcon : styles.disabledIcon} />
28
+ </AccordionButton>
32
29
  {!!children && <AccordionPanel {...rest}>{children}</AccordionPanel>}
33
30
  </ChakraAccordionItem>
34
31
  );
@@ -1,6 +1,7 @@
1
1
  import { Story, ComponentMeta } from '@storybook/react';
2
2
  import { useDisclosure } from '@chakra-ui/react';
3
3
  import Button from '../Button/Button';
4
+ import AspectRatio from '../AspectRatio/AspectRatio';
4
5
  import LightBox, { LightBoxProps } from './LightBox';
5
6
 
6
7
  export default {
@@ -13,15 +14,15 @@ export const WithProps: Story<LightBoxProps> = ({ ...props }: LightBoxProps) =>
13
14
 
14
15
  const getContent = () => {
15
16
  return (
16
- <iframe
17
- id="ytplayer"
18
- title="Intro to Bitrise"
19
- width="100%"
20
- height="500"
21
- src="https://www.youtube.com/embed/JrCn9xWQ7IM"
22
- frameBorder="0"
23
- allowFullScreen
24
- />
17
+ <AspectRatio ratio={props.size === 'full' ? 1.33 : 1.77}>
18
+ <iframe
19
+ id="ytplayer"
20
+ title="Intro to Bitrise"
21
+ src="https://www.youtube.com/embed/JrCn9xWQ7IM"
22
+ frameBorder="0"
23
+ allowFullScreen
24
+ />
25
+ </AspectRatio>
25
26
  );
26
27
  };
27
28
 
@@ -34,3 +35,5 @@ export const WithProps: Story<LightBoxProps> = ({ ...props }: LightBoxProps) =>
34
35
  </>
35
36
  );
36
37
  };
38
+
39
+ WithProps.args = { ...LightBox.defaultProps };
@@ -1,16 +1,26 @@
1
- import { Modal, ModalOverlay, ModalContent, usePrefersReducedMotion, HTMLChakraProps } from '@chakra-ui/react';
1
+ import {
2
+ Modal,
3
+ ModalOverlay,
4
+ ModalContent,
5
+ useBreakpointValue,
6
+ usePrefersReducedMotion,
7
+ HTMLChakraProps,
8
+ } from '@chakra-ui/react';
9
+ import { BREAKPOINTS } from '../../Foundations/Breakpoints/Breakpoints';
2
10
 
3
11
  export interface LightBoxProps extends Omit<HTMLChakraProps<'section'>, 'scrollBehavior'> {
4
12
  dataTestid?: string;
13
+ size?: 'small' | 'medium' | 'large' | 'full';
5
14
  isOpen: boolean;
6
15
  onClose(): void;
7
16
  }
8
17
 
9
- const LightBox = ({ children, dataTestid, isOpen, onClose, ...rest }: LightBoxProps) => {
18
+ const LightBox = ({ children, dataTestid, size, isOpen, onClose, ...rest }: LightBoxProps) => {
10
19
  const prefersReducedMotion = usePrefersReducedMotion();
20
+ const dialogSize = useBreakpointValue({ [BREAKPOINTS.MOBILE]: 'mobile', [BREAKPOINTS.DESKTOP]: size });
11
21
 
12
22
  return (
13
- <Modal isOpen={isOpen} motionPreset={prefersReducedMotion ? 'none' : 'scale'} onClose={onClose}>
23
+ <Modal isOpen={isOpen} motionPreset={prefersReducedMotion ? 'none' : 'scale'} onClose={onClose} size={dialogSize}>
14
24
  <ModalOverlay />
15
25
  <ModalContent borderRadius="0" data-testid={dataTestid} {...rest}>
16
26
  {children}
@@ -19,4 +29,8 @@ const LightBox = ({ children, dataTestid, isOpen, onClose, ...rest }: LightBoxPr
19
29
  );
20
30
  };
21
31
 
32
+ LightBox.defaultProps = {
33
+ size: 'large',
34
+ } as LightBoxProps;
35
+
22
36
  export default LightBox;
@@ -56,3 +56,11 @@ WithoutIcon.args = {
56
56
  action: undefined,
57
57
  showIcon: false,
58
58
  };
59
+
60
+ export const WithAction: ComponentStoryFn<typeof Notification> = (props) => <Template {...props} />;
61
+ WithAction.storyName = 'With action';
62
+ WithAction.args = {
63
+ action: {
64
+ label: 'Upgrade',
65
+ },
66
+ };
@@ -1,4 +1,4 @@
1
- import { createContext, ReactNode, useContext, useMemo } from 'react';
1
+ import { cloneElement, createContext, ReactElement, useContext, useMemo } from 'react';
2
2
  import {
3
3
  Alert as ChakraAlert,
4
4
  AlertTitle as NotificationTitle,
@@ -15,7 +15,9 @@ import CloseButton from '../CloseButton/CloseButton';
15
15
  import ColorButton, { ColorButtonProps } from '../ColorButton/ColorButton';
16
16
  import Icon, { TypeIconName } from '../Icon/Icon';
17
17
 
18
- const STATUSES: Record<string, { colorScheme: ColorScheme; defaultIcon: ReactNode }> = {
18
+ type NotificationStatus = 'info' | 'error' | 'success' | 'warning' | 'progress';
19
+
20
+ const STATUSES: Record<NotificationStatus, { colorScheme: ColorScheme; defaultIcon: ReactElement }> = {
19
21
  info: { colorScheme: 'blue', defaultIcon: <Icon name="Info" /> },
20
22
  error: { colorScheme: 'red', defaultIcon: <Icon name="ErrorGeneral" /> },
21
23
  success: { colorScheme: 'green', defaultIcon: <Icon name="Tick" /> },
@@ -24,25 +26,28 @@ const STATUSES: Record<string, { colorScheme: ColorScheme; defaultIcon: ReactNod
24
26
  colorScheme: 'purple',
25
27
  defaultIcon: (
26
28
  <chakra.span w="24" h="24" p="2">
27
- <Spinner w="100%" h="100%" />
29
+ <Spinner w="100" h="100" />
28
30
  </chakra.span>
29
31
  ),
30
32
  },
31
33
  } as const;
32
34
 
33
- export type ActionProps = { label: string; href?: string; onClick?: () => void } & Omit<
34
- ColorButtonProps,
35
- 'as' | 'onClick' | 'colorScheme'
36
- >;
35
+ export type ActionProps = {
36
+ label: string;
37
+ href?: string;
38
+ onClick?: () => void;
39
+ } & Omit<ColorButtonProps, 'as' | 'onClick' | 'colorScheme'>;
37
40
  export interface NotificationProps extends Omit<AlertProps, 'status' | 'colorScheme' | 'onClose'> {
38
- status: keyof typeof STATUSES;
41
+ status: NotificationStatus;
39
42
  onClose?: () => void;
40
43
  action?: ActionProps;
41
44
  iconName?: TypeIconName;
42
45
  showIcon?: boolean;
43
46
  }
44
47
 
45
- const ActionContext = createContext<{ colorScheme: ColorScheme }>({ colorScheme: 'blue' });
48
+ const ActionContext = createContext<{ colorScheme: ColorScheme }>({
49
+ colorScheme: 'blue',
50
+ });
46
51
 
47
52
  const NotificationAction = ({ label, href, ...rest }: ActionProps) => {
48
53
  const actionContext = useContext(ActionContext);
@@ -69,11 +74,14 @@ const Notification = forwardRef<NotificationProps, 'div'>((props, ref) => {
69
74
  actionButton = <NotificationAction marginRight="12" {...action} alignSelf="center" />;
70
75
  }
71
76
  const actionContext = useMemo(() => ({ colorScheme }), [colorScheme]);
77
+ // This is needed when the actionButton is rendered with a one-liner text.
78
+ // Without this both the icon and the text would be strangely aligned.
79
+ const marginTop = actionButton ? 4 : undefined;
72
80
  return (
73
81
  <ChakraAlert ref={ref} {...rest} colorScheme={colorScheme}>
74
82
  <ActionContext.Provider value={actionContext}>
75
- {showIcon && <Box flexShrink={0}>{icon}</Box>}
76
- <Box wordBreak="break-word" display="flex" flexDirection="column" flexGrow={1}>
83
+ {showIcon && cloneElement(icon, { flexShrink: 0, marginTop })}
84
+ <Box wordBreak="break-word" display="flex" flexDirection="column" flexGrow={1} marginTop={marginTop}>
77
85
  {children}
78
86
  </Box>
79
87
  {actionButton}
package/src/index.ts CHANGED
@@ -152,6 +152,9 @@ export {
152
152
  typedDropdown,
153
153
  } from './Components/Dropdown/Dropdown';
154
154
 
155
+ export type { NotificationProps } from './Components/Notification/Notification';
156
+ export { default as Notification } from './Components/Notification/Notification';
157
+
155
158
  export { BREAKPOINTS } from './Foundations/Breakpoints/Breakpoints';
156
159
 
157
160
  export type { AccordionProps } from './Components/Accordion/Accordion';
package/src/old.ts CHANGED
@@ -51,9 +51,6 @@ export { default as InputLabel } from './Old/Input/InputLabel';
51
51
  export type { Props as LogoProps } from './Old/Logo/Logo';
52
52
  export { default as Logo } from './Old/Logo/Logo';
53
53
 
54
- export type { Props as NotificationProps } from './Old/Notification/Notification';
55
- export { default as Notification } from './Old/Notification/Notification';
56
-
57
54
  export type { Props as ProgressBarProps } from './Old/Progress/ProgressBar';
58
55
  export { default as ProgressBar } from './Old/Progress/ProgressBar';
59
56