Skip to content

Commit

Permalink
Merge pull request #2216 from pyth-network/cprussin/tweak-support-drawer
Browse files Browse the repository at this point in the history
feat(staking): minor improvements to the median score drawer
  • Loading branch information
cprussin authored Dec 30, 2024
2 parents d93e42e + e0a7e5f commit 426c758
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 31 deletions.
16 changes: 12 additions & 4 deletions apps/insights/src/components/Publisher/layout.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,16 @@
}
}

.medianScoreDrawerBody {
display: flex;
flex-flow: column nowrap;
gap: theme.spacing(6);
.medianScoreDrawer {
.medianScoreDrawerFooter {
display: flex;
flex-flow: row nowrap;
justify-content: flex-end;
}

.medianScoreDrawerBody {
display: flex;
flex-flow: column nowrap;
gap: theme.spacing(6);
}
}
4 changes: 3 additions & 1 deletion apps/insights/src/components/Publisher/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -191,10 +191,12 @@ export const PublishersLayout = async ({ children, params }: Props) => {
/>
<Drawer
title="Median Score"
className={styles.medianScoreDrawer ?? ""}
bodyClassName={styles.medianScoreDrawerBody}
footerClassName={styles.medianScoreDrawerFooter}
footer={
<Button
variant="solid"
variant="outline"
size="sm"
href="https://docs.pyth.network/home/oracle-integrity-staking/publisher-quality-ranking"
target="_blank"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
.medianDeviationScore,
.medianStalledScore {
transition: opacity 100ms linear;
opacity: 0.1;
opacity: 0.2;
}

.medianScore {
Expand Down Expand Up @@ -78,48 +78,28 @@
}
}

&[data-hovered-score="uptime"] {
.medianUptimeScore {
opacity: 0.7;
}
}

&[data-hovered-score="uptime"],
&[data-focused-score="uptime"] {
.medianUptimeScore {
opacity: 1;
}
}

&[data-hovered-score="deviation"] {
.medianDeviationScore {
opacity: 0.7;
}
}

&[data-hovered-score="deviation"],
&[data-focused-score="deviation"] {
.medianDeviationScore {
opacity: 1;
}
}

&[data-hovered-score="stalled"] {
.medianStalledScore {
opacity: 0.7;
}
}

&[data-hovered-score="stalled"],
&[data-focused-score="stalled"] {
.medianStalledScore {
opacity: 1;
}
}

&[data-hovered-score="final"] {
.medianScore {
opacity: 0.7;
}
}

&[data-hovered-score="final"],
&[data-focused-score="final"] {
.medianScore {
opacity: 1;
Expand Down
33 changes: 32 additions & 1 deletion apps/insights/src/components/Publisher/median-score-history.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,12 @@ export const MedianScoreHistory = ({ medianScoreHistory }: Props) => {
>
<div className={styles.top}>
<div className={styles.left}>
<h3 className={styles.header}>Score History</h3>
<h3 className={styles.header}>
<HeaderText
hoveredScore={hoveredScore}
focusedScore={focusedScore}
/>
</h3>
<div className={styles.subheader}>
{selectedPoint
? dateFormatter.format(selectedPoint.time)
Expand Down Expand Up @@ -127,27 +132,31 @@ export const MedianScoreHistory = ({ medianScoreHistory }: Props) => {
dot={false}
className={styles.medianScore ?? ""}
stroke="currentColor"
strokeWidth={focusedScore === "final" ? 3 : 1}
/>
<Line
type="monotone"
dataKey="medianUptimeScore"
dot={false}
className={styles.medianUptimeScore ?? ""}
stroke="currentColor"
strokeWidth={focusedScore === "uptime" ? 3 : 1}
/>
<Line
type="monotone"
dataKey="medianDeviationScore"
dot={false}
className={styles.medianDeviationScore ?? ""}
stroke="currentColor"
strokeWidth={focusedScore === "deviation" ? 3 : 1}
/>
<Line
type="monotone"
dataKey="medianStalledScore"
dot={false}
className={styles.medianStalledScore ?? ""}
stroke="currentColor"
strokeWidth={focusedScore === "stalled" ? 3 : 1}
/>
<XAxis dataKey="time" hide />
<YAxis hide />
Expand Down Expand Up @@ -263,6 +272,28 @@ export const MedianScoreHistory = ({ medianScoreHistory }: Props) => {
);
};

type HeaderTextProps = {
focusedScore: FocusedScore;
hoveredScore: FocusedScore;
};

const HeaderText = ({ hoveredScore, focusedScore }: HeaderTextProps) => {
switch (focusedScore ?? hoveredScore) {
case "uptime": {
return "Median Uptime Score History";
}
case "deviation": {
return "Median Deviation Score History";
}
case "stalled": {
return "Median Stalled Score History";
}
default: {
return "Median Score History";
}
}
};

type FocusedScore = "uptime" | "deviation" | "stalled" | "final" | undefined;

type CurrentValueProps = {
Expand Down

0 comments on commit 426c758

Please sign in to comment.