Skip to content

Commit ce488c6

Browse files
committed
Change to use the new collapse committment in the code display
1 parent 8cc45af commit ce488c6

File tree

1 file changed

+6
-36
lines changed

1 file changed

+6
-36
lines changed

src/reactComponents/CodeDisplay.tsx

Lines changed: 6 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,9 @@
2020
*/
2121
import * as Antd from 'antd';
2222
import * as React from 'react';
23-
import { CopyOutlined as CopyIcon, LeftOutlined as CollapseIcon, RightOutlined as ExpandIcon } from '@ant-design/icons';
23+
import { CopyOutlined as CopyIcon } from '@ant-design/icons';
2424
import { Prism as SyntaxHighlighter } from 'react-syntax-highlighter';
25+
import SiderCollapseTrigger from './SiderCollapseTrigger';
2526
import { dracula, oneLight } from 'react-syntax-highlighter/dist/esm/styles/prism';
2627

2728
import type { MessageInstance } from 'antd/es/message/interface';
@@ -117,41 +118,10 @@ export default function CodeDisplay(props: CodeDisplayProps): React.JSX.Element
117118
if (!props.onToggleCollapse) return null;
118119

119120
return (
120-
<div
121-
style={{
122-
position: 'absolute',
123-
bottom: 0,
124-
left: '50%',
125-
transform: 'translateX(-50%)',
126-
backgroundColor: token.colorBgContainer,
127-
border: `1px solid ${token.colorBorder}`,
128-
borderBottom: 'none',
129-
borderRadius: '6px 6px 0 0',
130-
padding: '2px 6px',
131-
cursor: 'pointer',
132-
display: 'flex',
133-
alignItems: 'center',
134-
justifyContent: 'center',
135-
minWidth: '24px',
136-
height: '22px',
137-
color: token.colorTextSecondary,
138-
transition: 'all 0.2s',
139-
zIndex: 1,
140-
}}
141-
onClick={props.onToggleCollapse}
142-
onMouseEnter={(e) => {
143-
e.currentTarget.style.color = token.colorText;
144-
e.currentTarget.style.backgroundColor = token.colorBgTextHover;
145-
}}
146-
onMouseLeave={(e) => {
147-
e.currentTarget.style.color = token.colorTextSecondary;
148-
e.currentTarget.style.backgroundColor = token.colorBgContainer;
149-
}}
150-
>
151-
<Antd.Tooltip title={props.isCollapsed ? t("EXPAND") : t("COLLAPSE")}>
152-
{props.isCollapsed ? <ExpandIcon /> : <CollapseIcon />}
153-
</Antd.Tooltip>
154-
</div>
121+
<SiderCollapseTrigger
122+
collapsed={props.isCollapsed || false}
123+
onToggle={props.onToggleCollapse}
124+
/>
155125
);
156126
};
157127

0 commit comments

Comments
 (0)