Skip to content

Commit 183365e

Browse files
committed
Fix Nostr Statistics dropdown graphs to match liquid blue theme - Add dark glass morphism background, match Bitcoin chart styling, add expand/collapse all button
1 parent 43a4f4c commit 183365e

2 files changed

Lines changed: 98 additions & 31 deletions

File tree

src/components/tables/Tables/Tables.tsx

Lines changed: 44 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,21 @@
1-
import React from 'react';
1+
import React, { useState } from 'react';
22
import EditableTable from '../editableTable/EditableTable';
33
import { useTranslation } from 'react-i18next';
44
import * as S from './Tables.styles';
55
import { useResponsive } from '@app/hooks/useResponsive';
6+
import { BaseButton } from '@app/components/common/BaseButton/BaseButton';
7+
import { ExpandOutlined, ShrinkOutlined } from '@ant-design/icons';
68

79
export const Tables: React.FC = () => {
810
const { isDesktop } = useResponsive();
911
const { t } = useTranslation();
12+
const [allExpanded, setAllExpanded] = useState(false);
13+
const [expandedKeys, setExpandedKeys] = useState<number[]>([]);
14+
15+
const toggleAllExpanded = () => {
16+
setAllExpanded(!allExpanded);
17+
};
18+
1019
return (
1120
<>
1221
<S.TablesWrapper>
@@ -15,8 +24,41 @@ export const Tables: React.FC = () => {
1524
id="editable-table"
1625
title={'Kind Number Stats'}
1726
padding={isDesktop ? '1.25rem 1.25rem 1rem 1.25rem' : '1.25rem .5rem 1.25rem .5rem'}
27+
extra={
28+
<BaseButton
29+
type="ghost"
30+
icon={allExpanded ? <ShrinkOutlined /> : <ExpandOutlined />}
31+
onClick={toggleAllExpanded}
32+
style={{
33+
background: 'rgba(0, 255, 255, 0.1)',
34+
border: '1px solid rgba(0, 255, 255, 0.3)',
35+
color: 'rgba(0, 255, 255, 0.9)',
36+
padding: '4px 12px',
37+
borderRadius: '6px',
38+
fontSize: '13px',
39+
fontWeight: 500,
40+
transition: 'all 0.3s ease',
41+
}}
42+
onMouseEnter={(e) => {
43+
e.currentTarget.style.background = 'rgba(0, 255, 255, 0.2)';
44+
e.currentTarget.style.borderColor = 'rgba(0, 255, 255, 0.5)';
45+
e.currentTarget.style.boxShadow = '0 0 10px rgba(0, 255, 255, 0.3)';
46+
}}
47+
onMouseLeave={(e) => {
48+
e.currentTarget.style.background = 'rgba(0, 255, 255, 0.1)';
49+
e.currentTarget.style.borderColor = 'rgba(0, 255, 255, 0.3)';
50+
e.currentTarget.style.boxShadow = 'none';
51+
}}
52+
>
53+
{allExpanded ? 'Collapse All' : 'Expand All'}
54+
</BaseButton>
55+
}
1856
>
19-
<EditableTable />
57+
<EditableTable
58+
allExpanded={allExpanded}
59+
expandedKeys={expandedKeys}
60+
setExpandedKeys={setExpandedKeys}
61+
/>
2062
</S.Card>
2163
</S.TablesWrapper>
2264
</>

src/components/tables/editableTable/EditableTable.tsx

Lines changed: 54 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@ import useKindTrendData from '@app/hooks/useKindTrendData';
2020
import { Breakpoint } from 'antd/lib/_util/responsiveObserve';
2121
import { useResponsive } from '@app/hooks/useResponsive';
2222
import { BaseSkeleton } from '@app/components/common/BaseSkeleton/BaseSkeleton';
23-
import { CaretDownOutlined, CaretRightOutlined } from '@ant-design/icons';
23+
import { CaretDownOutlined, CaretRightOutlined, ExpandOutlined, ShrinkOutlined } from '@ant-design/icons';
24+
import { BaseButton } from '@app/components/common/BaseButton/BaseButton';
2425
ChartJS.register(CategoryScale, LinearScale, PointElement, LineElement, Title, Tooltip, Legend, Filler);
2526

2627
interface KindData {
@@ -31,7 +32,17 @@ interface KindData {
3132
totalSize: number;
3233
}
3334

34-
const EditableTable: React.FC = () => {
35+
interface EditableTableProps {
36+
allExpanded?: boolean;
37+
expandedKeys?: number[];
38+
setExpandedKeys?: (keys: number[]) => void;
39+
}
40+
41+
const EditableTable: React.FC<EditableTableProps> = ({
42+
allExpanded: parentAllExpanded,
43+
expandedKeys: parentExpandedKeys,
44+
setExpandedKeys: parentSetExpandedKeys
45+
}) => {
3546
const [form] = BaseForm.useForm();
3647
const { t } = useTranslation();
3748
const { kindData: initialKindData, isLoading } = useKindData();
@@ -60,12 +71,29 @@ const EditableTable: React.FC = () => {
6071
}
6172
}, [initialKindData, sortOrder, sortField]);
6273

74+
// Handle expand all/collapse all from parent
75+
useEffect(() => {
76+
if (parentAllExpanded !== undefined && sortedData.length > 0) {
77+
if (parentAllExpanded) {
78+
const allKeys = sortedData.map((item) => item.kindNumber);
79+
setExpandedRowKeys(allKeys);
80+
if (parentSetExpandedKeys) parentSetExpandedKeys(allKeys);
81+
} else {
82+
setExpandedRowKeys([]);
83+
if (parentSetExpandedKeys) parentSetExpandedKeys([]);
84+
}
85+
}
86+
}, [parentAllExpanded, sortedData, parentSetExpandedKeys]);
87+
6388
const handleExpand = (expanded: boolean, record: KindData) => {
89+
let newKeys: number[];
6490
if (expanded) {
65-
setExpandedRowKeys([...expandedRowKeys, record.kindNumber]);
91+
newKeys = [...expandedRowKeys, record.kindNumber];
6692
} else {
67-
setExpandedRowKeys(expandedRowKeys.filter(key => key !== record.kindNumber));
93+
newKeys = expandedRowKeys.filter(key => key !== record.kindNumber);
6894
}
95+
setExpandedRowKeys(newKeys);
96+
if (parentSetExpandedKeys) parentSetExpandedKeys(newKeys);
6997
};
7098

7199
const handleChange = (pagination: any, filters: any, sorter: any) => {
@@ -134,17 +162,16 @@ const EditableTable: React.FC = () => {
134162
size: 12,
135163
weight: 'bold',
136164
},
137-
color: 'rgba(0, 255, 255, 0.9)', // Liquid cyan for titles
165+
color: 'rgba(255, 255, 255, 0.95)', // White text for titles like Bitcoin chart
138166
},
139167
ticks: {
140168
font: {
141-
size: 11,
169+
size: 12,
142170
},
143-
color: 'rgba(0, 255, 255, 0.6)', // Lighter cyan for tick labels
171+
color: 'rgba(255, 255, 255, 0.9)', // White text like Bitcoin chart
144172
},
145173
grid: {
146-
color: 'rgba(0, 255, 255, 0.05)', // Very subtle cyan grid
147-
drawBorder: false,
174+
color: 'rgba(0, 255, 255, 0.15)', // Match Bitcoin borderBase
148175
},
149176
},
150177
x: {
@@ -155,17 +182,16 @@ const EditableTable: React.FC = () => {
155182
size: 12,
156183
weight: 'bold',
157184
},
158-
color: 'rgba(0, 255, 255, 0.9)', // Liquid cyan for titles
185+
color: 'rgba(255, 255, 255, 0.95)', // White text for titles like Bitcoin chart
159186
},
160187
ticks: {
161188
font: {
162189
size: 11,
163190
},
164-
color: 'rgba(0, 255, 255, 0.6)', // Lighter cyan for tick labels
191+
color: 'rgba(255, 255, 255, 0.9)', // White text like Bitcoin chart
165192
},
166193
grid: {
167-
color: 'rgba(0, 255, 255, 0.05)', // Very subtle cyan grid
168-
drawBorder: false,
194+
color: 'rgba(0, 255, 255, 0.15)', // Match Bitcoin borderBase
169195
},
170196
},
171197
},
@@ -176,7 +202,7 @@ const EditableTable: React.FC = () => {
176202
font: {
177203
size: 13,
178204
},
179-
color: 'rgba(0, 255, 255, 0.9)', // Liquid cyan for legend
205+
color: 'rgba(255, 255, 255, 0.95)', // White text for legend like Bitcoin chart
180206
},
181207
},
182208
filler: {
@@ -186,21 +212,18 @@ const EditableTable: React.FC = () => {
186212
callbacks: {
187213
label: (context: any) => `Total Size: ${context.raw.toFixed(3)} GB`,
188214
},
189-
backgroundColor: 'rgba(0, 10, 20, 0.95)',
190-
titleColor: 'rgba(0, 255, 255, 1)', // Liquid cyan
191-
bodyColor: 'rgba(255, 255, 255, 0.9)',
192-
borderColor: 'rgba(0, 255, 255, 0.3)',
215+
backgroundColor: 'rgba(0, 0, 0, 0.8)',
216+
titleColor: '#06B6D4', // Primary color like Bitcoin chart
217+
bodyColor: 'rgba(255, 255, 255, 0.95)',
218+
borderColor: '#06B6D4',
193219
borderWidth: 1,
194-
cornerRadius: 8,
195-
displayColors: false,
196-
padding: 12,
197220
},
198221
},
199222
layout: {
200223
padding: 0,
201224
},
202225
animation: {
203-
duration: 800,
226+
duration: 1000,
204227
easing: 'easeInOutQuart',
205228
},
206229
hover: {
@@ -222,16 +245,18 @@ const EditableTable: React.FC = () => {
222245
backgroundColor: (context: any) => {
223246
const ctx = context.chart.ctx;
224247
const gradient = ctx.createLinearGradient(0, 0, 0, 400);
225-
gradient.addColorStop(0, 'rgba(0, 255, 255, 0.3)'); // Liquid cyan
226-
gradient.addColorStop(1, 'rgba(0, 255, 255, 0.02)'); // Fade to transparent
248+
gradient.addColorStop(0, 'rgba(0, 255, 255, 0.15)'); // Match Bitcoin chart gradient
249+
gradient.addColorStop(1, 'rgba(0, 255, 255, 0.05)'); // Subtle fade
227250
return gradient;
228251
},
229-
borderColor: 'rgba(0, 255, 255, 0.8)', // Liquid cyan border
230-
pointBackgroundColor: 'rgba(0, 255, 255, 0.9)',
231-
pointBorderColor: 'rgba(0, 255, 255, 0.5)',
232-
pointHoverBackgroundColor: '#00FFFF',
233-
pointHoverBorderColor: 'rgba(0, 255, 255, 1)',
252+
borderColor: '#06B6D4', // Match liquid blue theme primary color (from Bitcoin chart)
253+
pointBackgroundColor: '#06B6D4',
254+
pointBorderColor: 'rgba(255, 255, 255, 0.95)', // White border like Bitcoin chart
255+
pointHoverBackgroundColor: 'rgba(255, 255, 255, 0.95)',
256+
pointHoverBorderColor: '#06B6D4',
234257
tension: 0.4,
258+
pointRadius: 4,
259+
pointHoverRadius: 6,
235260
},
236261
],
237262
};

0 commit comments

Comments
 (0)