@bitrise/bitkit 10.24.2 → 10.25.0
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 +1 -1
- package/src/Components/Text/Text.stories.tsx +1 -0
- package/src/Foundations/Breakpoints/Breakpoints.ts +5 -3
- package/src/Foundations/Responsive/Responsive.examples.tsx +95 -0
- package/src/Foundations/Responsive/Responsive.stories.mdx +6 -0
- package/src/hooks/index.ts +1 -0
- package/src/hooks/useResponsive.ts +23 -0
- package/src/tsconfig.tsbuildinfo +1 -1
package/package.json
CHANGED
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
export const BREAKPOINTS = {
|
|
2
2
|
MOBILE: 'base',
|
|
3
|
+
TABLET: 'tablet',
|
|
3
4
|
DESKTOP: 'desktop',
|
|
4
|
-
|
|
5
|
+
WIDEDESKTOP: 'wideDesktop',
|
|
5
6
|
};
|
|
6
7
|
|
|
7
8
|
const breakpoints = {
|
|
8
9
|
[BREAKPOINTS.MOBILE]: '0rem',
|
|
9
|
-
[BREAKPOINTS.
|
|
10
|
-
[BREAKPOINTS.
|
|
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 useResponsiveHook
|
|
62
|
+
</Text>
|
|
63
|
+
<Text marginBottom="24">
|
|
64
|
+
Use this hook when you want to render something conditionally. It will return an array with 1-4 booleans,
|
|
65
|
+
like:
|
|
66
|
+
<br />
|
|
67
|
+
<Code backgroundColor="neutral.20" color="neutral.93" paddingY="4" paddingX="8">
|
|
68
|
+
const { isMobile, isTablet, isDesktop, isWideDesktop } = 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
|
+
};
|
package/src/hooks/index.ts
CHANGED
|
@@ -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;
|