Skip to content

Commit 14d7225

Browse files
chore: slot detail stats density and layout
1 parent be0f1bd commit 14d7225

37 files changed

+456
-354
lines changed

src/colors.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -262,6 +262,7 @@ export const slotDetailsSelectedColor = "#e3efff";
262262
export const slotDetailsDisabledSlotBorderColor = "#484D53B2";
263263
export const slotDetailsStatsPrimary = "var(--gray-11)";
264264
export const slotDetailsStatsSecondary = "var(--gray-10)";
265+
export const slotDetailsStatsTertiary = "var(--gray-12)";
265266

266267
// slots list
267268
export const slotsListSlotBackgroundColor = "#070A13";

src/components/Card.tsx

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,20 @@ import type { PropsWithChildren, HTMLAttributes } from "react";
44

55
interface CardProps {
66
hideChildren?: boolean;
7-
includeBg?: boolean;
7+
isNarrow?: boolean;
88
}
99

1010
export default function Card({
1111
children,
1212
hideChildren,
13-
includeBg = true,
13+
isNarrow = false,
1414
...props
1515
}: PropsWithChildren<CardProps & HTMLAttributes<HTMLDivElement>>) {
1616
return (
17-
<div className={clsx(styles.card, { [styles.bg]: includeBg })} {...props}>
17+
<div
18+
{...props}
19+
className={clsx(styles.card, isNarrow && styles.narrow, props.className)}
20+
>
1821
{!hideChildren && children}
1922
</div>
2023
);

src/components/card.module.css

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
.card {
2+
padding: 10px;
23
border-radius: 8px;
34
border: 1px solid var(--container-border-color);
4-
padding: 8px 16px;
5+
background: var(--container-background-color);
56

6-
&.bg {
7-
background: var(--container-background-color);
7+
&.narrow {
8+
padding: 4px;
89
}
910
}

src/consts.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ export const txnErrorCodeMap: Record<string, string> = {
6262
export const nonBreakingSpace = "\u00A0";
6363

6464
export const clusterIndicatorHeight = 5;
65-
export const slotNavHeight = 29;
65+
export const slotNavHeight = 30;
6666

6767
export const headerHeight = 48;
6868
export const headerSpacing = 13;

src/features/Overview/SlotPerformance/TileCard.tsx

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import TileSparkLineExpandedContainer from "./TileSparkLineExpandedContainer";
1111
import { useMeasure } from "react-use";
1212
import type React from "react";
1313
import { useLastDefinedValue, useTileSparkline } from "./useTileSparkline";
14+
import clsx from "clsx";
1415

1516
interface TileCardProps {
1617
header: string;
@@ -23,7 +24,8 @@ interface TileCardProps {
2324
sparklineHeight?: number;
2425
isExpanded?: boolean;
2526
setIsExpanded?: (isExpanded: boolean) => void;
26-
includeBg?: boolean;
27+
isDark?: boolean;
28+
isNarrow?: boolean;
2729
}
2830

2931
export default function TileCard({
@@ -37,7 +39,8 @@ export default function TileCard({
3739
sparklineHeight,
3840
isExpanded = false,
3941
setIsExpanded = () => {},
40-
includeBg = true,
42+
isDark = false,
43+
isNarrow,
4144
}: TileCardProps) {
4245
const [ref, { width }] = useMeasure<HTMLDivElement>();
4346

@@ -60,7 +63,10 @@ export default function TileCard({
6063

6164
return (
6265
<Flex ref={ref}>
63-
<Card includeBg={includeBg} style={{ width: "100%" }}>
66+
<Card
67+
className={clsx(styles.fullWidth, isDark && styles.dark)}
68+
isNarrow={isNarrow}
69+
>
6470
<Flex direction="column" justify="between" height="100%" gap="1">
6571
<TileHeader
6672
header={header}
@@ -73,7 +79,7 @@ export default function TileCard({
7379
value={avgBusy}
7480
queryBusy={aggQueryBusyPerTs}
7581
height={sparklineHeight}
76-
includeBg={includeBg}
82+
background={isDark ? "#0000001F" : undefined}
7783
/>
7884
<TileSparkLineExpandedContainer
7985
tileCountArr={tileCountArr}
@@ -100,7 +106,7 @@ export default function TileCard({
100106
key={i}
101107
className={styles.tile}
102108
style={{
103-
background: `gray`,
109+
background: isDark ? "#232A38" : "gray",
104110
}}
105111
/>
106112
);

src/features/Overview/SlotPerformance/TileSparkLine.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,14 @@ interface TileParkLineProps {
2323
value?: number;
2424
queryBusy?: number[];
2525
height?: number;
26-
includeBg?: boolean;
26+
background?: string;
2727
}
2828

2929
export default function TileSparkLine({
3030
value,
3131
queryBusy,
3232
height = 24,
33-
includeBg = true,
33+
background,
3434
}: TileParkLineProps) {
3535
const [svgRef, { width }] = useMeasure<SVGSVGElement>();
3636

@@ -50,7 +50,7 @@ export default function TileSparkLine({
5050
scaledDataPoints={scaledDataPoints}
5151
range={range}
5252
height={height}
53-
background={includeBg ? undefined : "unset"}
53+
background={background}
5454
pxPerTick={pxPerTick}
5555
tickMs={chartTickMs}
5656
isLive={isLive}

src/features/Overview/SlotPerformance/tileCard.module.css

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,15 @@
22
color: var(--dropdown-button-text-color);
33
}
44

5+
.full-width {
6+
width: 100%;
7+
}
8+
9+
.dark {
10+
background: #171b24;
11+
border-color: transparent;
12+
}
13+
514
.subHeader {
615
color: var(--tile-sub-header-color);
716
font-size: 12px;

src/features/SlotDetails/DetailedSlotStats/ComputeSection/BusyAccounts.tsx

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { useSlotQueryResponseDetailed } from "../../../../hooks/useSlotQuery";
44
import { selectedSlotAtom } from "../../../Overview/SlotPerformance/atoms";
55
import PctBarRow from "../PctBarRow";
66
import { SlotDetailsSubSection } from "../SlotDetailsSubSection";
7+
import { gridGapX, gridGapY } from "../consts";
78

89
export default function BusyAccounts() {
910
const selectedSlot = useAtomValue(selectedSlotAtom);
@@ -14,15 +15,21 @@ export default function BusyAccounts() {
1415

1516
return (
1617
<SlotDetailsSubSection title="Top 5 Busy Accounts">
17-
<Grid columns="repeat(5, auto) minmax(80px, 200px)" gapX="2" gapY="1">
18+
<Grid
19+
columns="repeat(5, auto) minmax(80px, 100%)"
20+
gapX={gridGapX}
21+
gapY={gridGapY}
22+
>
1823
{limits.used_account_write_costs.map(({ account, cost }) => (
1924
<PctBarRow
2025
key={account}
21-
label={`${account.substring(0, 8)}...`}
26+
label={account}
27+
labelWidth="80px"
2228
value={cost}
2329
total={limits.max_account_write_cost}
2430
valueColor="#30A46C"
2531
numeratorColor={false}
32+
pctColor={true}
2633
/>
2734
))}
2835
</Grid>

src/features/SlotDetails/DetailedSlotStats/ComputeSection/ComputeUnitStats.tsx

Lines changed: 23 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@ import {
77
computeUnitsColor,
88
headerColor,
99
nonVoteColor,
10-
slotDetailsStatsPrimary,
11-
slotDetailsStatsSecondary,
1210
votesColor,
1311
} from "../../../../colors";
1412
import { SlotDetailsSubSection } from "../SlotDetailsSubSection";
13+
import styles from "../detailedSlotStats.module.css";
14+
import { gridGapX, gridGapY } from "../consts";
1515

1616
const bundleColor = headerColor;
1717

@@ -50,26 +50,34 @@ export default function ComputeUnitStats() {
5050
if (!stats) return;
5151

5252
const totalCus = stats.vote + stats.bundle + stats.other;
53+
const maxCus = Math.max(stats.vote, stats.bundle, stats.other);
5354

5455
return (
5556
<SlotDetailsSubSection title="Consumed Compute Units">
56-
<Grid columns="repeat(5, auto) minmax(80px, auto)" gapX="2" gapY="1">
57+
<Grid
58+
columns="repeat(5, auto) minmax(80px, 100%)"
59+
gapX={gridGapX}
60+
gapY={gridGapY}
61+
>
5762
<CuStatRow
5863
label="Vote"
5964
cus={stats.vote}
6065
totalCus={totalCus}
66+
maxCus={maxCus}
6167
pctColor={votesColor}
6268
/>
6369
<CuStatRow
6470
label="Bundle"
6571
cus={stats.bundle}
6672
totalCus={totalCus}
73+
maxCus={maxCus}
6774
pctColor={bundleColor}
6875
/>
6976
<CuStatRow
7077
label="Other"
7178
cus={stats.other}
7279
totalCus={totalCus}
80+
maxCus={maxCus}
7381
pctColor={nonVoteColor}
7482
/>
7583
</Grid>
@@ -81,31 +89,29 @@ interface CuStatRowProps {
8189
label: string;
8290
cus: number;
8391
totalCus: number;
92+
maxCus: number;
8493
pctColor: string;
8594
}
8695

87-
function CuStatRow({ label, cus, totalCus, pctColor }: CuStatRowProps) {
96+
function CuStatRow({ label, cus, totalCus, maxCus, pctColor }: CuStatRowProps) {
8897
const cuPctFromTotal = Math.round(totalCus ? (cus / totalCus) * 100 : 0);
98+
const cuPctFromMax = Math.round(maxCus ? (cus / maxCus) * 100 : 0);
8999

90100
return (
91101
<>
92-
<Text wrap="nowrap" style={{ color: slotDetailsStatsSecondary }}>
93-
{label}
94-
</Text>
95-
<Text wrap="nowrap" style={{ color: pctColor }} align="right">
102+
<Text className={styles.label}>{label}</Text>
103+
<Text className={styles.value} style={{ color: pctColor }} align="right">
96104
{cus.toLocaleString()}
97105
</Text>
98-
<Text wrap="nowrap" style={{ color: slotDetailsStatsPrimary }}>
99-
/
100-
</Text>
101-
<Text wrap="nowrap" style={{ color: computeUnitsColor }} align="right">
102-
{totalCus.toLocaleString()}
103-
</Text>
106+
<Text className={styles.value}>/</Text>
104107
<Text
105-
wrap="nowrap"
106-
style={{ color: slotDetailsStatsPrimary }}
108+
className={styles.value}
109+
style={{ color: computeUnitsColor }}
107110
align="right"
108111
>
112+
{totalCus.toLocaleString()}
113+
</Text>
114+
<Text className={styles.value} align="right">
109115
{cuPctFromTotal}%
110116
</Text>
111117
<svg
@@ -117,7 +123,7 @@ function CuStatRow({ label, cus, totalCus, pctColor }: CuStatRowProps) {
117123
>
118124
<rect
119125
height="8"
120-
width={`${cuPctFromTotal}%`}
126+
width={`${cuPctFromMax}%`}
121127
opacity={0.6}
122128
fill={pctColor}
123129
/>

src/features/SlotDetails/DetailedSlotStats/ComputeSection/CumulativeExecutionTimeStats.tsx

Lines changed: 27 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,10 @@ import { useMemo } from "react";
66
import { getDurationWithUnits } from "../../../Overview/SlotPerformance/TransactionBarsCard/chartUtils";
77
import PctBar from "../PctBar";
88
import { SlotDetailsSubSection } from "../SlotDetailsSubSection";
9-
import { slotDetailsStatsPrimary } from "../../../../colors";
9+
import styles from "../detailedSlotStats.module.css";
10+
import clsx from "clsx";
11+
import MonoText from "../../../../components/MonoText";
12+
import { gridGapX, gridGapY } from "../consts";
1013
import {
1114
getTxnBundleStats,
1215
getTxnStateDurations,
@@ -85,15 +88,15 @@ export default function CumulativeExecutionTimeStats() {
8588

8689
return (
8790
<SlotDetailsSubSection title="Cumulative Execution Time">
88-
<Grid columns="repeat(7, auto)" gapX="2" gapY="1">
91+
<Grid columns="repeat(7, auto)" gapX={gridGapX} gapY={gridGapY}>
8992
<div />
90-
<Text style={{ color: slotDetailsStatsPrimary, gridColumn: "span 2" }}>
93+
<Text className={styles.tableHeader} style={{ gridColumn: "span 2" }}>
9194
Success+Landed
9295
</Text>
93-
<Text style={{ color: slotDetailsStatsPrimary, gridColumn: "span 2" }}>
96+
<Text className={styles.tableHeader} style={{ gridColumn: "span 2" }}>
9497
Failed+Landed
9598
</Text>
96-
<Text style={{ color: slotDetailsStatsPrimary, gridColumn: "span 2" }}>
99+
<Text className={styles.tableHeader} style={{ gridColumn: "span 2" }}>
97100
Unlanded
98101
</Text>
99102
<Row
@@ -161,8 +164,6 @@ function Row({
161164
max,
162165
isTotal,
163166
}: RowProps) {
164-
const labelColor = isTotal ? "var(--gray-12)" : "var(--gray-11)";
165-
const valueColor = isTotal ? "var(--gray-11)" : "var(--gray-10)";
166167
const landedSuccessColor = isTotal ? "#28684A" : "#174933";
167168
const landedFailedColor = isTotal ? "#8C333A" : "#611623";
168169
const unlandedColor = isTotal ? "#12677E" : "#004558";
@@ -173,23 +174,35 @@ function Row({
173174

174175
return (
175176
<>
176-
<Text wrap="nowrap" style={{ color: labelColor }}>
177+
<Text className={clsx(styles.tableRowLabel, isTotal && styles.total)}>
177178
{label}
178179
</Text>
179-
<Text wrap="nowrap" style={{ color: valueColor }} align="right">
180-
{`${landedSuccessUnits.value} ${landedSuccessUnits.unit}`}
180+
<Text
181+
className={clsx(styles.tableCellValue, isTotal && styles.total)}
182+
align="right"
183+
>
184+
{landedSuccessUnits.value}
185+
<MonoText>{landedSuccessUnits.unit}</MonoText>
181186
</Text>
182187
<PctBar
183188
value={landedSuccess}
184189
total={max}
185190
valueColor={landedSuccessColor}
186191
/>
187-
<Text wrap="nowrap" style={{ color: valueColor }} align="right">
188-
{`${landedFailedUnits.value} ${landedFailedUnits.unit}`}
192+
<Text
193+
className={clsx(styles.tableCellValue, isTotal && styles.total)}
194+
align="right"
195+
>
196+
{landedFailedUnits.value}
197+
<MonoText>{landedFailedUnits.unit}</MonoText>
189198
</Text>
190199
<PctBar value={landedFailed} total={max} valueColor={landedFailedColor} />
191-
<Text wrap="nowrap" style={{ color: valueColor }} align="right">
192-
{`${unlandedUnits.value} ${unlandedUnits.unit}`}
200+
<Text
201+
className={clsx(styles.tableCellValue, isTotal && styles.total)}
202+
align="right"
203+
>
204+
{unlandedUnits.value}
205+
<MonoText>{unlandedUnits.unit}</MonoText>
193206
</Text>
194207
<PctBar value={unlanded} total={max} valueColor={unlandedColor} />
195208
</>

0 commit comments

Comments
 (0)