@bitrise/bitkit 12.27.0 → 12.28.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": "12.27.0",
4
+ "version": "12.28.0",
5
5
  "repository": "git@github.com:bitrise-io/bitkit.git",
6
6
  "main": "src/index.ts",
7
7
  "license": "UNLICENSED",
@@ -35,8 +35,7 @@
35
35
  "react": "^18.2.0",
36
36
  "react-dom": "^18.2.0",
37
37
  "react-focus-lock": "^2.9.1",
38
- "react-markdown": "^8.0.7",
39
- "rehype-sanitize": "^5.0.1"
38
+ "react-markdown": "^8.0.7"
40
39
  },
41
40
  "peerDependencies": {
42
41
  "react": "^18.2.0",
@@ -0,0 +1,14 @@
1
+ import { ReactNode } from 'react';
2
+ import { useStyleConfig } from '@chakra-ui/react';
3
+ import Box from '../Box/Box';
4
+
5
+ const CodeBlock = ({ children }: { children: ReactNode }) => {
6
+ const css = useStyleConfig('CodeBlock');
7
+ return (
8
+ <Box __css={css} as="pre">
9
+ {children}
10
+ </Box>
11
+ );
12
+ };
13
+
14
+ export default CodeBlock;
@@ -1,6 +1,5 @@
1
+ import { ComponentProps } from 'react';
1
2
  import ReactMarkdown, { Components } from 'react-markdown';
2
- import rehypeSanitize from 'rehype-sanitize';
3
- import { Code } from '@chakra-ui/react';
4
3
 
5
4
  import List from '../List/List';
6
5
  import ListItem from '../List/ListItem';
@@ -8,7 +7,7 @@ import Box from '../Box/Box';
8
7
  import Divider from '../Divider/Divider';
9
8
  import Text from '../Text/Text';
10
9
 
11
- const components: Components = {
10
+ const defaultComponents: Components = {
12
11
  h1: ({ node, ...props }) => <Text size="6" {...props} />,
13
12
  h2: ({ node, ...props }) => <Text paddingTop="12" size="5" {...props} />,
14
13
  h3: ({ node, ...props }) => <Text paddingTop="12" size="4" fontWeight="bold" {...props} />,
@@ -17,7 +16,6 @@ const components: Components = {
17
16
  h6: ({ node, ...props }) => <Text paddingTop="12" size="1" fontWeight="bold" {...props} />,
18
17
  p: ({ node, ...props }) => <Text {...props} />,
19
18
  hr: () => <Divider my="16" borderColor="separator.primary" size="2" />,
20
- pre: ({ node, ...props }) => <Code {...props} />,
21
19
  ul: ({ node, ordered, ...props }) => <List paddingBottom="8" {...props} />,
22
20
  ol: ({ node, ordered, ...props }) => <List paddingBottom="8" isOrdered {...props} />,
23
21
  li: ({ node, ordered, ...props }) => <ListItem {...props} />,
@@ -35,10 +33,15 @@ const components: Components = {
35
33
  </Box>
36
34
  ),
37
35
  };
38
- const NoteMarkdownContent = ({ md }: { md: string }) => {
36
+ type NoteMarkdownContentProps = { md: string } & Pick<
37
+ ComponentProps<typeof ReactMarkdown>,
38
+ 'components' | 'rehypePlugins'
39
+ >;
40
+ const NoteMarkdownContent = ({ md, components, ...rest }: NoteMarkdownContentProps) => {
41
+ const extendedComponents = { ...defaultComponents, ...components };
39
42
  return (
40
43
  <Box display="flex" flexDirection="column" gap="16">
41
- <ReactMarkdown rehypePlugins={[rehypeSanitize]} components={components}>
44
+ <ReactMarkdown components={extendedComponents} {...rest}>
42
45
  {md}
43
46
  </ReactMarkdown>
44
47
  </Box>
package/src/index.ts CHANGED
@@ -288,3 +288,4 @@ export { default as Tag } from './Components/Tag/Tag';
288
288
 
289
289
  export { default as Note } from './Components/Note/Note';
290
290
  export { default as MarkdownContent } from './Components/Note/NoteMarkdownContent';
291
+ export { default as CodeBlock } from './Components/CodeBlock/CodeBlock';
package/src/theme.ts CHANGED
@@ -37,7 +37,7 @@ import SidebarItem from './Components/Sidebar/SidebarItem.theme';
37
37
  import SegmentedControl from './Components/SegmentedControl/SegmentedControl.theme';
38
38
  import Tag from './Components/Tag/Tag.theme';
39
39
  import Note from './Components/Note/Note.theme';
40
- import Code from './Components/Code/Code.theme';
40
+ import CodeBlock from './Components/CodeBlock/CodeBlock.theme';
41
41
 
42
42
  import breakpoints from './Foundations/Breakpoints/Breakpoints';
43
43
  import colors from './Foundations/Colors/Colors';
@@ -122,7 +122,7 @@ const theme = {
122
122
  SegmentedControl,
123
123
  Tag,
124
124
  Note,
125
- Code,
125
+ CodeBlock,
126
126
  },
127
127
  };
128
128