From f89bd0de7fa785354ce9df36637c9f88cbfc13ef Mon Sep 17 00:00:00 2001 From: c-bata Date: Tue, 3 Jan 2023 00:46:47 +0900 Subject: [PATCH] Improve Chip styles --- optuna_dashboard/ts/components/TrialList.tsx | 97 +++++++++++--------- 1 file changed, 55 insertions(+), 42 deletions(-) diff --git a/optuna_dashboard/ts/components/TrialList.tsx b/optuna_dashboard/ts/components/TrialList.tsx index eced23ec..cf56ff79 100644 --- a/optuna_dashboard/ts/components/TrialList.tsx +++ b/optuna_dashboard/ts/components/TrialList.tsx @@ -20,6 +20,30 @@ import { TrialNote } from "./Note" import { DataGrid, DataGridColumn } from "./DataGrid" import { Link } from "react-router-dom" +type Color = + | "default" + | "primary" + | "secondary" + | "error" + | "info" + | "success" + | "warning" + +const getChipColor = (state: TrialState): Color => { + if (state === "Complete") { + return "success" + } else if (state === "Running") { + return "secondary" + } else if (state === "Waiting") { + return "secondary" + } else if (state === "Pruned") { + return "warning" + } else if (state === "Fail") { + return "error" + } + return "default" +} + export const TrialList: FC<{ studyDetail: StudyDetail | null trialNumber: number | null @@ -75,15 +99,17 @@ export const TrialList: FC<{ - - {isBestTrial(trial.trial_id) ? ( + + - ) : null} + {isBestTrial(trial.trial_id) ? ( + + ) : null} + Values:{" "} {trial.values?.map((v) => v.toString()).join(" ") || "None"} @@ -152,25 +178,6 @@ export const TrialList: FC<{ studyDetail?.trials.length || 0 } Trials`} {trials.map((trial, i) => { - let color: - | "default" - | "primary" - | "secondary" - | "error" - | "info" - | "success" - | "warning" = "default" - if (trial.state === "Complete") { - color = "success" - } else if (trial.state === "Running") { - color = "secondary" - } else if (trial.state === "Waiting") { - color = "secondary" - } else if (trial.state === "Pruned") { - color = "warning" - } else if (trial.state === "Fail") { - color = "error" - } return ( - - - {isBestTrial(trial.trial_id) ? ( - - ) : null} - - } - /> + + + + {isBestTrial(trial.trial_id) ? ( + + ) : null} + )