Skip to content

Commit

Permalink
feat: update stats panel. update styles, use hook.
Browse files Browse the repository at this point in the history
Signed-off-by: Eugene Panteleymonchuk <[email protected]>
  • Loading branch information
panteleymonchuk committed Feb 15, 2024
1 parent df03dc8 commit 5a62002
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ import CameraControls from "./CameraControls";
import "./Visualizer.scss";

const features = {
statsEnabled: true,
statsEnabled: false,
cameraControls: true,
};

Expand Down Expand Up @@ -244,7 +244,6 @@ const VisualizerInstance: React.FC<RouteComponentProps<VisualizerRouteProps>> =

return (
<Wrapper
bps={bpsCounter.getBPS()}
key={network}
blocksCount={indexToBlockId.length}
filter=""
Expand Down
28 changes: 11 additions & 17 deletions client/src/features/visualizer-threejs/wrapper/KeyPanel.scss
Original file line number Diff line number Diff line change
Expand Up @@ -59,23 +59,17 @@
align-items: center;
pointer-events: none;

.stats-panel {
background: var(--body-background);

.card--value,
.card--label {
text-align: left;
}
.card--label {
justify-content: flex-start;
}
.card--content {
padding: 0;
}
.stats-panel__info {
padding: 0 10px;
display: inline-block;
}
.card--label {
justify-content: flex-start;
}
.card--content {
padding: 0;
}
.stats-panel__info {
justify-content: center;
display: flex;
flex-direction: column;
align-items: center;
}

@include tablet-down {
Expand Down
4 changes: 2 additions & 2 deletions client/src/features/visualizer-threejs/wrapper/KeyPanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { BlockState } from "@iota/sdk-wasm-nova/web";
import "./KeyPanel.scss";
import { StatsPanel } from "~features/visualizer-threejs/wrapper/StatsPanel";

export const KeyPanel = ({ bps }: { bps: number }) => {
export const KeyPanel = ({ network }: { network: string }) => {
const statuses: {
label: string;
state: BlockState;
Expand Down Expand Up @@ -59,7 +59,7 @@ export const KeyPanel = ({ bps }: { bps: number }) => {
);
})}
</div>
<StatsPanel bps={bps} />
<StatsPanel network={network} />
</div>
);
};
6 changes: 4 additions & 2 deletions client/src/features/visualizer-threejs/wrapper/StatsPanel.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
import React from "react";
import { useNetworkStats } from "~helpers/stardust/hooks/useNetworkStats";

export const StatsPanel = ({ bps }: { bps: number }) => {
export const StatsPanel = ({ network }: { network: string }) => {
const [blocksPerSecond] = useNetworkStats(network);
return (
<div className="stats-panel-container">
<div className="card">
<div className="stats-panel__info">
<div className="card--label">BPS</div>
<div className="card--value green">{parseInt(String(bps))}</div>
<div className="card--value green">{blocksPerSecond}</div>
</div>
</div>
</div>
Expand Down
8 changes: 3 additions & 5 deletions client/src/features/visualizer-threejs/wrapper/Wrapper.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,18 @@ import { SelectedFeedInfo } from "./SelectedFeedInfo";

export const Wrapper = ({
blocksCount,
bps,
children,
filter,
isEdgeRenderingEnabled,
isPlaying,
network,
networkConfig,
onChangeFilter,
selectNode,
selectedFeedItem,
setEdgeRenderingEnabled,
setIsPlaying,
isEdgeRenderingEnabled,
setEdgeRenderingEnabled,
}: {
readonly bps: number;
readonly blocksCount: number;
readonly children: React.ReactNode;
readonly filter: string;
Expand Down Expand Up @@ -71,7 +69,7 @@ export const Wrapper = ({
</div>

{selectedFeedItem && <SelectedFeedInfo networkConfig={networkConfig} network={network} selectedFeedItem={selectedFeedItem} />}
<KeyPanel bps={bps} />
<KeyPanel network={network} />
</div>
);

Expand Down

0 comments on commit 5a62002

Please sign in to comment.