@bitrise/bitkit 10.16.0 → 10.16.3

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.0",
4
+ "version": "10.16.3",
5
5
  "repository": "git@github.com:bitrise-io/bitkit.git",
6
6
  "main": "src/index.ts",
7
7
  "license": "UNLICENSED",
@@ -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}
@@ -10,7 +10,7 @@ export type Props = {
10
10
  * input.
11
11
  */
12
12
  const InputLabel: React.FunctionComponent<Props> = (props: Props) => {
13
- return <Text {...props} as="label" marginY="4" size="3" color="purple.10" fontWeight="bold" />;
13
+ return <Text as="label" marginY="4" size="3" color="purple.10" fontWeight="bold" {...props} />;
14
14
  };
15
15
 
16
16
  export default InputLabel;
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