style: command viewer scroller

This commit is contained in:
jialin
2026-01-07 15:55:26 +08:00
parent 8f9fae9210
commit bbf09c2ea9
21 changed files with 136 additions and 153 deletions
@@ -10,6 +10,7 @@ interface CodeViewerProps {
copyable?: boolean;
height?: string | number;
style?: React.CSSProperties;
xScrollable?: boolean;
}
const DarkViewer: React.FC<CodeViewerProps> = (props) => {
const {
@@ -19,7 +20,8 @@ const DarkViewer: React.FC<CodeViewerProps> = (props) => {
autodetect,
ignoreIllegals,
copyable,
height = 'auto'
height = 'auto',
xScrollable = false
} = props || {};
return (
@@ -33,6 +35,7 @@ const DarkViewer: React.FC<CodeViewerProps> = (props) => {
autodetect={autodetect}
ignoreIllegals={ignoreIllegals}
copyable={copyable}
xScrollable={xScrollable}
></CodeViewer>
);
};
@@ -10,6 +10,7 @@ interface CodeViewerProps {
copyable?: boolean;
height?: string | number;
style?: React.CSSProperties;
xScrollable?: boolean;
}
const LightViewer: React.FC<CodeViewerProps> = (props) => {
const {
@@ -20,7 +21,8 @@ const LightViewer: React.FC<CodeViewerProps> = (props) => {
ignoreIllegals,
copyable,
style,
height = 'auto'
height = 'auto',
xScrollable = false
} = props || {};
return (
@@ -34,6 +36,7 @@ const LightViewer: React.FC<CodeViewerProps> = (props) => {
autodetect={autodetect}
ignoreIllegals={ignoreIllegals}
copyable={copyable}
xScrollable={xScrollable}
></CodeViewer>
);
};
+17 -3
View File
@@ -15,6 +15,7 @@ interface CodeViewerProps {
height?: string | number;
theme?: 'light' | 'dark';
style?: React.CSSProperties;
xScrollable?: boolean;
}
interface CodeHeaderProps {
@@ -43,6 +44,14 @@ const CodeHeaderWrapper = styled.div`
const Wrapper = styled.div`
border-radius: var(--border-radius-mini);
&:hover {
.custome-scrollbar {
&::-webkit-scrollbar-thumb {
background-color: var(--color-scrollbar-thumb);
border-radius: 4px;
}
}
}
`;
const CodeHeader: React.FC<CodeHeaderProps> = ({
@@ -80,7 +89,8 @@ const CodeViewer: React.FC<CodeViewerProps> = (props) => {
ignoreIllegals = true,
copyable = true,
height = 'auto',
style
style,
xScrollable = false
} = props || {};
const highlightedCode = useMemo(() => {
@@ -131,7 +141,8 @@ const CodeViewer: React.FC<CodeViewerProps> = (props) => {
'code-pre custome-scrollbar custom-scrollbar-horizontal ',
{
dark: props.theme === 'dark',
light: props.theme === 'light'
light: props.theme === 'light',
'x-scrollable': xScrollable
}
)}
style={{
@@ -141,7 +152,10 @@ const CodeViewer: React.FC<CodeViewerProps> = (props) => {
}}
>
<code
style={{ minHeight: height }}
style={{
minHeight: height,
...(xScrollable ? { width: 'max-content' } : {})
}}
className={classNames(highlightedCode.className, {
dark: props.theme === 'dark',
light: props.theme === 'light'
+5 -1
View File
@@ -10,6 +10,7 @@ const HighlightCode: React.FC<{
copyable?: boolean;
theme?: 'light' | 'dark';
fixedTheme?: 'light' | 'dark';
xScrollable?: boolean;
height?: string | number;
style?: React.CSSProperties;
copyValue?: string;
@@ -21,7 +22,8 @@ const HighlightCode: React.FC<{
lang = 'bash',
copyable = true,
theme,
height = 'auto'
height = 'auto',
xScrollable = false
} = props;
const { userSettings } = useUserSettings();
@@ -40,6 +42,7 @@ const HighlightCode: React.FC<{
copyValue={copyValue}
copyable={copyable}
height={height}
xScrollable={xScrollable}
style={style}
/>
) : (
@@ -50,6 +53,7 @@ const HighlightCode: React.FC<{
copyValue={copyValue}
copyable={copyable}
height={height}
xScrollable={xScrollable}
/>
)}
</div>
+1 -1
View File
@@ -2,7 +2,7 @@ import { createFromIconfontCN } from '@ant-design/icons';
// import './iconfont/iconfont.js';
const IconFont = createFromIconfontCN({
scriptUrl: '//at.alicdn.com/t/c/font_4613488_jo5x7z2z718.js'
scriptUrl: '//at.alicdn.com/t/c/font_4613488_rajpu0blzkp.js'
});
export default IconFont;
+2 -1
View File
@@ -120,6 +120,7 @@ const TagsWrapper: React.FC<TagsWrapperProps> = (props) => {
>
<Tag
className="more"
variant="outlined"
style={{ marginInline: hiddenIndices.end < 1 ? 0 : `${gap}px 0` }}
ref={moreBtnRef}
>
@@ -132,4 +133,4 @@ const TagsWrapper: React.FC<TagsWrapperProps> = (props) => {
);
};
export default React.memo(TagsWrapper);
export default TagsWrapper;