Skip to content

Commit

Permalink
feat: improve scrollbar position
Browse files Browse the repository at this point in the history
  • Loading branch information
JuroUhlar committed Jun 13, 2024
1 parent 4c6f33d commit 98589ec
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 22 deletions.
52 changes: 31 additions & 21 deletions src/client/components/common/CodeSnippet/CodeSnippet.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { PropsWithChildren } from 'react';
import { CSSProperties, PropsWithChildren } from 'react';
import { PrismAsyncLight } from 'react-syntax-highlighter';
import lightTheme from 'react-syntax-highlighter/dist/cjs/styles/prism/coy';
import darkTheme from 'react-syntax-highlighter/dist/cjs/styles/prism/coldark-dark';
Expand Down Expand Up @@ -28,32 +28,42 @@ export function CodeSnippet({
}: PropsWithChildren<CodeSnippetProps>) {
const hasDarkMode = false;

const PRISM_CUSTOM_STYLE = {
backgroundColor: '#FFF',
padding: '16px 12px',
borderRadius: '8px',
fontFamily: 'Roboto Mono, monospace',
fontSize: '14px',
margin: '0',
const PRISM_CUSTOM_STYLE: CSSProperties = {
padding: '16px',
fontFamily: 'JetBrains Mono, monospace',
fontSize: '16px',
overflow: 'auto',
border: '1px solid #D0D0D0',
marginTop: '0',
marginBottom: '0',
marginLeft: '0',
marginRight: '0',
// lineHeight: '205%',
height: '446px',
};
const PRISM_CODE_TAG_PROPS = { style: { color: '#c92c2c', font: 'inherit' as const } };

return (
<PrismAsyncLight
showLineNumbers={showLineNumbers}
lineNumberStyle={PRISM_LINE_NUMBER_STYLE}
wrapLines
language={language}
style={hasDarkMode ? darkTheme : lightTheme}
customStyle={PRISM_CUSTOM_STYLE}
codeTagProps={PRISM_CODE_TAG_PROPS}
className={classnames(styles.snippet, className)}
data-testid={dataTestId}
<div
style={{
padding: '3px',
backgroundColor: '#FFF',
borderRadius: '8px',
border: '1px solid #D0D0D0',
}}
>
{children}
</PrismAsyncLight>
<PrismAsyncLight
showLineNumbers={showLineNumbers}
lineNumberStyle={PRISM_LINE_NUMBER_STYLE}
wrapLines
language={language}
style={hasDarkMode ? darkTheme : lightTheme}
customStyle={PRISM_CUSTOM_STYLE}
codeTagProps={PRISM_CODE_TAG_PROPS}
className={classnames(styles.snippet, className)}
data-testid={dataTestId}
>
{children}
</PrismAsyncLight>
</div>
);
}
4 changes: 3 additions & 1 deletion src/styles/global-styles.scss
Original file line number Diff line number Diff line change
Expand Up @@ -168,12 +168,14 @@ img {
vertical-align: middle;
}

/** Scrollbar styles */
/* This works on Firefox */
body {
scrollbar-width: thin;
scrollbar-color: #c1c1c1 transparent;
}

// /* Works on Chrome, Edge, and Safari */
/* This Works on Chrome, Edge, and Safari */
*::-webkit-scrollbar {
width: 6px;
height: 6px;
Expand Down

0 comments on commit 98589ec

Please sign in to comment.