Skip to content

Commit a32d9c7

Browse files
authored
Replace style with css prop in CSP package (elastic#202013)
## Summary Part of the resolution of this issue: - elastic#149246 Removes the `style` prop in React components and elements to avoid using inline styles. Instead, it uses now the `emotion.css` prop to dynamically attach all styles to the native `class` attribute. ### Motivation Using inline styles at scale causes a performance penalty at rendering time. It's way more efficient to attach styles to a single or several classnames instead. ### Screenshots <details><summary>Default Edge</summary> <img width="1028" alt="Screenshot 2024-12-02 at 16 27 47" src="https://github.com/user-attachments/assets/4c913a69-ee26-4cda-829c-2b26799ead81"> </details> <details><summary>Graph Popovers</summary> <img width="175" alt="Screenshot 2024-12-02 at 16 27 57" src="https://github.com/user-attachments/assets/55054b05-9cb4-4ca7-a19a-319277d7961d"> </details> <details><summary>Graph Stacked Edge Cases</summary> <img width="1319" alt="Screenshot 2024-12-02 at 16 28 03" src="https://github.com/user-attachments/assets/11ec7a03-e8cf-4090-9443-56288bf78a2c"> </details> ### Checklist Check the PR satisfies following conditions. Reviewers should verify this PR satisfies this list as well. - [x] The PR description includes the appropriate Release Notes section, and the correct `release_note:*` label is applied per the [guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process) ### Identify risks - Minor risk with low impact and severity: - Only risk is CSP graph nodes showing with a different background and border
1 parent eb7edd3 commit a32d9c7

File tree

4 files changed

+5
-3
lines changed

4 files changed

+5
-3
lines changed

x-pack/packages/kbn-cloud-security-posture/graph/src/components/edge/default_edge.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,8 @@ export function DefaultEdge({
4949
path={edgePath}
5050
style={{
5151
stroke: euiTheme.colors[color],
52+
}}
53+
css={{
5254
strokeDasharray: '2,2',
5355
}}
5456
markerEnd={

x-pack/packages/kbn-cloud-security-posture/graph/src/components/edge/styles.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ export const SvgDefsMarker = () => {
128128
const { euiTheme } = useEuiTheme();
129129

130130
return (
131-
<svg style={{ position: 'absolute', width: 0, height: 0 }}>
131+
<svg css={{ position: 'absolute', width: 0, height: 0 }}>
132132
<defs>
133133
<Marker id="primary" color={euiTheme.colors.primary} />
134134
<Marker id="danger" color={euiTheme.colors.danger} />

x-pack/packages/kbn-cloud-security-posture/graph/src/components/node/edge_group_node.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ export const EdgeGroupNode: React.FC<NodeProps> = memo((props: NodeProps) => {
1616
<>
1717
<NodeResizeControl
1818
position="right"
19-
style={{ borderColor: 'transparent', background: 'transparent' }}
19+
css={{ borderColor: 'transparent', background: 'transparent' }}
2020
>
2121
<Handle
2222
type="target"

x-pack/packages/kbn-cloud-security-posture/graph/src/components/node/styles.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ export const NodeIcon = ({ icon, color, x, y }: NodeIconProps) => {
177177
return (
178178
<foreignObject x={x} y={y} width="50" height="50">
179179
<div
180-
style={{ display: 'flex', justifyContent: 'center', alignItems: 'center', height: '100%' }}
180+
css={{ display: 'flex', justifyContent: 'center', alignItems: 'center', height: '100%' }}
181181
>
182182
<EuiIcon type={getSpanIcon(icon) ?? icon} size="l" color={color ?? 'primary'} />
183183
</div>

0 commit comments

Comments
 (0)