Skip to content

Commit 26001d9

Browse files
committed
feat: fix darkmode
1 parent e0cb0ef commit 26001d9

File tree

5 files changed

+112
-45
lines changed

5 files changed

+112
-45
lines changed

src/components/Hints/CrossplaneHint.tsx

Lines changed: 59 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
import { Card, CardHeader, ProgressIndicator, Button } from '@ui5/webcomponents-react';
22
import { RadarChart } from '@ui5/webcomponents-react-charts';
33
import { useTranslation } from 'react-i18next';
4+
import cx from 'clsx';
45
import { APIError } from '../../lib/api/error';
5-
import { getDisabledCardStyle } from './Hints';
6+
import { styles } from './Hints';
67
import { ManagedResourceItem, Condition } from '../../lib/shared/types';
78
import React from 'react';
89

@@ -25,8 +26,6 @@ export const CrossplaneHint: React.FC<CrossplaneHintProps> = ({
2526
}) => {
2627
const { t } = useTranslation();
2728

28-
const cardStyle = enabled ? {} : getDisabledCardStyle();
29-
3029
// Aggregate healthiness by resource type
3130
const resourceTypeHealth: Record<string, number> = {};
3231
const resourceTypeTotal: Record<string, number> = {};
@@ -41,11 +40,26 @@ export const CrossplaneHint: React.FC<CrossplaneHintProps> = ({
4140
}
4241
});
4342

44-
// Prepare radar chart dataset: each resource type is a dimension, value is percent healthy
45-
const radarDataset = Object.keys(resourceTypeTotal).map(type => ({
46-
type,
47-
health: `${Math.round(((resourceTypeHealth[type] || 0) / resourceTypeTotal[type]) * 100)}%`
48-
}));
43+
// Prepare radar chart dataset: each resource type is a dimension, values are counts for healthy and creating
44+
const radarDataset = Object.keys(resourceTypeTotal).map(type => {
45+
const total = resourceTypeTotal[type];
46+
const healthy = resourceTypeHealth[type] || 0;
47+
48+
// Count creating resources (no conditions yet or unknown status)
49+
const creating = allItems.filter((item: ManagedResourceItem) => {
50+
if (item.kind !== type) return false;
51+
const conditions = item.status?.conditions || [];
52+
const hasReadyCondition = conditions.some((c: Condition) => c.type === 'Ready');
53+
const hasSyncedCondition = conditions.some((c: Condition) => c.type === 'Synced');
54+
return !hasReadyCondition || !hasSyncedCondition;
55+
}).length;
56+
57+
return {
58+
type,
59+
healthy: Math.round((healthy / total) * 100),
60+
creating: Math.round((creating / total) * 100)
61+
};
62+
});
4963

