Skip to content

Commit 8f40983

Browse files
committed
feat(insights): add evaluation period selector in component drawer
Also fixes UI-11
1 parent 099f680 commit 8f40983

File tree

12 files changed

+701
-589
lines changed

12 files changed

+701
-589
lines changed

apps/insights/src/app/component-score-history/route.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,14 @@ export const GET = async (req: NextRequest) => {
1515
),
1616
);
1717
if (parsed.success) {
18-
const { cluster, publisherKey, symbol } = parsed.data;
19-
const data = await getFeedScoreHistory(cluster, publisherKey, symbol);
18+
const { cluster, publisherKey, symbol, from, to } = parsed.data;
19+
const data = await getFeedScoreHistory(
20+
cluster,
21+
publisherKey,
22+
symbol,
23+
from,
24+
to,
25+
);
2026
return Response.json(data);
2127
} else {
2228
return new Response(fromError(parsed.error).toString(), {
@@ -29,4 +35,6 @@ const queryParamsSchema = z.object({
2935
cluster: z.enum(CLUSTER_NAMES).transform((value) => toCluster(value)),
3036
publisherKey: z.string(),
3137
symbol: z.string().transform((value) => decodeURIComponent(value)),
38+
from: z.string(),
39+
to: z.string(),
3240
});

apps/insights/src/components/LivePrices/index.tsx

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,11 @@ export const LiveValue = <T extends keyof PriceData>({
146146
}: LiveValueProps<T>) => {
147147
const { current } = useLivePriceData(feedKey);
148148

149-
return current?.[field]?.toString() ?? defaultValue;
149+
return current !== undefined || defaultValue !== undefined ? (
150+
(current?.[field]?.toString() ?? defaultValue)
151+
) : (
152+
<Skeleton width={SKELETON_WIDTH} />
153+
);
150154
};
151155

152156
type LiveComponentValueProps<T extends keyof PriceComponent["latest"]> = {
@@ -164,7 +168,11 @@ export const LiveComponentValue = <T extends keyof PriceComponent["latest"]>({
164168
}: LiveComponentValueProps<T>) => {
165169
const { current } = useLivePriceComponent(feedKey, publisherKey);
166170

167-
return current?.latest[field].toString() ?? defaultValue;
171+
return current !== undefined || defaultValue !== undefined ? (
172+
(current?.latest[field].toString() ?? defaultValue)
173+
) : (
174+
<Skeleton width={SKELETON_WIDTH} />
175+
);
168176
};
169177

170178
const isToday = (date: Date) => {

apps/insights/src/components/PriceComponentDrawer/index.module.scss

Lines changed: 160 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,164 @@
1717
margin: theme.spacing(40) auto;
1818
font-size: theme.spacing(16);
1919
}
20+
21+
.rankingBreakdown {
22+
.scoreHistoryChart {
23+
grid-column: span 2 / span 2;
24+
border-radius: theme.border-radius("2xl");
25+
display: flex;
26+
flex-flow: column nowrap;
27+
gap: theme.spacing(4);
28+
background: theme.color("background", "primary");
29+
margin-bottom: theme.spacing(2);
30+
31+
.top {
32+
display: flex;
33+
flex-flow: row nowrap;
34+
justify-content: space-between;
35+
align-items: flex-start;
36+
margin: theme.spacing(4);
37+
38+
.left {
39+
display: flex;
40+
flex-flow: column nowrap;
41+
gap: theme.spacing(1);
42+
43+
.header {
44+
color: theme.color("heading");
45+
46+
@include theme.text("sm", "medium");
47+
}
48+
49+
.subheader {
50+
color: theme.color("muted");
51+
52+
@include theme.text("xs", "normal");
53+
}
54+
}
55+
}
56+
57+
.chart {
58+
border-bottom-left-radius: theme.border-radius("2xl");
59+
border-bottom-right-radius: theme.border-radius("2xl");
60+
overflow: hidden;
61+
62+
.score,
63+
.uptimeScore,
64+
.deviationScore,
65+
.stalledScore {
66+
transition: opacity 100ms linear;
67+
opacity: 0.2;
68+
}
69+
70+
.score {
71+
color: theme.color("states", "data", "normal");
72+
}
73+
74+
.uptimeScore {
75+
color: theme.color("states", "info", "normal");
76+
}
77+
78+
.deviationScore {
79+
color: theme.color("states", "lime", "normal");
80+
}
81+
82+
.stalledScore {
83+
color: theme.color("states", "warning", "normal");
84+
}
85+
}
86+
87+
&:not([data-focused-score], [data-hovered-score]) {
88+
.score,
89+
.uptimeScore,
90+
.deviationScore,
91+
.stalledScore {
92+
opacity: 1;
93+
}
94+
}
95+
96+
&[data-hovered-score="uptime"],
97+
&[data-focused-score="uptime"] {
98+
.uptimeScore {
99+
opacity: 1;
100+
}
101+
}
102+
103+
&[data-hovered-score="deviation"],
104+
&[data-focused-score="deviation"] {
105+
.deviationScore {
106+
opacity: 1;
107+
}
108+
}
109+
110+
&[data-hovered-score="stalled"],
111+
&[data-focused-score="stalled"] {
112+
.stalledScore {
113+
opacity: 1;
114+
}
115+
}
116+
117+
&[data-hovered-score="final"],
118+
&[data-focused-score="final"] {
119+
.score {
120+
opacity: 1;
121+
}
122+
}
123+
}
124+
125+
.date {
126+
@include theme.text("sm", "normal");
127+
128+
margin: theme.spacing(2) theme.spacing(4);
129+
}
130+
131+
.scoreCell {
132+
vertical-align: top;
133+
}
134+
135+
.metric {
136+
display: flex;
137+
flex-flow: column nowrap;
138+
gap: theme.spacing(2);
139+
overflow: hidden;
140+
141+
.metricName {
142+
display: flex;
143+
flex-flow: row nowwrap;
144+
align-items: center;
145+
gap: theme.spacing(2);
146+
147+
.legend {
148+
width: theme.spacing(4);
149+
height: theme.spacing(4);
150+
fill: none;
151+
}
152+
}
153+
154+
.metricDescription {
155+
color: theme.color("muted");
156+
157+
@include theme.text("sm", "normal");
158+
159+
white-space: normal;
160+
line-height: 1.2;
161+
}
162+
163+
&[data-component="uptime"] .legend {
164+
stroke: theme.color("states", "info", "normal");
165+
}
166+
167+
&[data-component="deviation"] .legend {
168+
stroke: theme.color("states", "lime", "normal");
169+
}
170+
171+
&[data-component="stalled"] .legend {
172+
stroke: theme.color("states", "warning", "normal");
173+
}
174+
175+
&[data-component="final"] .legend {
176+
stroke: theme.color("states", "data", "normal");
177+
}
178+
}
179+
}
20180
}

0 commit comments

Comments
 (0)