diff options
Diffstat (limited to 'subprojects/frontend/src/graph/GraphTheme.tsx')
-rw-r--r-- | subprojects/frontend/src/graph/GraphTheme.tsx | 58 |
1 files changed, 15 insertions, 43 deletions
diff --git a/subprojects/frontend/src/graph/GraphTheme.tsx b/subprojects/frontend/src/graph/GraphTheme.tsx index 50a003e0..bdc01b78 100644 --- a/subprojects/frontend/src/graph/GraphTheme.tsx +++ b/subprojects/frontend/src/graph/GraphTheme.tsx | |||
@@ -4,9 +4,6 @@ | |||
4 | * SPDX-License-Identifier: EPL-2.0 | 4 | * SPDX-License-Identifier: EPL-2.0 |
5 | */ | 5 | */ |
6 | 6 | ||
7 | import cancelSVG from '@material-icons/svg/svg/cancel/baseline.svg?raw'; | ||
8 | import labelSVG from '@material-icons/svg/svg/label/baseline.svg?raw'; | ||
9 | import labelOutlinedSVG from '@material-icons/svg/svg/label/outline.svg?raw'; | ||
10 | import { | 7 | import { |
11 | alpha, | 8 | alpha, |
12 | styled, | 9 | styled, |
@@ -16,8 +13,6 @@ import { | |||
16 | import { lch } from 'd3-color'; | 13 | import { lch } from 'd3-color'; |
17 | import { range } from 'lodash-es'; | 14 | import { range } from 'lodash-es'; |
18 | 15 | ||
19 | import svgURL from '../utils/svgURL'; | ||
20 | |||
21 | import obfuscateColor from './obfuscateColor'; | 16 | import obfuscateColor from './obfuscateColor'; |
22 | 17 | ||
23 | function createEdgeColor( | 18 | function createEdgeColor( |
@@ -69,32 +64,16 @@ function createTypeHashStyles( | |||
69 | return result; | 64 | return result; |
70 | } | 65 | } |
71 | 66 | ||
72 | function iconStyle( | ||
73 | svg: string, | ||
74 | color: string, | ||
75 | noEmbedIcons?: boolean, | ||
76 | ): CSSObject { | ||
77 | if (noEmbedIcons) { | ||
78 | return { | ||
79 | fill: color, | ||
80 | }; | ||
81 | } | ||
82 | return { | ||
83 | maskImage: svgURL(svg), | ||
84 | background: color, | ||
85 | }; | ||
86 | } | ||
87 | |||
88 | export function createGraphTheme({ | 67 | export function createGraphTheme({ |
89 | theme, | 68 | theme, |
90 | colorNodes, | 69 | colorNodes, |
91 | hexTypeHashes, | 70 | hexTypeHashes, |
92 | noEmbedIcons, | 71 | useOpacity, |
93 | }: { | 72 | }: { |
94 | theme: Theme; | 73 | theme: Theme; |
95 | colorNodes: boolean; | 74 | colorNodes: boolean; |
96 | hexTypeHashes: string[]; | 75 | hexTypeHashes: string[]; |
97 | noEmbedIcons?: boolean; | 76 | useOpacity?: boolean; |
98 | }): CSSObject { | 77 | }): CSSObject { |
99 | const shadowAlapha = theme.palette.mode === 'dark' ? 0.32 : 0.24; | 78 | const shadowAlapha = theme.palette.mode === 'dark' ? 0.32 : 0.24; |
100 | 79 | ||
@@ -120,13 +99,15 @@ export function createGraphTheme({ | |||
120 | '.node-INDIVIDUAL .node-outline': { | 99 | '.node-INDIVIDUAL .node-outline': { |
121 | strokeWidth: 2, | 100 | strokeWidth: 2, |
122 | }, | 101 | }, |
123 | '.node-shadow.node-bg': noEmbedIcons | 102 | '.node-shadow.node-bg': useOpacity |
124 | ? { | 103 | ? { |
125 | // Inkscape can't handle opacity in exported SVG. | 104 | // Inkscape can't handle RGBA in exported SVG. |
126 | fill: theme.palette.text.primary, | 105 | fill: theme.palette.text.primary, |
127 | opacity: shadowAlapha, | 106 | opacity: shadowAlapha, |
128 | } | 107 | } |
129 | : { | 108 | : { |
109 | // But using `opacity` with the transition animation leads to flashing shadows, | ||
110 | // so we still use RGBA whenever possible. | ||
130 | fill: alpha(theme.palette.text.primary, shadowAlapha), | 111 | fill: alpha(theme.palette.text.primary, shadowAlapha), |
131 | }, | 112 | }, |
132 | '.node-exists-UNKNOWN .node-outline': { | 113 | '.node-exists-UNKNOWN .node-outline': { |
@@ -147,24 +128,15 @@ export function createGraphTheme({ | |||
147 | }, | 128 | }, |
148 | ...createEdgeColor('UNKNOWN', theme.palette.text.secondary, 'none'), | 129 | ...createEdgeColor('UNKNOWN', theme.palette.text.secondary, 'none'), |
149 | ...createEdgeColor('ERROR', theme.palette.error.main), | 130 | ...createEdgeColor('ERROR', theme.palette.error.main), |
150 | ...(noEmbedIcons | 131 | '.icon-TRUE': { |
151 | ? {} | 132 | fill: theme.palette.text.primary, |
152 | : { | 133 | }, |
153 | '.icon': { | 134 | '.icon-UNKNOWN': { |
154 | maskSize: '12px 12px', | 135 | fill: theme.palette.text.secondary, |
155 | maskPosition: '50% 50%', | 136 | }, |
156 | maskRepeat: 'no-repeat', | 137 | '.icon-ERROR': { |
157 | width: '100%', | 138 | fill: theme.palette.error.main, |
158 | height: '100%', | 139 | }, |
159 | }, | ||
160 | }), | ||
161 | '.icon-TRUE': iconStyle(labelSVG, theme.palette.text.primary, noEmbedIcons), | ||
162 | '.icon-UNKNOWN': iconStyle( | ||
163 | labelOutlinedSVG, | ||
164 | theme.palette.text.secondary, | ||
165 | noEmbedIcons, | ||
166 | ), | ||
167 | '.icon-ERROR': iconStyle(cancelSVG, theme.palette.error.main, noEmbedIcons), | ||
168 | 'text.label-UNKNOWN': { | 140 | 'text.label-UNKNOWN': { |
169 | fill: theme.palette.text.secondary, | 141 | fill: theme.palette.text.secondary, |
170 | }, | 142 | }, |