File size: 887 Bytes
1e92f2d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
/**
 * copied: https://github.com/arvinxx/dumi-theme-antd-style/tree/master/src/builtins/Container
 */
import * as React from 'react';
import { Alert } from 'antd';

import useStyles from './style';

interface ContainerProps {
  type: 'info' | 'warning' | 'success' | 'error';
  title?: string;
}

const Container: React.FC<React.PropsWithChildren<ContainerProps>> = ({
  type,
  title,
  children,
}) => {
  const { styles, cx } = useStyles();

  return (
    <Alert
      showIcon
      type={type}
      message={title || type.toUpperCase()}
      description={
        <div
          className={cx(
            styles.desc,
            // 为了让 markdown 的样式生效需要在这里添加一个额外的 class
            'markdown',
          )}
        >
          {children}
        </div>
      }
      className={styles.alert}
    />
  );
};

export default Container;