Skip to content

Commit

Permalink
🐛 fix: highlighter scroll bugs (lobehub#178)
Browse files Browse the repository at this point in the history
  • Loading branch information
phuctm97 authored Jul 8, 2024
1 parent 532c5bf commit 079bc9a
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/Highlighter/demos/FullFeatured.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export default () => {

return (
<StoryBook levaStore={store}>
<Highlighter fullFeatured {...options} />
<Highlighter fullFeatured {...options} style={{ ...options.style, width: '100%' }} />
</StoryBook>
);
};
2 changes: 1 addition & 1 deletion src/Highlighter/demos/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export default () => {

return (
<StoryBook levaStore={store}>
<Highlighter {...options} />
<Highlighter {...options} style={{ ...options.style, width: '100%' }} />
</StoryBook>
);
};
4 changes: 3 additions & 1 deletion src/Highlighter/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,9 @@ export const Highlighter = memo<HighlighterProps>(
/>
)}
{showLanguage && language && <Tag className={styles.lang}>{language.toLowerCase()}</Tag>}
<SyntaxHighlighter language={language?.toLowerCase()}>{children}</SyntaxHighlighter>
<div className={styles.scroller}>
<SyntaxHighlighter language={language?.toLowerCase()}>{children}</SyntaxHighlighter>
</div>
</div>
);
},
Expand Down
7 changes: 6 additions & 1 deletion src/Highlighter/style.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export const useStyles = createStyles(
type !== 'pure' && typeStylish,
css`
position: relative;
overflow: auto;
overflow: hidden;
border-radius: ${token.borderRadius}px;
transition: background-color 100ms ${token.motionEaseOut};
Expand Down Expand Up @@ -90,6 +90,11 @@ export const useStyles = createStyles(
transition: opacity 0.1s;
`,
),
scroller: css`
overflow: auto;
width: 100%;
height: 100%;
`,
select: css`
user-select: none;
font-size: 14px;
Expand Down

0 comments on commit 079bc9a

Please sign in to comment.