Skip to content

Commit

Permalink
docs: add Highlighter example
Browse files Browse the repository at this point in the history
  • Loading branch information
Carrotzpc committed Jul 31, 2024
1 parent 3f0993f commit 0eff088
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 0 deletions.
1 change: 1 addition & 0 deletions example/.dumirc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ export default defineConfig({
ignorePreRenderError: true,
},
...(isProduction ? { ssr: { builder: 'webpack' } } : {}),
...(isPreview ? { devtool: 'source-map' } : {}),
styles: [
`html, body { background: transparent; }
Expand Down
46 changes: 46 additions & 0 deletions example/src/Example/demos/Highlighter.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import { StoryBook, useControls, useCreateStore } from '@lobehub/ui';
import { Highlighter, HighlighterProps } from '@yuntijs/ui';

const code = `export default ({ children, className }: MarkdownProps) => {
const { styles } = useStyles();
return (
<ReactMarkdown
className={cx(styles.container, className)}
components={{ pre: CodeBlock, code: Code }}
>
{children}
</ReactMarkdown>
);
}`;

export default () => {
const store = useCreateStore();
const options: HighlighterProps | any = useControls(
{
children: {
rows: true,
value: code,
},
copyable: true,
copyButtonSize: {
options: ['site', 'large', 'normal', 'small'],
value: 'site',
},
language: 'tsx',
showLanguage: true,
spotlight: false,
type: {
options: ['ghost', 'block', 'pure'],
value: 'block',
},
fullFeatured: false,
},
{ store }
);

return (
<StoryBook levaStore={store}>
<Highlighter {...options} style={{ ...options.style, width: '100%' }} />
</StoryBook>
);
};
4 changes: 4 additions & 0 deletions example/src/Example/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,7 @@ description: This is an doc example
## Typography

<code src="./demos/Typography.tsx"></code>

## Highlighter

<code src="./demos/Highlighter.tsx"></code>

0 comments on commit 0eff088

Please sign in to comment.