Skip to content

Commit 59a13b1

Browse files
authored
Fix Python code display growing to be taller than blockly component (#167)
1 parent 62e3399 commit 59a13b1

File tree

1 file changed

+6
-10
lines changed

1 file changed

+6
-10
lines changed

src/reactComponents/CodeDisplay.tsx

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,6 @@ interface CodeDisplayProps {
3838
setAlertErrorMessage: StringFunction;
3939
}
4040

41-
/** Full dimensions style for the syntax highlighter. */
42-
const FULL_SIZE_STYLE = {
43-
width: '100%',
44-
height: '100%',
45-
};
46-
4741
/** Success message for copy operation. */
4842
const COPY_SUCCESS_MESSAGE = 'Copy completed successfully.';
4943

@@ -86,13 +80,15 @@ export default function CodeDisplay(props: CodeDisplayProps): React.JSX.Element
8680
/** Creates the custom style object for the syntax highlighter. */
8781
const getSyntaxHighlighterStyle = (): React.CSSProperties => ({
8882
backgroundColor: token.colorBgContainer,
89-
...FULL_SIZE_STYLE,
83+
width: '100%',
84+
overflowX: 'hidden',
85+
overflowY: 'auto',
9086
});
9187

9288
/** Renders the header section with title and copy button. */
9389
const renderHeader = (): React.JSX.Element => (
94-
<Antd.Space>
95-
<Antd.Typography.Title level={3}>{t("CODE")}</Antd.Typography.Title>
90+
<Antd.Space align="center">
91+
<Antd.Typography.Title level={3} style={{ margin: 0 }}>{t("CODE")}</Antd.Typography.Title>
9692
<Antd.Tooltip title={t("COPY")}>
9793
<Antd.Button
9894
icon={<CopyIcon />}
@@ -115,7 +111,7 @@ export default function CodeDisplay(props: CodeDisplayProps): React.JSX.Element
115111
);
116112

117113
return (
118-
<Antd.Flex vertical gap="small">
114+
<Antd.Flex vertical gap="small" style={{ height: '100%' }}>
119115
{renderHeader()}
120116
{renderCodeBlock()}
121117
</Antd.Flex>

0 commit comments

Comments
 (0)