5064
// Progress bar logic (unchanged)
5165
const healthyCount = allItems.filter((item: ManagedResourceItem) => {
@@ -88,19 +102,23 @@ export const CrossplaneHint: React.FC<CrossplaneHintProps> = ({
88102
}
89103
titleText={t('Hints.CrossplaneHint.title')}
90104
subtitleText={t('Hints.CrossplaneHint.subtitle')}
91-
interactive={true}
105+
interactive={enabled}
92106
/>
93107
}
94-
style={cardStyle}
95-
onClick={() => {
108+
className={cx({
109+
[styles['disabled']]: !enabled,
110+
})}
111+
onClick={enabled ? () => {
96112
const el = document.querySelector('.crossplane-table-element');
97113
if (el) {
98114
el.scrollIntoView({ behavior: 'smooth', block: 'start' });
99115
}
100-
}}
101-
onMouseEnter={() => setHovered(true)}
102-
onMouseLeave={() => setHovered(false)}
116+
} : undefined}
117+
onMouseEnter={enabled ? () => setHovered(true) : undefined}
118+
onMouseLeave={enabled ? () => setHovered(false) : undefined}
103119
>
120+
{/* Disabled overlay */}
121+
{!enabled && <div className={styles.disabledOverlay} />}
104122

105123
<div style={{ display: 'flex', flexDirection: 'column', alignItems: 'center', padding: '1rem 0' }}>
106124
{isLoading ? (
@@ -138,19 +156,36 @@ export const CrossplaneHint: React.FC<CrossplaneHintProps> = ({
138156
/>
139157
)}
140158
</div>
141-
{/* Minimal RadarChart for resource healthiness, only show on hover */}
142-
{hovered && !isLoading && !error && radarDataset.length > 0 && (
143-
<div style={{ width: 260, height: 260, display: 'flex', justifyContent: 'center', alignItems: 'center', margin: '1rem 0', overflow: 'visible' }}>
159+
{/* RadarChart for resource healthiness, only show on hover when enabled */}
160+
{enabled && hovered && !isLoading && !error && radarDataset.length > 0 && (
161+
<div style={{
162+
width: '100%',
163+
height: 300,
164+
display: 'flex',
165+
justifyContent: 'center',
166+
alignItems: 'center',
167+
margin: '1rem 0',
168+
overflow: 'visible'
169+
}}>
144170
<RadarChart
145171
dataset={radarDataset}
146172
dimensions={[{ accessor: 'type' }]}
147-
measures={[{
148-
accessor: 'health',
149-
color: 'green',
150-
hideDataLabel: true,
151-
}]}
152-
style={{ width: 220, height: 220 }}
153-
noLegend={true}
173+
measures={[
174+
{
175+
accessor: 'healthy',
176+
color: '#28a745',
177+
hideDataLabel: true,
178+
label: 'Healthy (%)'
179+
},
180+
{
181+
accessor: 'creating',
182+
color: '#fd7e14',
183+
hideDataLabel: true,
184+
label: 'Creating (%)'
185+
}
186+
]}
187+
style={{ width: '100%', height: '100%', minWidth: 280, minHeight: 280 }}
188+
noLegend={false}
154189
/>
155190
</div>
156191
)}

src/components/Hints/GitOpsHint.tsx

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
import { Card, CardHeader, ProgressIndicator, Button } from '@ui5/webcomponents-react';
22
import { useTranslation } from 'react-i18next';
3+
import cx from 'clsx';
34
import { APIError } from '../../lib/api/error';
4-
import { getDisabledCardStyle } from './Hints';
5+
import { styles } from './Hints';
56
import { ManagedResourceItem } from '../../lib/shared/types';
67

78
interface GitOpsHintProps {
@@ -48,8 +49,6 @@ export const GitOpsHint: React.FC<GitOpsHintProps> = ({
4849
: 'None'
4950
: 'None';
5051

51-
const cardStyle = enabled ? {} : getDisabledCardStyle();
52-
5352
return (
5453
<div style={{ position: 'relative', width: '100%' }}>
5554
<Card
@@ -65,17 +64,21 @@ export const GitOpsHint: React.FC<GitOpsHintProps> = ({
6564
}
6665
titleText={t('Hints.GitOpsHint.title')}
6766
subtitleText={t('Hints.GitOpsHint.subtitle')}
68-
interactive={true}
67+
interactive={enabled}
6968
/>
7069
}
71-
style={cardStyle}
72-
onClick={() => {
70+
className={cx({
71+
[styles['disabled']]: !enabled,
72+
})}
73+
onClick={enabled ? () => {
7374
const el = document.querySelector('.cp-page-section-gitops');
7475
if (el) {
7576
el.scrollIntoView({ behavior: 'smooth', block: 'start' });
7677
}
77-
}}
78+
} : undefined}
7879
>
80+
{/* Disabled overlay */}
81+
{!enabled && <div className={styles.disabledOverlay} />}
7982
<div style={{ display: 'flex', flexDirection: 'column', alignItems: 'center', padding: '1rem 0' }}>
8083
{isLoading ? (
8184
<ProgressIndicator
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
.disabled {
2+
position: relative;
3+
}
4+
5+
.disabledOverlay {
6+
position: absolute;
7+
top: 0;
8+
left: 0;
9+
right: 0;
10+
bottom: 0;
11+
background: rgba(255, 255, 255, 0.6);
12+
backdrop-filter: grayscale(0.9) blur(0.5px);
13+
border-radius: inherit;
14+
z-index: 1;
15+
pointer-events: none;
16+
}
17+
18+
/* Dark mode support */
19+
@media (prefers-color-scheme: dark) {
20+
.disabledOverlay {
21+
background: rgba(0, 0, 0, 0.4);
22+
}
23+
}
24+
25+
/* Also check for UI5 theme variables for dark themes */
26+
[data-ui5-theme-root*="dark"] .disabledOverlay,
27+
[data-ui5-theme*="dark"] .disabledOverlay {
28+
background: rgba(0, 0, 0, 0.4);
29+
}

src/components/Hints/Hints.tsx

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,8 @@ interface HintsProps {
1414
mcp: ControlPlaneType;
1515
}
1616

17-
// Utility function to create disabled card style
18-
export const getDisabledCardStyle = () => ({
19-
background: '#f3f3f3',
20-
filter: 'grayscale(0.7)',
21-
opacity: 0.7,
22-
});
17+
// Export styles for use by hint components
18+
export { default as styles } from './Hints.module.css';
2319

2420
// Utility function to flatten managed resources
2521
export const flattenManagedResources = (managedResources: any): ManagedResourceItem[] => {
@@ -50,9 +46,10 @@ const Hints: React.FC<HintsProps> = ({ mcp }) => {
5046
justifyContent: 'space-between',
5147
alignItems: 'stretch',
5248
width: '100%',
53-
height: '150px',
54-
zIndex: 9999,
55-
position: 'relative',
49+
// This breaks the scrolling currently since its zIndex is higher than the header bar
50+
// height: '150px',
51+
// zIndex: 9999,
52+
// position: 'relative',
5653
}}
5754
>
5855
<CrossplaneHint

src/components/Hints/VaultHint.tsx

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
import { Card, CardHeader, ProgressIndicator, Button } from '@ui5/webcomponents-react';
22
import { useTranslation } from 'react-i18next';
3+
import cx from 'clsx';
34
import { APIError } from '../../lib/api/error';
4-
import { getDisabledCardStyle } from './Hints';
5+
import { styles } from './Hints';
56
import { ManagedResourceItem } from '../../lib/shared/types';
67

78
interface VaultHintProps {
@@ -23,8 +24,6 @@ export const VaultHint: React.FC<VaultHintProps> = ({
2324
}) => {
2425
const { t } = useTranslation();
2526

26-
const cardStyle = enabled ? {} : getDisabledCardStyle();
27-
2827
return (
2928
<div style={{ position: 'relative', width: '100%' }}>
3029
<Card
@@ -43,8 +42,12 @@ export const VaultHint: React.FC<VaultHintProps> = ({
4342
interactive={false}
4443
/>
4544
}
46-
style={cardStyle}
45+
className={cx({
46+
[styles['disabled']]: !enabled,
47+
})}
4748
>
49+
{/* Disabled overlay */}
50+
{!enabled && <div className={styles.disabledOverlay} />}
4851
<div style={{ display: 'flex', flexDirection: 'column', alignItems: 'center', padding: '1rem 0' }}>
4952
{isLoading ? (
5053
<ProgressIndicator
@@ -62,7 +65,7 @@ export const VaultHint: React.FC<VaultHintProps> = ({
6265
/>
6366
) : (
6467
<ProgressIndicator
65-
value={allItems.length > 0 ? 100 : 0}
68+
value={allItems.length > 0 ? 0 : 0}
6669
displayValue={enabled ? (allItems.length > 0 ? `100${t('Hints.VaultHint.progressAvailable')}` : t('Hints.VaultHint.noResources')) : t('Hints.VaultHint.inactive')}
6770
valueState={enabled ? (allItems.length > 0 ? 'Positive' : 'None') : 'None'}
6871
style={{ width: '80%', maxWidth: 500, minWidth: 120 }}

0 commit comments

Comments
 (0)