@bitrise/bitkit 10.24.2 → 10.25.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.24.2",
4
+ "version": "10.25.2",
5
5
  "repository": "git@github.com:bitrise-io/bitkit.git",
6
6
  "main": "src/index.ts",
7
7
  "license": "UNLICENSED",
@@ -24,7 +24,7 @@ const getItemIds = (props: AccordionProps) => {
24
24
  * Accordions display a list of high-level options that can expand/collapse to reveal more information.
25
25
  */
26
26
  const Accordion = (props: AccordionProps) => {
27
- const prefersReducedMotion = usePrefersReducedMotion();
27
+ const prefersReducedMotion = usePrefersReducedMotion({ ssr: false });
28
28
  const { children, colorScheme, onChange, ...rest } = props;
29
29
  const itemIds = getItemIds(props);
30
30
 
@@ -38,7 +38,7 @@ const Dialog = ({
38
38
  ...rest
39
39
  }: DialogProps) => {
40
40
  const dialogSize = useBreakpointValue({ [BREAKPOINTS.MOBILE]: 'mobile', [BREAKPOINTS.DESKTOP]: size });
41
- const prefersReducedMotion = usePrefersReducedMotion();
41
+ const prefersReducedMotion = usePrefersReducedMotion({ ssr: false });
42
42
 
43
43
  return (
44
44
  <Modal
@@ -16,7 +16,7 @@ export interface LightBoxProps extends Omit<HTMLChakraProps<'section'>, 'scrollB
16
16
  }
17
17
 
18
18
  const LightBox = ({ children, dataTestid, size, isOpen, onClose, ...rest }: LightBoxProps) => {
19
- const prefersReducedMotion = usePrefersReducedMotion();
19
+ const prefersReducedMotion = usePrefersReducedMotion({ ssr: false });
20
20
  const dialogSize = useBreakpointValue({ [BREAKPOINTS.MOBILE]: 'mobile', [BREAKPOINTS.DESKTOP]: size });
21
21
 
22
22
  return (
@@ -17,5 +17,6 @@ WithProps.args = sortObjectByKey({
17
17
  children: 'The quick brown fox jumps over the lazy dog.',
18
18
  fontWeight: 'normal',
19
19
  letterSpacing: 'normal',
20
+ size: ['5', '3'],
20
21
  textTransform: 'none',
21
22
  });
@@ -1,13 +1,15 @@
1
1
  export const BREAKPOINTS = {
2
2
  MOBILE: 'base',
3
+ TABLET: 'tablet',
3
4
  DESKTOP: 'desktop',
4
- WIDE: 'wide',
5
+ WIDEDESKTOP: 'wideDesktop',
5
6
  };
6
7
 
7
8
  const breakpoints = {
8
9
  [BREAKPOINTS.MOBILE]: '0rem',
9
- [BREAKPOINTS.DESKTOP]: '53rem', // 848px
10
- [BREAKPOINTS.WIDE]: '101rem', // 1616px
10
+ [BREAKPOINTS.TABLET]: '53rem', // 848px
11
+ [BREAKPOINTS.DESKTOP]: '80rem', // 1280px
12
+ [BREAKPOINTS.WIDEDESKTOP]: '101rem', // 1616px
11
13
  };
12
14
 
13
15
  export default breakpoints;
@@ -0,0 +1,95 @@
1
+ import { Code } from '@chakra-ui/react';
2
+ import Box from '../../Components/Box/Box';
3
+ import Card from '../../Components/Card/Card';
4
+ import CardContent from '../../Components/Card/CardContent';
5
+ import Link from '../../Components/Link/Link';
6
+ import List from '../../Components/List/List';
7
+ import ListItem from '../../Components/List/ListItem';
8
+ import Provider from '../../Components/Provider/Provider';
9
+ import Text from '../../Components/Text/Text';
10
+
11
+ import useResponsive from '../../hooks/useResponsive';
12
+
13
+ export const Responsive = () => {
14
+ const { isMobile, isTablet, isDesktop, isWideDesktop } = useResponsive();
15
+ return (
16
+ <Provider>
17
+ <Text as="h2" size="8" marginBottom="24">
18
+ Responsive solutions
19
+ </Text>
20
+
21
+ <Card boxShadow="medium" marginBottom="48" padding="24">
22
+ <CardContent>
23
+ <Text as="h3" size="6" marginBottom="12">
24
+ With responsive style props
25
+ </Text>
26
+ <Text marginBottom="32">
27
+ Use the array syntax on style props, when the element should be always visible, but you want to change
28
+ margin, padding, etc on it.
29
+ <br />
30
+ <Link
31
+ colorScheme="purple"
32
+ href="https://chakra-ui.com/docs/styled-system/responsive-styles#the-array-syntax"
33
+ isExternal
34
+ isUnderlined
35
+ >
36
+ https://chakra-ui.com/docs/styled-system/responsive-styles#the-array-syntax
37
+ </Link>
38
+ </Text>
39
+ <Text marginBottom="8">We have 4 breakpoints:</Text>
40
+ <Box
41
+ backgroundColor={['green.40', 'purple.30', 'red.40', 'neutral.40']}
42
+ color="neutral.93"
43
+ paddingX="24"
44
+ paddingY="16"
45
+ transition="200ms"
46
+ >
47
+ This Box is
48
+ <List>
49
+ <ListItem>green below 848px (53rem)</ListItem>
50
+ <ListItem>purple from 848px (53rem) but below 1280px (80rem)</ListItem>
51
+ <ListItem>red from 1280px (80rem) but below 1616px (101rem)</ListItem>
52
+ <ListItem>gray from 1616px (101rem)</ListItem>
53
+ </List>
54
+ </Box>
55
+ </CardContent>
56
+ </Card>
57
+
58
+ <Card boxShadow="medium" marginBottom="24" padding="24">
59
+ <CardContent>
60
+ <Text as="h3" size="6" marginBottom="12">
61
+ With useResponsive hook
62
+ </Text>
63
+ <Text marginBottom="24">
64
+ Use this hook when you want to render something conditionally. It will return an object with 1-4 booleans,
65
+ like:
66
+ <br />
67
+ <Code backgroundColor="neutral.20" color="neutral.93" paddingY="4" paddingX="8">
68
+ const &#123; isMobile, isTablet, isDesktop, isWideDesktop &#125; = useResponsive();
69
+ </Code>
70
+ </Text>
71
+ {isMobile && (
72
+ <Box backgroundColor="green.40" color="neutral.93" paddingX="24" paddingY="16">
73
+ This Box is rendered below 848px (53rem), because isMobile is true.
74
+ </Box>
75
+ )}
76
+ {isTablet && (
77
+ <Box backgroundColor="purple.30" color="neutral.93" paddingX="24" paddingY="16">
78
+ This Box is rendered from 848px (53rem) but below 1280px (80rem), because isTablet is true.
79
+ </Box>
80
+ )}
81
+ {isDesktop && (
82
+ <Box backgroundColor="red.40" color="neutral.93" paddingX="24" paddingY="16">
83
+ This Box is rendered from 1280px (80rem) but below 1616px, because isDesktop is true.
84
+ </Box>
85
+ )}
86
+ {isWideDesktop && (
87
+ <Box backgroundColor="neutral.40" color="neutral.93" paddingX="24" paddingY="16">
88
+ This Box is rendered from 1616px (101rem), because isWideDesktop is true.
89
+ </Box>
90
+ )}
91
+ </CardContent>
92
+ </Card>
93
+ </Provider>
94
+ );
95
+ };
@@ -0,0 +1,6 @@
1
+ import { Meta } from '@storybook/addon-docs';
2
+ import { Responsive } from './Responsive.examples';
3
+
4
+ <Meta title="Foundations/Responsive" />
5
+
6
+ <Responsive />
@@ -1,2 +1,3 @@
1
1
  export { default as useHistory } from './useHistory';
2
+ export { default as useResponsive } from './useResponsive';
2
3
  export { useDisclosure } from '@chakra-ui/react';
@@ -0,0 +1,23 @@
1
+ import { useMediaQuery } from '@chakra-ui/react';
2
+ import breakpoints, { BREAKPOINTS } from '../Foundations/Breakpoints/Breakpoints';
3
+
4
+ const minusOnePixel = (value: string) => {
5
+ const valueInPixels = parseInt(value, 10) * 16;
6
+ return `${valueInPixels - 1}px`;
7
+ };
8
+
9
+ const mediaQueries = [
10
+ `(min-width: ${breakpoints[BREAKPOINTS.MOBILE]}) and (max-width: ${minusOnePixel(breakpoints[BREAKPOINTS.TABLET])})`,
11
+ `(min-width: ${breakpoints[BREAKPOINTS.TABLET]}) and (max-width: ${minusOnePixel(breakpoints[BREAKPOINTS.DESKTOP])})`,
12
+ `(min-width: ${breakpoints[BREAKPOINTS.DESKTOP]}) and (max-width: ${minusOnePixel(
13
+ breakpoints[BREAKPOINTS.WIDEDESKTOP],
14
+ )})`,
15
+ `(min-width: ${breakpoints[BREAKPOINTS.WIDEDESKTOP]})`,
16
+ ];
17
+
18
+ const useResponsive = () => {
19
+ const [isMobile, isTablet, isDesktop, isWideDesktop] = useMediaQuery(mediaQueries);
20
+ return { isMobile, isTablet, isDesktop, isWideDesktop };
21
+ };
22
+
23
+ export default useResponsive;