Skip to content

Commit

Permalink
🐛 fix: snippet style
Browse files Browse the repository at this point in the history
  • Loading branch information
rdmclin2 committed Feb 9, 2024
1 parent 14599ce commit 6c89538
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 11 deletions.
3 changes: 1 addition & 2 deletions src/Highlight/components/HighLighter/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import { useStyles } from './style';

export type ShikiProps = Pick<
HighlightProps,
'language' | 'children' | 'theme' | 'lineNumber' | 'shiki'
'language' | 'children' | 'theme' | 'lineNumber' | 'shiki' | 'className' | 'style'
>;

const HighLighter: React.FC<ShikiProps> = memo((props) => {
Expand Down Expand Up @@ -50,7 +50,6 @@ const HighLighter: React.FC<ShikiProps> = memo((props) => {
{loading ? (
<Center className={styles.center} gap={8} horizontal>
<Loading spin className={styles.loading} />
Highlighting...
</Center>
) : null}
</>
Expand Down
8 changes: 5 additions & 3 deletions src/Snippet/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,11 @@ const BaseSnippet = memo<SnippetProps>((props) => {
return (
<div className={cx(styles.container, className)} {...rest}>
{spotlight && <Spotlight />}
<HighLighter language={language} theme={isDarkMode ? 'dark' : 'light'} shiki>
{symbol ? [symbol, children].join(' ') : children}
</HighLighter>
<div className={styles.highlighter}>
<HighLighter language={language} theme={isDarkMode ? 'dark' : 'light'} shiki>
{symbol ? [symbol, children].join(' ') : children}
</HighLighter>
</div>
{copyable && <CopyButton content={children} />}
</div>
);
Expand Down
14 changes: 8 additions & 6 deletions src/Snippet/style.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,6 @@ export const useStyles = createStyles(({ css, cx, token, prefixCls }, { type })
background-color: ${token.colorFillTertiary};
}
.${prefix}-shiki {
position: relative;
overflow: hidden;
flex: 1;
}
pre {
overflow-x: auto !important;
overflow-y: hidden !important;
Expand All @@ -57,5 +51,13 @@ export const useStyles = createStyles(({ css, cx, token, prefixCls }, { type })
}
`,
),
highlighter: cx(
`${prefix}-highlighter`,
css`
position: relative;
overflow: hidden;
flex: 1;
`,
),
};
});

0 comments on commit 6c89538

Please sign in to comment.