@bitrise/bitkit 13.13.0 → 13.14.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@bitrise/bitkit",
3
3
  "description": "Bitrise React component library",
4
- "version": "13.13.0",
4
+ "version": "13.14.0",
5
5
  "repository": {
6
6
  "type": "git",
7
7
  "url": "git+ssh://git@github.com/bitrise-io/bitkit.git"
@@ -1,15 +1,31 @@
1
1
  import { createMultiStyleConfigHelpers } from '@chakra-ui/styled-system';
2
2
 
3
- const itemHelpers = createMultiStyleConfigHelpers(['container', 'codeBox', 'copyIcon']);
3
+ const { definePartsStyle, defineMultiStyleConfig } = createMultiStyleConfigHelpers([
4
+ 'container',
5
+ 'codeBox',
6
+ 'copyIcon',
7
+ ]);
4
8
 
5
- const CodeBlockTheme = itemHelpers.defineMultiStyleConfig({
9
+ const sizes = {
10
+ lg: definePartsStyle({
11
+ codeBox: {
12
+ textStyle: 'code/lg',
13
+ },
14
+ }),
15
+ md: definePartsStyle({
16
+ codeBox: {
17
+ textStyle: 'code/md',
18
+ },
19
+ }),
20
+ };
21
+
22
+ const CodeBlockTheme = defineMultiStyleConfig({
6
23
  baseStyle: {
7
24
  codeBox: {
8
25
  bg: 'neutral.95',
9
26
  border: '1px solid',
10
27
  borderColor: 'separator.primary',
11
28
  borderRadius: '8',
12
- fontSize: '2',
13
29
  minHeight: '4rem',
14
30
  overflowY: 'auto',
15
31
  px: '12',
@@ -26,6 +42,10 @@ const CodeBlockTheme = itemHelpers.defineMultiStyleConfig({
26
42
  top: '1rem',
27
43
  },
28
44
  },
45
+ defaultProps: {
46
+ size: 'lg',
47
+ },
48
+ sizes,
29
49
  });
30
50
 
31
51
  export default CodeBlockTheme;
@@ -5,10 +5,11 @@ import IconButton from '../IconButton/IconButton';
5
5
  interface CodeBlockProps extends BoxProps {
6
6
  children: string;
7
7
  isCopiable?: boolean;
8
+ size?: 'md' | 'lg';
8
9
  }
9
10
 
10
11
  const CodeBlock = ({ children, isCopiable, ...props }: CodeBlockProps) => {
11
- const style = useMultiStyleConfig('CodeBlock');
12
+ const style = useMultiStyleConfig('CodeBlock', props);
12
13
 
13
14
  const { onCopy } = useClipboard(children);
14
15
 
@@ -33,4 +34,8 @@ const CodeBlock = ({ children, isCopiable, ...props }: CodeBlockProps) => {
33
34
  );
34
35
  };
35
36
 
37
+ CodeBlock.defaultProps = {
38
+ size: 'lg',
39
+ } as CodeBlockProps;
40
+
36
41
  export default CodeBlock;
@@ -1,36 +1,45 @@
1
1
  import { defineStyle, defineStyleConfig } from '@chakra-ui/styled-system';
2
2
 
3
+ const sizes = {
4
+ lg: defineStyle({
5
+ textStyle: 'code/lg',
6
+ }),
7
+ md: defineStyle({
8
+ textStyle: 'code/md',
9
+ }),
10
+ };
11
+
12
+ const copiableStyle = defineStyle({
13
+ cursor: 'pointer',
14
+ _hover: {
15
+ background: 'neutral.93',
16
+ },
17
+ _active: {
18
+ background: 'neutral.90',
19
+ },
20
+ _focusVisible: {
21
+ boxShadow: 'outline',
22
+ },
23
+ });
24
+
3
25
  const baseStyle = defineStyle(({ isCopiable }) => {
4
26
  const style = {
5
27
  bg: 'neutral.95',
6
28
  borderRadius: '2',
7
- fontFamily: 'mono',
8
- fontSize: '2',
9
- lineHeight: '20px',
10
29
  px: '6px',
11
30
  py: '2px',
12
31
  width: 'fit-content',
13
32
  };
14
33
 
15
- if (isCopiable) {
16
- return {
17
- ...style,
18
- _active: {
19
- background: 'neutral.90',
20
- },
21
- _focusVisible: {
22
- boxShadow: 'outline',
23
- },
24
- _hover: {
25
- background: 'neutral.93',
26
- },
27
- cursor: 'pointer',
28
- };
29
- }
30
-
31
- return style;
34
+ return { ...style, ...(isCopiable ? copiableStyle : {}) };
32
35
  });
33
36
 
34
- export default defineStyleConfig({
37
+ const CodeSnippetTheme = defineStyleConfig({
35
38
  baseStyle,
39
+ defaultProps: {
40
+ size: 'lg',
41
+ },
42
+ sizes,
36
43
  });
44
+
45
+ export default CodeSnippetTheme;
@@ -7,11 +7,12 @@ export interface CodeSnippetProps extends Omit<BoxProps, 'children'> {
7
7
  children: string;
8
8
  isCopiable?: boolean;
9
9
  textToCopy?: string;
10
+ size?: 'md' | 'lg';
10
11
  }
11
12
 
12
13
  const CodeSnippet = (props: CodeSnippetProps) => {
13
14
  const { children, isCopiable, textToCopy, ...rest } = props;
14
- const css = useStyleConfig('CodeSnippet', { isCopiable });
15
+ const css = useStyleConfig('CodeSnippet', props);
15
16
  const { hasCopied, onCopy } = useClipboard(textToCopy || children);
16
17
 
17
18
  const [isTooltipOpen, setTooltipOpen] = useState(false);
@@ -33,4 +34,8 @@ const CodeSnippet = (props: CodeSnippetProps) => {
33
34
  );
34
35
  };
35
36
 
37
+ CodeSnippet.defaultProps = {
38
+ size: 'lg',
39
+ } as CodeSnippetProps;
40
+
36
41
  export default CodeSnippet;
@@ -8,44 +8,53 @@ import Box from '../Box/Box';
8
8
  import Divider from '../Divider/Divider';
9
9
  import Text from '../Text/Text';
10
10
  import CodeBlock from '../CodeBlock/CodeBlock';
11
+ import CodeSnippet from '../CodeSnippet/CodeSnippet';
11
12
 
12
- const defaultComponents: Components = {
13
- a: ({ node, ...props }) => <Link colorScheme="purple" isUnderlined target="_blank" {...props} />,
14
- blockquote: ({ children }) => (
15
- <Box
16
- as="blockquote"
17
- borderColor="separator.primary"
18
- borderLeftStyle="solid"
19
- borderLeftWidth="2px"
20
- color="text.secondary"
21
- paddingLeft="16"
22
- py="8"
23
- >
24
- {children}
25
- </Box>
26
- ),
27
- code: ({ node, ...props }) => <code {...props} />,
28
- h1: ({ node, ...props }) => <Text as="h1" size="6" {...props} />,
29
- h2: ({ node, ...props }) => <Text as="h2" size="5" {...props} />,
30
- h3: ({ node, ...props }) => <Text as="h3" fontWeight="bold" size="4" {...props} />,
31
- h4: ({ node, ...props }) => <Text as="h4" fontWeight="bold" size="3" {...props} />,
32
- h5: ({ node, ...props }) => <Text as="h5" fontWeight="bold" size="2" {...props} />,
33
- h6: ({ node, ...props }) => <Text as="h6" fontWeight="bold" size="1" {...props} />,
34
- hr: () => <Divider borderColor="separator.primary" my="16" size="2" />,
35
- li: ({ node, ...props }) => <ListItem {...props} />,
36
- ol: ({ node, ...props }) => <List isOrdered {...props} />,
37
- p: ({ node, ...props }) => <Text {...props} />,
38
- pre: ({ node, ...props }) => <CodeBlock>{props.children as string}</CodeBlock>,
39
- ul: ({ node, ...props }) => <List {...props} />,
13
+ const defaultComponents = (size: 'md' | 'lg'): Components => {
14
+ return {
15
+ a: ({ node, ...props }) => <Link colorScheme="purple" isUnderlined target="_blank" {...props} />,
16
+ blockquote: ({ children }) => (
17
+ <Box
18
+ as="blockquote"
19
+ borderColor="separator.primary"
20
+ borderLeftStyle="solid"
21
+ borderLeftWidth="2px"
22
+ color="text.secondary"
23
+ paddingLeft="16"
24
+ py="8"
25
+ >
26
+ {children}
27
+ </Box>
28
+ ),
29
+ code: ({ node, ...props }) => (
30
+ <CodeSnippet size={size} {...props}>
31
+ {props.children as string}
32
+ </CodeSnippet>
33
+ ),
34
+ h1: ({ node, ...props }) => <Text as="h1" textStyle="heading/h1" {...props} />,
35
+ h2: ({ node, ...props }) => <Text as="h2" textStyle="heading/h2" {...props} />,
36
+ h3: ({ node, ...props }) => <Text as="h3" textStyle="heading/h3" {...props} />,
37
+ h4: ({ node, ...props }) => <Text as="h4" textStyle="heading/h4" {...props} />,
38
+ h5: ({ node, ...props }) => <Text as="h5" textStyle="heading/h5" {...props} />,
39
+ h6: ({ node, ...props }) => <Text as="h6" textStyle="heading/h6" {...props} />,
40
+ hr: () => <Divider borderColor="separator.primary" my="16" size="2" />,
41
+ li: ({ node, ...props }) => <ListItem {...props} />,
42
+ ol: ({ node, ...props }) => <List isOrdered {...props} />,
43
+ p: ({ node, ...props }) => <Text {...props} />,
44
+ pre: ({ node, ...props }) => <CodeBlock size={size}>{props.children as string}</CodeBlock>,
45
+ ul: ({ node, ...props }) => <List {...props} />,
46
+ };
40
47
  };
41
- type NoteMarkdownContentProps = { md: string } & Pick<
48
+
49
+ type NoteMarkdownContentProps = { md: string; size?: 'md' | 'lg' } & Pick<
42
50
  ComponentProps<typeof ReactMarkdown>,
43
51
  'components' | 'rehypePlugins'
44
52
  >;
45
- const NoteMarkdownContent = ({ components, md, ...rest }: NoteMarkdownContentProps) => {
46
- const extendedComponents = { ...defaultComponents, ...components };
53
+ const NoteMarkdownContent = ({ components, md, size = 'lg', ...rest }: NoteMarkdownContentProps) => {
54
+ const extendedComponents = { ...defaultComponents(size), ...components };
55
+ const textStyle = `body/${size}/regular`;
47
56
  return (
48
- <Box display="flex" flexDirection="column" gap="16">
57
+ <Box display="flex" flexDirection="column" gap="16" textStyle={textStyle}>
49
58
  <ReactMarkdown components={extendedComponents} {...rest}>
50
59
  {md}
51
60
  </ReactMarkdown>