diff --git a/.dumi/theme/builtins/API.tsx b/.dumi/theme/builtins/API.tsx new file mode 100755 index 000000000..ce815d396 --- /dev/null +++ b/.dumi/theme/builtins/API.tsx @@ -0,0 +1,57 @@ +import React, { useContext } from 'react'; +import type { IApiComponentProps} from 'dumi/theme'; +import { context, useApiData, AnchorLink } from 'dumi/theme'; + +const LOCALE_TEXTS = { + 'zh-CN': { + name: '属性名', + description: '描述', + type: '类型', + default: '默认值', + required: '(必选)', + }, + 'en-US': { + name: 'Name', + description: 'Description', + type: 'Type', + default: 'Default', + required: '(required)', + }, +}; + +export default ({ identifier, export: expt }: IApiComponentProps) => { + const data = useApiData(identifier); + const { locale } = useContext(context); + const texts = /^zh|cn$/i.test(locale) ? LOCALE_TEXTS['zh-CN'] : LOCALE_TEXTS['en-US']; + + return ( + <> + {data && ( + + + + + + + + + + + {data[expt].map(row => ( + + + + + + + ))} + +
{texts.name}{texts.description}{texts.type}{texts.default}
{row.identifier}{row.description || '--'} + {row.type} + + {row.default || (row.required && texts.required) || '--'} +
+ )} + + ); +}; diff --git a/.dumi/theme/builtins/Alert.less b/.dumi/theme/builtins/Alert.less new file mode 100755 index 000000000..988f32486 --- /dev/null +++ b/.dumi/theme/builtins/Alert.less @@ -0,0 +1,68 @@ +@import (reference) '../style/variables.less'; + +.@{prefix}-alert { + @s-border-right: 3px; + + position: relative; + margin: 24px 0; + padding: 15px; + color: @c-text; + font-size: 14px; + line-height: 20px; + border-left: 0; + background: #ffffff; + // box-shadow: 0 6px 16px -2px rgba(0, 0, 0, 0.06); + border-radius: 1px; + + &::after { + content: ''; + position: absolute; + display: inline-block; + top: 0; + left: 0; + bottom: 0; + width: @s-border-right; + border-radius: 1px; + } + + &:first-child { + margin-top: 0; + } + + &:not([type]), + &[type='warning'] { + background-color: #fffbe6; + &::after { + background: #ffe58f; + } + } + + &[type='info'] { + background: rgba(105, 185, 255, .15); + &::after { + background: #69b9ff; + } + .@{prefix}-alert-title { + color: #69b9ff; + } + } + + &[type='success'] { + &::after { + background: #8cd225; + } + } + + &[type='error'] { + &::after { + background: #ff4646; + } + } + + .@{prefix}-alert-title { + margin-top: 0; + font-weight: 600; + color: #fab00e; + margin-bottom: .6em; + } +} diff --git a/.dumi/theme/builtins/Alert.tsx b/.dumi/theme/builtins/Alert.tsx new file mode 100755 index 000000000..9facc10b9 --- /dev/null +++ b/.dumi/theme/builtins/Alert.tsx @@ -0,0 +1,17 @@ +import React from 'react'; +import './Alert.less'; +import { Alert } from 'antd'; +import micromark from 'micromark' + +export default (props: any) => { + const { title, children, ...others } = props; + console.log({children}); + return ( +
+ {title && ( +

{title}

+ )} + {typeof children === 'string' ?
: children} +
+ ) +}; diff --git a/.dumi/theme/builtins/Badge.less b/.dumi/theme/builtins/Badge.less new file mode 100755 index 000000000..dc2de29c9 --- /dev/null +++ b/.dumi/theme/builtins/Badge.less @@ -0,0 +1,31 @@ +@import (reference) '../style/variables.less'; + +.@{prefix}-badge { + display: inline-block; + margin-left: 6px; + padding: 1px 7px; + color: #fff; + font-size: 13px; + line-height: 20px; + text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.1); + box-shadow: 0 6px 16px -2px rgba(0, 0, 0, 0.06); + border-radius: 1px; + vertical-align: top; + + &:not([type]), + &[type='info'] { + background: #4569d4; + } + + &[type='warning'] { + background: #ffc121; + } + + &[type='success'] { + background: #8cd225; + } + + &[type='error'] { + background: #ff4646; + } +} diff --git a/.dumi/theme/builtins/Badge.tsx b/.dumi/theme/builtins/Badge.tsx new file mode 100755 index 000000000..2572c291c --- /dev/null +++ b/.dumi/theme/builtins/Badge.tsx @@ -0,0 +1,4 @@ +import React from 'react'; +import './Badge.less'; + +export default (props: any) => ; diff --git a/.dumi/theme/builtins/Example.less b/.dumi/theme/builtins/Example.less new file mode 100755 index 000000000..cb829c52e --- /dev/null +++ b/.dumi/theme/builtins/Example.less @@ -0,0 +1,47 @@ +@import (reference) '../style/variables.less'; + +.@{prefix}-example-wrapper { + padding-top: 16px; + height: calc(100vh - @s-nav-height - 2px); + + @media @mobile { + padding-top: 16px; + } + + &-toolbar { + display: flex; + color: @c-heading; + font-size: 16px; + font-weight: 500; + justify-content: space-between; + margin-bottom: 16px; + border-bottom: 1px solid @c-border; + + button, + a { + display: inline-block; + margin: 6px 0 6px 12px; + width: 16px; + height: 16px; + font-weight: 400; + border: 0; + outline: none; + vertical-align: middle; + cursor: pointer; + + &:first-child { + background-position-x: -144px; + } + + &:nth-child(2) { + background-position-x: -126px; + } + } + } + + iframe { + width: 100%; + min-height: 100%; + border: 0; + } +} diff --git a/.dumi/theme/builtins/Example.tsx b/.dumi/theme/builtins/Example.tsx new file mode 100755 index 000000000..7323cd68c --- /dev/null +++ b/.dumi/theme/builtins/Example.tsx @@ -0,0 +1,34 @@ +import React, { useRef, useEffect, useState } from 'react'; +import './Example.less'; + +export default (props: { route: any }) => { + const elm = useRef(); + const [height, setHeight] = useState(0); + + useEffect(() => { + setHeight(elm.current.contentWindow.document.documentElement.scrollHeight); + }, [elm]); + + return ( + props.route.meta.examplePath && ( +
+
+ {props.route.meta.description || props.route.meta.title} + +
+