Skip to content

Commit a3fe4bb

Browse files
fix(extensions): fix button position (#2567)
Signed-off-by: Christoph Jerolimov <jerolimov+git@redhat.com>
1 parent 36a5e1a commit a3fe4bb

7 files changed

Lines changed: 275 additions & 450 deletions

File tree

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@red-hat-developer-hub/backstage-plugin-extensions': patch
3+
---
4+
5+
Improve button position and make the design independ from the fact if the global-header is installed/used or not.

workspaces/extensions/plugins/extensions/src/components/CodeEditor.tsx

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ import { useState, useCallback } from 'react';
1818

1919
import { Progress } from '@backstage/core-components';
2020

21-
import Box from '@mui/material/Box';
2221
import Button from '@mui/material/Button';
2322
import ContentCopyRoundedIcon from '@mui/icons-material/ContentCopyRounded';
2423
import Typography from '@mui/material/Typography';
@@ -87,7 +86,7 @@ export const CodeEditor = ({
8786
};
8887

8988
return (
90-
<Box position="relative" sx={{ width: '100%', height: '100%' }}>
89+
<div style={{ position: 'relative', width: '100%', height: '100%' }}>
9190
<Button
9291
variant="text"
9392
onClick={handleCopy}
@@ -112,15 +111,18 @@ export const CodeEditor = ({
112111
)}
113112
</Button>
114113

115-
<Editor
116-
theme={paletteMode}
117-
defaultLanguage={defaultLanguage}
118-
onChange={onChange}
119-
onMount={onMount}
120-
loading={<Progress />}
121-
options={defaultOptions}
122-
{...otherProps}
123-
/>
124-
</Box>
114+
{/* Use absolute to enforce the editor to use the right hight. */}
115+
<div style={{ position: 'absolute', width: '100%', height: '100%' }}>
116+
<Editor
117+
theme={paletteMode}
118+
defaultLanguage={defaultLanguage}
119+
onChange={onChange}
120+
onMount={onMount}
121+
loading={<Progress />}
122+
options={defaultOptions}
123+
{...otherProps}
124+
/>
125+
</div>
126+
</div>
125127
);
126128
};

workspaces/extensions/plugins/extensions/src/components/CodeEditorCard.tsx

Lines changed: 22 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
*/
1616

1717
import { lazy, Suspense } from 'react';
18-
import Grid from '@mui/material/Grid';
1918
import Card from '@mui/material/Card';
2019
import CardContent from '@mui/material/CardContent';
2120
import { Progress } from '@backstage/core-components';
@@ -27,51 +26,28 @@ const CodeEditor = lazy(() =>
2726

2827
export const CodeEditorCard = ({ onLoad }: { onLoad: () => void }) => {
2928
return (
30-
<Grid
31-
item
32-
xs={12}
33-
md={6.5}
34-
sx={{ display: 'flex', flexDirection: 'column', height: '100%' }}
35-
>
36-
<Card
37-
sx={{
38-
flex: 1,
39-
display: 'flex',
40-
flexDirection: 'column',
41-
overflow: 'hidden',
42-
borderRadius: 0,
43-
}}
44-
>
45-
<CardContent
46-
sx={{
47-
flex: 1,
48-
display: 'flex',
49-
flexDirection: 'column',
50-
overflow: 'auto',
51-
scrollbarWidth: 'thin',
52-
}}
53-
>
54-
<Suspense
55-
fallback={
56-
<div
57-
style={{
58-
width: '100%',
59-
height: '100%',
60-
display: 'flex',
61-
alignItems: 'start',
62-
justifyContent: 'center',
63-
}}
64-
>
65-
<div style={{ width: '100%', height: '100px' }}>
66-
<Progress />
67-
</div>
29+
<Card sx={{ flex: '1 1 0' }}>
30+
<CardContent style={{ display: 'flex' }}>
31+
<Suspense
32+
fallback={
33+
<div
34+
style={{
35+
width: '100%',
36+
height: '100%',
37+
display: 'flex',
38+
alignItems: 'start',
39+
justifyContent: 'center',
40+
}}
41+
>
42+
<div style={{ width: '100%', height: '100px' }}>
43+
<Progress />
6844
</div>
69-
}
70-
>
71-
<CodeEditor defaultLanguage="yaml" onLoaded={onLoad} />
72-
</Suspense>
73-
</CardContent>
74-
</Card>
75-
</Grid>
45+
</div>
46+
}
47+
>
48+
<CodeEditor defaultLanguage="yaml" onLoaded={onLoad} />
49+
</Suspense>
50+
</CardContent>
51+
</Card>
7652
);
7753
};

0 commit comments

Comments
 (0)