@bitrise/bitkit 10.15.0 → 10.16.2

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.15.0",
4
+ "version": "10.16.2",
5
5
  "repository": "git@github.com:bitrise-io/bitkit.git",
6
6
  "main": "src/index.ts",
7
7
  "license": "UNLICENSED",
@@ -0,0 +1,24 @@
1
+ import { ComponentStory, ComponentMeta } from '@storybook/react';
2
+ import Image from '../Image/Image';
3
+ import AspectRatio from './AspectRatio';
4
+
5
+ export default {
6
+ title: 'Components/AspectRatio',
7
+ component: AspectRatio,
8
+ } as ComponentMeta<typeof AspectRatio>;
9
+
10
+ const Template: ComponentStory<typeof AspectRatio> = (props) => <AspectRatio {...props} />;
11
+
12
+ export const WithImage = Template.bind({});
13
+ WithImage.args = {
14
+ children: <Image alt="Bitrise office" src="bitrise_office.jpg" />,
15
+ maxWidth: 800,
16
+ ratio: 1920 / 1280,
17
+ };
18
+
19
+ export const WithVideo = Template.bind({});
20
+ WithVideo.args = {
21
+ children: <iframe title="Intro to Bitrise" src="https://www.youtube.com/embed/JrCn9xWQ7IM" allowFullScreen />,
22
+ maxWidth: 800,
23
+ ratio: 16 / 9,
24
+ };
@@ -0,0 +1,14 @@
1
+ import { AspectRatio as ChakraAspectRatio, AspectRatioProps, forwardRef } from '@chakra-ui/react';
2
+
3
+ /**
4
+ * AspectRatio component is used to embed responsive videos and maps, etc.
5
+ *
6
+ * https://chakra-ui.com/docs/components/aspect-ratio/usage
7
+ */
8
+ const AspectRatio = forwardRef<AspectRatioProps, 'div'>((props, ref) => {
9
+ return <ChakraAspectRatio {...props} ref={ref} />;
10
+ });
11
+
12
+ export type { AspectRatioProps };
13
+
14
+ export default AspectRatio;
@@ -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;
@@ -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
@@ -163,6 +163,9 @@ export { default as AccordionItem } from './Components/Accordion/AccordionItem';
163
163
  export type { LightBoxProps } from './Components/LightBox/LightBox';
164
164
  export { default as LightBox } from './Components/LightBox/LightBox';
165
165
 
166
+ export type { AspectRatioProps } from './Components/AspectRatio/AspectRatio';
167
+ export { default as AspectRatio } from './Components/AspectRatio/AspectRatio';
168
+
166
169
  export type { TableProps } from './Components/Table/Table';
167
170
  export { default as Table } from './Components/Table/Table';
168
171