Skip to content

Commit

Permalink
✨ feat: add Snippet
Browse files Browse the repository at this point in the history
  • Loading branch information
canisminor1990 committed May 23, 2023
1 parent a49ebc0 commit f23a34d
Show file tree
Hide file tree
Showing 46 changed files with 506 additions and 2,956 deletions.
11 changes: 7 additions & 4 deletions .dumirc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { defineConfig } from 'dumi';
import { homepage } from './package.json';

const isProd = process.env.NODE_ENV === 'production';
const isWin = process.platform === 'win32';

const themeConfig = {
name: 'UI',
Expand All @@ -21,10 +22,12 @@ export default defineConfig({
base: '/',
publicPath: '/',
ssr: isProd ? {} : false,
apiParser: {},
resolve: {
entryFile: './src/index.ts',
},
apiParser: isWin ? false : {},
resolve: isWin
? undefined
: {
entryFile: './src/index.ts',
},
define: {
'process.env': process.env,
},
Expand Down
12 changes: 9 additions & 3 deletions packages/dumi-theme-lobehub/src/builtins/SourceCode/index.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,20 @@
import { FC } from 'react';

import { Highlighter } from '@lobehub/ui';
import { useTheme } from 'antd-style';
import { rgba } from 'polished';
import { FC } from 'react';

interface SourceCodeProps {
lang: string;
children: string;
}

const SourceCode: FC<SourceCodeProps> = ({ children, lang }) => {
return <Highlighter language={lang}>{children}</Highlighter>;
const theme = useTheme();
return (
<Highlighter style={{ background: rgba(theme.colorBgLayout, 0.5) }} language={lang}>
{children}
</Highlighter>
);
};

export default SourceCode;
15 changes: 4 additions & 11 deletions packages/dumi-theme-lobehub/src/components/ApiHeader/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { useResponsive } from 'antd-style';
import { FC, ReactNode, memo } from 'react';
import { Flexbox } from 'react-layout-kit';

import Code from '../CodeSnippet';
import { Snippet } from '@lobehub/ui';

import { ApiHeaderProps } from '@/index';
import { useStyles } from './style';
Expand Down Expand Up @@ -89,16 +89,9 @@ export const ApiHeader: FC<ApiTitleProps> = memo(
</div>
)}
<Flexbox style={{ marginTop: 16 }} gap={mobile ? 16 : 24}>
<Flexbox horizontal={!mobile} gap={mobile ? 12 : 0}>
<Typography.Text
className={styles.label}
type={'secondary'}
style={{ display: 'flex', alignItems: 'center' }}
>
Snippet
</Typography.Text>
<Code>{importStr}</Code>
</Flexbox>
<div style={{ display: 'flex' }}>
<Snippet>{importStr}</Snippet>
</div>
<Divider dashed style={{ margin: '2px 0' }} />
<Flexbox horizontal={!mobile} gap={mobile ? 24 : 0} distribution={'space-between'}>
<Space split={<Divider type={'vertical'} />} wrap>
Expand Down
43 changes: 0 additions & 43 deletions packages/dumi-theme-lobehub/src/components/CodeSnippet/index.tsx

This file was deleted.

20 changes: 0 additions & 20 deletions packages/dumi-theme-lobehub/src/components/CodeSnippet/style.ts

This file was deleted.

This file was deleted.

This file was deleted.

41 changes: 0 additions & 41 deletions packages/dumi-theme-lobehub/src/components/Highlighter/Prism.tsx

This file was deleted.

108 changes: 0 additions & 108 deletions packages/dumi-theme-lobehub/src/components/Highlighter/index.tsx

This file was deleted.

Loading

0 comments on commit f23a34d

Please sign in to comment.