@bitrise/bitkit 13.20.0 → 13.21.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
|
@@ -4,13 +4,17 @@ import ReactMarkdown, { Components } from 'react-markdown';
|
|
|
4
4
|
import List from '../List/List';
|
|
5
5
|
import Link from '../Link/Link';
|
|
6
6
|
import ListItem from '../List/ListItem';
|
|
7
|
-
import Box from '../Box/Box';
|
|
7
|
+
import Box, { BoxProps } 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
11
|
import CodeSnippet from '../CodeSnippet/CodeSnippet';
|
|
12
12
|
|
|
13
|
-
|
|
13
|
+
type GapType = Exclude<BoxProps['gap'], undefined>;
|
|
14
|
+
|
|
15
|
+
const defaultComponents = (size: 'sm' | 'md' | 'lg', gap: GapType = '16'): Components => {
|
|
16
|
+
const codeSize = size === 'lg' ? 'lg' : 'md';
|
|
17
|
+
|
|
14
18
|
return {
|
|
15
19
|
a: ({ node, ...props }) => <Link colorScheme="purple" isUnderlined target="_blank" {...props} />,
|
|
16
20
|
blockquote: ({ children }) => (
|
|
@@ -27,7 +31,7 @@ const defaultComponents = (size: 'md' | 'lg'): Components => {
|
|
|
27
31
|
</Box>
|
|
28
32
|
),
|
|
29
33
|
code: ({ node, ...props }) => (
|
|
30
|
-
<CodeSnippet size={
|
|
34
|
+
<CodeSnippet size={codeSize} {...props}>
|
|
31
35
|
{props.children as string}
|
|
32
36
|
</CodeSnippet>
|
|
33
37
|
),
|
|
@@ -37,24 +41,26 @@ const defaultComponents = (size: 'md' | 'lg'): Components => {
|
|
|
37
41
|
h4: ({ node, ...props }) => <Text as="h4" textStyle="heading/h4" {...props} />,
|
|
38
42
|
h5: ({ node, ...props }) => <Text as="h5" textStyle="heading/h5" {...props} />,
|
|
39
43
|
h6: ({ node, ...props }) => <Text as="h6" textStyle="heading/h6" {...props} />,
|
|
40
|
-
hr: () => <Divider borderColor="separator.primary" my=
|
|
44
|
+
hr: () => <Divider borderColor="separator.primary" my={gap} size="2" />,
|
|
41
45
|
li: ({ node, ...props }) => <ListItem {...props} />,
|
|
42
46
|
ol: ({ node, ...props }) => <List isOrdered {...props} />,
|
|
43
47
|
p: ({ node, ...props }) => <Text {...props} />,
|
|
44
|
-
pre: ({ node, ...props }) => <CodeBlock size={
|
|
48
|
+
pre: ({ node, ...props }) => <CodeBlock size={codeSize}>{props.children as string}</CodeBlock>,
|
|
45
49
|
ul: ({ node, ...props }) => <List {...props} />,
|
|
46
50
|
};
|
|
47
51
|
};
|
|
48
52
|
|
|
49
|
-
type NoteMarkdownContentProps = {
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
53
|
+
type NoteMarkdownContentProps = {
|
|
54
|
+
md: string;
|
|
55
|
+
gap?: GapType;
|
|
56
|
+
size?: 'sm' | 'md' | 'lg';
|
|
57
|
+
} & Pick<ComponentProps<typeof ReactMarkdown>, 'components' | 'rehypePlugins'>;
|
|
58
|
+
|
|
59
|
+
const NoteMarkdownContent = ({ components, md, gap = '16', size = 'lg', ...rest }: NoteMarkdownContentProps) => {
|
|
54
60
|
const extendedComponents = { ...defaultComponents(size), ...components };
|
|
55
61
|
const textStyle = `body/${size}/regular`;
|
|
56
62
|
return (
|
|
57
|
-
<Box display="flex" flexDirection="column" gap=
|
|
63
|
+
<Box display="flex" flexDirection="column" gap={gap} textStyle={textStyle}>
|
|
58
64
|
<ReactMarkdown components={extendedComponents} {...rest}>
|
|
59
65
|
{md}
|
|
60
66
|
</ReactMarkdown>
|