Skip to content
This repository was archived by the owner on Jul 30, 2025. It is now read-only.

Commit 23121b2

Browse files
committed
fix: remove use of inline styling in Form.tsx
Fixes #4112
1 parent 42cd286 commit 23121b2

File tree

2 files changed

+33
-25
lines changed
  • plugins
    • plugin-client-common/web/css/static
    • plugin-kubectl/src/lib/view/modes

2 files changed

+33
-25
lines changed

plugins/plugin-client-common/web/css/static/Form.scss

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,11 @@
11
[kui-theme-style] {
2+
.kui--form-section {
3+
&:not(:first-child) {
4+
padding-top: 1em;
5+
margin-top: 1em;
6+
}
7+
}
8+
29
.bx--form {
310
display: grid;
411
grid-template-rows: min-content;

plugins/plugin-kubectl/src/lib/view/modes/Form.tsx

Lines changed: 26 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -36,28 +36,33 @@ export default function SidecarForm({
3636
className?: string
3737
}) {
3838
return (
39-
<Form className={nested ? className : `padding-content scrollable ${className || ''}`}>
40-
{Object.keys(map).map((key, idx) => {
41-
const vvalue = map[key]
42-
const value =
43-
(typeof vvalue === 'number' ? vvalue.toLocaleString() : typeof vvalue !== 'object' ? vvalue : vvalue.label) ||
44-
''
39+
<div className="kui--form-section">
40+
<Form className={nested ? className : `padding-content scrollable ${className || ''}`}>
41+
{Object.keys(map).map((key, idx) => {
42+
const vvalue = map[key]
43+
const value =
44+
(typeof vvalue === 'number'
45+
? vvalue.toLocaleString()
46+
: typeof vvalue !== 'object'
47+
? vvalue
48+
: vvalue.label) || ''
4549

46-
const colspan = Math.max(Math.ceil(key.length / 8), Math.ceil((value.length + 2) / 5.5))
47-
const style = { gridColumn: `span ${colspan > 15 ? 8 : colspan}` }
48-
const className = typeof vvalue !== 'object' ? undefined : 'kui--form-item--for-label'
50+
const colspan = Math.max(Math.ceil(key.length / 8), Math.ceil((value.length + 2) / 5.5))
51+
const style = { gridColumn: `span ${colspan > 15 ? 8 : colspan}` }
52+
const className = typeof vvalue !== 'object' ? undefined : 'kui--form-item--for-label'
4953

50-
return (
51-
<div key={idx} style={style} className={className}>
52-
{colspan > 15 ? (
53-
<TextArea readOnly id={`kubectl-summary-${key}`} labelText={key} defaultValue={value} />
54-
) : (
55-
<TextInput readOnly id={`kubectl-summary-${key}`} labelText={key} defaultValue={value} />
56-
)}
57-
</div>
58-
)
59-
})}
60-
</Form>
54+
return (
55+
<div key={idx} style={style} className={className}>
56+
{colspan > 15 ? (
57+
<TextArea readOnly id={`kubectl-summary-${key}`} labelText={key} defaultValue={value} />
58+
) : (
59+
<TextInput readOnly id={`kubectl-summary-${key}`} labelText={key} defaultValue={value} />
60+
)}
61+
</div>
62+
)
63+
})}
64+
</Form>
65+
</div>
6166
)
6267
}
6368

@@ -74,11 +79,7 @@ export function FormWithLabels(props: { map: FormMap; resource: KubeResource })
7479
return (
7580
<div className="padding-content scrollable">
7681
<SidecarForm nested map={props.map} />
77-
{nLabels > 0 && (
78-
<div style={{ paddingTop: '1em' }}>
79-
<SidecarForm nested map={labelMap} className="top-pad" />
80-
</div>
81-
)}
82+
{nLabels > 0 && <SidecarForm nested map={labelMap} />}
8283
</div>
8384
)
8485
}

0 commit comments

Comments
 (0)