Skip to content

Commit 6803bb4

Browse files
committed
Move node/edge colors to constants
1 parent 0d6025a commit 6803bb4

File tree

2 files changed

+32
-4
lines changed

2 files changed

+32
-4
lines changed

redisinsight/ui/src/packages/ri-explain/src/Explain.tsx

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,13 @@ import {
99
EuiIcon,
1010
} from '@elastic/eui'
1111

12+
import {
13+
EDGE_COLOR_BODY_DARK,
14+
EDGE_COLOR_BODY_LIGHT,
15+
NODE_COLOR_BODY_DARK,
16+
NODE_COLOR_BODY_LIGHT,
17+
} from './constants'
18+
1219
import {
1320
CoreType,
1421
ModuleType,
@@ -31,6 +38,14 @@ function getEdgeSize(c: number) {
3138
return Math.floor(Math.log(c || 1) + 1)
3239
}
3340

41+
function getNodeColor(isDarkTheme: boolean) {
42+
return isDarkTheme ? NODE_COLOR_BODY_DARK : NODE_COLOR_BODY_LIGHT
43+
}
44+
45+
function getEdgeColor(isDarkTheme: boolean) {
46+
return isDarkTheme ? EDGE_COLOR_BODY_DARK : EDGE_COLOR_BODY_LIGHT
47+
}
48+
3449
export default function Explain(props: IExplain): JSX.Element {
3550
const command = props.command.split(' ')[0].toLowerCase()
3651

@@ -206,7 +221,7 @@ function ExplainDraw({data, type, module, profilingTime}: {data: any, type: Core
206221
ancestors.pairs.forEach(p => {
207222
document.querySelector(`#node-${p[0]}`)?.setAttribute("style", "")
208223
const edge = graph.getCellById(`${p[0]}-${p[1]}`)
209-
const edgeColor = isDarkTheme ? '#6B6B6B' : '#8992B3'
224+
const edgeColor = getEdgeColor(isDarkTheme)
210225
edge.setAttrs({
211226
line: {
212227
stroke: edgeColor,
@@ -333,7 +348,7 @@ function ExplainDraw({data, type, module, profilingTime}: {data: any, type: Core
333348
data: info,
334349
attrs: {
335350
body: {
336-
fill: isDarkTheme ? '#5F95FF' : '#8992B3',
351+
fill: getNodeColor(isDarkTheme),
337352
stroke: 'transparent',
338353
},
339354
},
@@ -361,7 +376,7 @@ function ExplainDraw({data, type, module, profilingTime}: {data: any, type: Core
361376
if (data.children) {
362377
data.children.forEach((item: any) => {
363378
const itemRecords = parseInt(item.data.counter || 0)
364-
const edgeColor = isDarkTheme ? '#6B6B6B' : '#8992B3'
379+
const edgeColor = getEdgeColor(isDarkTheme)
365380
model.edges?.push({
366381
id: `${data.id}-${item.id}`,
367382
source: {
@@ -421,7 +436,14 @@ function ExplainDraw({data, type, module, profilingTime}: {data: any, type: Core
421436
return (
422437
<div>
423438
{ collapse && <div style={{ paddingTop: '50px' }}></div> }
424-
<div id="container-parent" style={{ height: isFullScreen ? (window.outerHeight - 170) + 'px' : collapse ? '500px' : '585px', width: '100%', overflow: 'auto' }}>
439+
<div
440+
id="container-parent"
441+
style={{
442+
height: isFullScreen ? (window.outerHeight - 170) + 'px' : collapse ? '500px' : '585px',
443+
width: '100%',
444+
overflow: 'auto',
445+
}}
446+
>
425447
<div style={{ margin: 0, width: '100vw' }} ref={container} id="container" />
426448
{ !collapse && (
427449
<div className="ZoomMenu">
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
export const NODE_COLOR_BODY_DARK = '#5F95FF'
2+
export const NODE_COLOR_BODY_LIGHT = '#8992B3'
3+
4+
export const EDGE_COLOR_BODY_DARK = '#6B6B6B'
5+
export const EDGE_COLOR_BODY_LIGHT = '#8992B3'
6+

0 commit comments

Comments
 (0)