Skip to content

Commit f7898a3

Browse files
chore: slot detail stats density and layout
1 parent b1f86e9 commit f7898a3

37 files changed

+438
-351
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: 7 additions & 1 deletion
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,7 +15,11 @@ 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, 200px)"
20+
gapX={gridGapX}
21+
gapY={gridGapY}
22+
>
1823
{limits.used_account_write_costs.map(({ account, cost }) => (
1924
<PctBarRow
2025
key={account}
@@ -23,6 +28,7 @@ export default function BusyAccounts() {
2328
total={limits.max_account_write_cost}
2429
valueColor="#30A46C"
2530
numeratorColor={false}
31+
pctColor={true}
2632
/>
2733
))}
2834
</Grid>

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

Lines changed: 15 additions & 15 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

@@ -53,7 +53,11 @@ export default function ComputeUnitStats() {
5353

5454
return (
5555
<SlotDetailsSubSection title="Consumed Compute Units">
56-
<Grid columns="repeat(5, auto) minmax(80px, auto)" gapX="2" gapY="1">
56+
<Grid
57+
columns="repeat(5, auto) minmax(80px, auto)"
58+
gapX={gridGapX}
59+
gapY={gridGapY}
60+
>
5761
<CuStatRow
5862
label="Vote"
5963
cus={stats.vote}
@@ -89,23 +93,19 @@ function CuStatRow({ label, cus, totalCus, pctColor }: CuStatRowProps) {
8993

9094
return (
9195
<>
92-
<Text wrap="nowrap" style={{ color: slotDetailsStatsSecondary }}>
93-
{label}
94-
</Text>
95-
<Text wrap="nowrap" style={{ color: pctColor }} align="right">
96+
<Text className={styles.label}>{label}</Text>
97+
<Text className={styles.value} style={{ color: pctColor }} align="right">
9698
{cus.toLocaleString()}
9799
</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>
100+
<Text className={styles.value}>/</Text>
104101
<Text
105-
wrap="nowrap"
106-
style={{ color: slotDetailsStatsPrimary }}
102+
className={styles.value}
103+
style={{ color: computeUnitsColor }}
107104
align="right"
108105
>
106+
{totalCus.toLocaleString()}
107+
</Text>
108+
<Text className={styles.value} align="right">
109109
{cuPctFromTotal}%
110110
</Text>
111111
<svg

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

Lines changed: 27 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,10 @@ import { getDurationWithUnits } from "../../../Overview/SlotPerformance/Transact
77
import type { SlotTransactions } from "../../../../api/types";
88
import PctBar from "../PctBar";
99
import { SlotDetailsSubSection } from "../SlotDetailsSubSection";
10-
import { slotDetailsStatsPrimary } from "../../../../colors";
10+
import styles from "../detailedSlotStats.module.css";
11+
import clsx from "clsx";
12+
import MonoText from "../../../../components/MonoText";
13+
import { gridGapX, gridGapY } from "../consts";
1114

1215
const initDurations = {
1316
preLoading: 0,
@@ -93,15 +96,15 @@ export default function CumulativeExecutionTimeStats() {
9396

9497
return (
9598
<SlotDetailsSubSection title="Cumulative Execution Time">
96-
<Grid columns="repeat(7, auto)" gapX="2" gapY="1">
99+
<Grid columns="repeat(7, auto)" gapX={gridGapX} gapY={gridGapY}>
97100
<div />
98-
<Text style={{ color: slotDetailsStatsPrimary, gridColumn: "span 2" }}>
101+
<Text className={styles.tableHeader} style={{ gridColumn: "span 2" }}>
99102
Success+Landed
100103
</Text>
101-
<Text style={{ color: slotDetailsStatsPrimary, gridColumn: "span 2" }}>
104+
<Text className={styles.tableHeader} style={{ gridColumn: "span 2" }}>
102105
Failed+Landed
103106
</Text>
104-
<Text style={{ color: slotDetailsStatsPrimary, gridColumn: "span 2" }}>
107+
<Text className={styles.tableHeader} style={{ gridColumn: "span 2" }}>
105108
Unlanded
106109
</Text>
107110
<Row
@@ -169,8 +172,6 @@ function Row({
169172
max,
170173
isTotal,
171174
}: RowProps) {
172-
const labelColor = isTotal ? "var(--gray-12)" : "var(--gray-11)";
173-
const valueColor = isTotal ? "var(--gray-11)" : "var(--gray-10)";
174175
const landedSuccessColor = isTotal ? "#28684A" : "#174933";
175176
const landedFailedColor = isTotal ? "#8C333A" : "#611623";
176177
const unlandedColor = isTotal ? "#12677E" : "#004558";
@@ -181,23 +182,35 @@ function Row({
181182

182183
return (
183184
<>
184-
<Text wrap="nowrap" style={{ color: labelColor }}>
185+
<Text className={clsx(styles.tableRowLabel, isTotal && styles.total)}>
185186
{label}
186187
</Text>
187-
<Text wrap="nowrap" style={{ color: valueColor }} align="right">
188-
{`${landedSuccessUnits.value} ${landedSuccessUnits.unit}`}
188+
<Text
189+
className={clsx(styles.tableCellValue, isTotal && styles.total)}
190+
align="right"
191+
>
192+
{landedSuccessUnits.value}
193+
<MonoText>{landedSuccessUnits.unit}</MonoText>
189194
</Text>
190195
<PctBar
191196
value={landedSuccess}
192197
total={max}
193198
valueColor={landedSuccessColor}
194199
/>
195-
<Text wrap="nowrap" style={{ color: valueColor }} align="right">
196-
{`${landedFailedUnits.value} ${landedFailedUnits.unit}`}
200+
<Text
201+
className={clsx(styles.tableCellValue, isTotal && styles.total)}
202+
align="right"
203+
>
204+
{landedFailedUnits.value}
205+
<MonoText>{landedFailedUnits.unit}</MonoText>
197206
</Text>
198207
<PctBar value={landedFailed} total={max} valueColor={landedFailedColor} />
199-
<Text wrap="nowrap" style={{ color: valueColor }} align="right">
200-
{`${unlandedUnits.value} ${unlandedUnits.unit}`}
208+
<Text
209+
className={clsx(styles.tableCellValue, isTotal && styles.total)}
210+
align="right"
211+
>
212+
{unlandedUnits.value}
213+
<MonoText>{unlandedUnits.unit}</MonoText>
201214
</Text>
202215
<PctBar value={unlanded} total={max} valueColor={unlandedColor} />
203216
</>

0 commit comments

Comments
 (0)