refactor: standardize status badges and fix composer whitespace handling

This commit is contained in:
Mohamed Boudra
2026-08-16 19:14:04 +02:00
parent 3136117906
commit 90c97c1b1a
16 changed files with 457 additions and 163 deletions
+13 -39
View File
@@ -26,6 +26,7 @@ import { AdaptiveModalSheet, type SheetHeader } from "@/components/adaptive-moda
import { SettingsTextAreaCard } from "@/components/settings-textarea";
import { Alert as InlineAlert } from "@/components/ui/alert";
import { Button } from "@/components/ui/button";
import { StatusBadge, type StatusBadgeVariant } from "@/components/ui/status-badge";
import { Switch } from "@/components/ui/switch";
import {
ProfileDraft,
@@ -170,45 +171,30 @@ function HostStatusBadges({ serverId }: { serverId: string }) {
const activeConnection = snapshot?.activeConnection ?? null;
const statusLabel = formatConnectionStatus(connectionStatus);
const statusTone = getConnectionStatusTone(connectionStatus);
let statusColor: string;
let statusVariant: StatusBadgeVariant = "muted";
let statusDotColor = theme.colors.foregroundMuted;
if (statusTone === "success") {
statusColor = theme.colors.palette.green[400];
statusVariant = "success";
statusDotColor = theme.colors.statusDotSuccess;
} else if (statusTone === "warning") {
statusColor = theme.colors.palette.amber[500];
statusVariant = "warning";
statusDotColor = theme.colors.statusDotWarning;
} else if (statusTone === "error") {
statusColor = theme.colors.destructive;
} else {
statusColor = theme.colors.foregroundMuted;
}
let statusPillBg: string;
if (statusTone === "success") {
statusPillBg = "rgba(74, 222, 128, 0.1)";
} else if (statusTone === "warning") {
statusPillBg = "rgba(245, 158, 11, 0.1)";
} else if (statusTone === "error") {
statusPillBg = "rgba(248, 113, 113, 0.1)";
} else {
statusPillBg = "rgba(161, 161, 170, 0.1)";
statusVariant = "error";
statusDotColor = theme.colors.statusDotDanger;
}
const connectionBadge = formatActiveConnectionBadge(activeConnection, theme, t);
const versionBadgeText = formatDaemonVersionBadge(daemonVersion);
const statusPillStyle = useMemo(
() => [styles.statusPill, { backgroundColor: statusPillBg }],
[statusPillBg],
);
const statusDotStyle = useMemo(
() => [styles.statusDot, { backgroundColor: statusColor }],
[statusColor],
() => [styles.statusDot, { backgroundColor: statusDotColor }],
[statusDotColor],
);
const statusTextStyle = useMemo(() => [styles.statusText, { color: statusColor }], [statusColor]);
const statusLeading = useMemo(() => <View style={statusDotStyle} />, [statusDotStyle]);
return (
<View style={styles.identityBadges} testID="host-page-identity">
<View style={statusPillStyle}>
<View style={statusDotStyle} />
<Text style={statusTextStyle}>{statusLabel}</Text>
</View>
<StatusBadge label={statusLabel} variant={statusVariant} leading={statusLeading} />
{connectionBadge ? (
<View style={styles.badgePill}>
{connectionBadge.icon}
@@ -1836,23 +1822,11 @@ const styles = StyleSheet.create((theme) => ({
flexWrap: "wrap",
marginBottom: theme.spacing[6],
},
statusPill: {
flexDirection: "row",
alignItems: "center",
gap: 6,
paddingHorizontal: theme.spacing[2],
paddingVertical: 4,
borderRadius: theme.borderRadius.full,
},
statusDot: {
width: 6,
height: 6,
borderRadius: theme.borderRadius.full,
},
statusText: {
fontSize: theme.fontSize.xs,
fontWeight: theme.fontWeight.normal,
},
badgePill: {
flexDirection: "row",
alignItems: "center",