|
20 | 20 | */ |
21 | 21 | import * as Antd from 'antd'; |
22 | 22 | 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'; |
24 | 24 | import { Prism as SyntaxHighlighter } from 'react-syntax-highlighter'; |
| 25 | +import SiderCollapseTrigger from './SiderCollapseTrigger'; |
25 | 26 | import { dracula, oneLight } from 'react-syntax-highlighter/dist/esm/styles/prism'; |
26 | 27 |
|
27 | 28 | import type { MessageInstance } from 'antd/es/message/interface'; |
@@ -117,41 +118,10 @@ export default function CodeDisplay(props: CodeDisplayProps): React.JSX.Element |
117 | 118 | if (!props.onToggleCollapse) return null; |
118 | 119 |
|
119 | 120 | 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 | + /> |
155 | 125 | ); |
156 | 126 | }; |
157 | 127 |
|
|
0 commit comments