ui/MachineStatus: use css modules

This commit is contained in:
Glen Huang
2025-09-24 15:47:38 +08:00
parent fde05adbd6
commit c0281e8b4c
2 changed files with 13 additions and 13 deletions

View File

@@ -1,4 +1,4 @@
span.machine-status { .machineStatus {
@apply flex items-center gap-1.5; @apply flex items-center gap-1.5;
.indicator { .indicator {
@@ -13,7 +13,7 @@ span.machine-status {
background-color: theme(colors.fg.semantic.error.1); background-color: theme(colors.fg.semantic.error.1);
} }
&.out-of-sync > .indicator { &.outOfSync > .indicator {
background-color: theme(colors.fg.inv.3); background-color: theme(colors.fg.inv.3);
} }
} }

View File

@@ -1,5 +1,4 @@
import "./MachineStatus.css"; import styles from "./MachineStatus.module.css";
import { Badge } from "@kobalte/core/badge"; import { Badge } from "@kobalte/core/badge";
import cx from "classnames"; import cx from "classnames";
import { Match, Show, Switch } from "solid-js"; import { Match, Show, Switch } from "solid-js";
@@ -14,8 +13,7 @@ export interface MachineStatusProps {
} }
export const MachineStatus = (props: MachineStatusProps) => { export const MachineStatus = (props: MachineStatusProps) => {
const status = () => props.status; // FIXME: this will break i18n in the future
// remove the '_' from the enum // remove the '_' from the enum
// we will use css transform in the typography component to capitalize // we will use css transform in the typography component to capitalize
const statusText = () => props.status?.replaceAll("_", " "); const statusText = () => props.status?.replaceAll("_", " ");
@@ -25,15 +23,17 @@ export const MachineStatus = (props: MachineStatusProps) => {
return ( return (
<Switch> <Switch>
<Match when={!status()}> <Match when={!props.status}>
<Loader /> <Loader />
</Match> </Match>
<Match when={status()}> <Match when={props.status}>
<Badge <Badge
class={cx("machine-status", { class={cx(styles.machineStatus, {
"not-installed": status() == "not_installed", [styles.online]: props.status == "online",
[styles.offline]: props.status == "offline",
[styles.outOfSync]: props.status == "out_of_sync",
})} })}
textValue={status()} textValue={props.status}
> >
{props.label && ( {props.label && (
<Typography <Typography
@@ -47,10 +47,10 @@ export const MachineStatus = (props: MachineStatusProps) => {
</Typography> </Typography>
)} )}
<Show <Show
when={status() != "not_installed"} when={props.status != "not_installed"}
fallback={<Icon icon="Offline" inverted={true} />} fallback={<Icon icon="Offline" inverted={true} />}
> >
<div class="indicator" /> <div class={styles.indicator} />
</Show> </Show>
</Badge> </Badge>
</Match> </Match>