Skip to content

Commit 4bc8aac

Browse files
author
weinStag
committed
Add chart toggle button in Toolbar component
- Show/Hide chart functionality with icons - Responsive button positioning - Avoid conflicts with existing stats button - Clean hover effects and styling
1 parent 30d8e1d commit 4bc8aac

File tree

2 files changed

+135
-14
lines changed

2 files changed

+135
-14
lines changed

src/components/Toolbar/Toolbar.react.js

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ const Stats = ({ data, classwiseCloudFunctions, className, appId, appName }) =>
3838
},
3939
{
4040
type: 'p99',
41-
label: 'P99',
41+
label: 'P999',
4242
getValue: data => {
4343
const sorted = data.sort((a, b) => a - b);
4444
return sorted[Math.floor(sorted.length * 0.99)];
@@ -125,6 +125,7 @@ const Stats = ({ data, classwiseCloudFunctions, className, appId, appName }) =>
125125
const Toolbar = props => {
126126
const action = useNavigationType();
127127
const navigate = useNavigate();
128+
128129
let backButton;
129130
if (props.relation || (props.filters && props.filters.size && action !== NavigationType.Pop)) {
130131
backButton = (
@@ -146,13 +147,25 @@ const Toolbar = props => {
146147
</div>
147148
</div>
148149
{props?.selectedData?.length ? (
149-
<Stats
150-
data={props.selectedData}
151-
classwiseCloudFunctions={props.classwiseCloudFunctions}
152-
className={props.className}
153-
appId={props.appId}
154-
appName={props.appName}
155-
/>
150+
<div className={styles.dataControls}>
151+
<Stats
152+
data={props.selectedData}
153+
classwiseCloudFunctions={props.classwiseCloudFunctions}
154+
className={props.className}
155+
appId={props.appId}
156+
appName={props.appName}
157+
/>
158+
{props?.selectedData?.length > 1 && (
159+
<button
160+
onClick={props.toggleChartPanel}
161+
className={styles.chartButton}
162+
title={props.isChartPanelVisible ? 'Hide Data Visualization' : 'Show Data Visualization'}
163+
>
164+
<Icon width={16} height={16} fill="currentColor" name="analytics-outline" />
165+
<span>{props.isChartPanelVisible ? 'Hide Chart' : 'Show Chart B'}</span>
166+
</button>
167+
)}
168+
</div>
156169
) : null}
157170
<div className={styles.actions}>{props.children}</div>
158171
{props.classwiseCloudFunctions &&

src/components/Toolbar/Toolbar.scss

Lines changed: 114 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -87,16 +87,22 @@ body:global(.expanded) {
8787
}
8888

8989
.stats {
90-
position: absolute;
91-
right: 20px;
92-
bottom: 10px;
9390
background: $blue;
94-
border-radius: 3px;
95-
padding: 2px 6px;
91+
border-radius: 6px;
92+
padding: 8px 12px;
9693
font-size: 14px;
94+
font-weight: 500;
9795
color: white;
98-
box-shadow: none;
96+
box-shadow: 0 2px 8px rgba(22, 156, 238, 0.3);
9997
border: none;
98+
transition: all 0.3s ease;
99+
z-index: 5;
100+
101+
&:hover {
102+
background: #1976d2;
103+
transform: translateY(-1px);
104+
box-shadow: 0 4px 12px rgba(22, 156, 238, 0.4);
105+
}
100106
}
101107

102108
.stats_popover_container {
@@ -153,3 +159,105 @@ body:global(.expanded) {
153159
}
154160
}
155161
}
162+
163+
.dataControls {
164+
position: absolute;
165+
right: 20px;
166+
bottom: 10px; // Movido para a mesma linha do stats
167+
display: flex;
168+
align-items: center;
169+
gap: 16px;
170+
z-index: 10;
171+
}
172+
173+
.chartButton {
174+
display: flex;
175+
align-items: center;
176+
gap: 8px;
177+
padding: 8px 16px;
178+
background: linear-gradient(135deg, #169cee, #1976d2);
179+
border: none;
180+
border-radius: 6px;
181+
color: white;
182+
font-size: 13px;
183+
font-weight: 500;
184+
cursor: pointer;
185+
transition: all 0.3s ease;
186+
box-shadow: 0 2px 8px rgba(22, 156, 238, 0.3);
187+
188+
&:hover {
189+
background: linear-gradient(135deg, #1976d2, #1565c0);
190+
transform: translateY(-1px);
191+
box-shadow: 0 4px 12px rgba(22, 156, 238, 0.4);
192+
}
193+
194+
&:active {
195+
transform: translateY(0);
196+
box-shadow: 0 2px 6px rgba(22, 156, 238, 0.3);
197+
}
198+
199+
svg {
200+
flex-shrink: 0;
201+
filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.1));
202+
}
203+
}
204+
205+
// Responsividade para o botão do gráfico
206+
@media (max-width: 968px) {
207+
.stats {
208+
right: 120px; // Menor distância em telas médias
209+
}
210+
}
211+
212+
@media (max-width: 768px) {
213+
.dataControls {
214+
right: 15px;
215+
bottom: 10px;
216+
gap: 12px;
217+
}
218+
219+
.chartButton {
220+
padding: 6px 12px;
221+
font-size: 12px;
222+
gap: 6px;
223+
224+
svg {
225+
width: 14px;
226+
height: 14px;
227+
}
228+
}
229+
230+
.stats {
231+
right: 110px; // Ajustado para telas menores
232+
bottom: 10px;
233+
padding: 6px 10px;
234+
font-size: 13px;
235+
}
236+
}
237+
238+
@media (max-width: 480px) {
239+
.dataControls {
240+
right: 10px;
241+
bottom: 10px;
242+
flex-direction: row;
243+
gap: 8px;
244+
align-items: center;
245+
}
246+
247+
.chartButton {
248+
padding: 5px 8px;
249+
font-size: 11px;
250+
251+
// Em telas muito pequenas, mostra apenas o ícone
252+
span {
253+
display: none;
254+
}
255+
}
256+
257+
.stats {
258+
right: 80px; // Posição ajustada para mobile
259+
bottom: 10px;
260+
font-size: 12px;
261+
padding: 5px 8px;
262+
}
263+
}

0 commit comments

Comments
 (0)