Merge pull request #119 from shumaiOne/feat/ui-system-colors

feat(webui): replace hardcoded colors with system tokens
This commit is contained in:
Yiling-J
2026-06-17 15:23:46 +08:00
committed by GitHub
5 changed files with 110 additions and 114 deletions
@@ -6,11 +6,11 @@ import { Badge } from '@/ui/components/ui/badge'
import { Button } from '@/ui/components/ui/button'
import { Checkbox } from '@/ui/components/ui/checkbox'
import {
DropdownMenu,
DropdownMenuContent,
DropdownMenuItem,
DropdownMenuSeparator,
DropdownMenuTrigger,
DropdownMenu,
DropdownMenuContent,
DropdownMenuItem,
DropdownMenuSeparator,
DropdownMenuTrigger,
} from '@/ui/components/ui/dropdown-menu'
import { EditableText } from '@/ui/components/ui/editable-text'
import { Skeleton } from '@/ui/components/ui/skeleton'
@@ -23,7 +23,7 @@ import type { DragState } from '../dnd-types'
import FieldRenderer from '../field-renderer'
import { FilePreview } from './file-preview'
import { type FieldInfo as MetadataFieldInfo, FieldType } from '@shumai/dtos'
import { FieldType, type FieldInfo as MetadataFieldInfo } from '@shumai/dtos'
import { FIELD_TYPE_ICONS } from '../fields-manager'
interface FileCardProps {
@@ -1,62 +1,62 @@
import { client } from '@/ui/api/client'
import { Card, CardContent } from '@/ui/components/ui/card'
import {
AlertDialog,
AlertDialogAction,
AlertDialogCancel,
AlertDialogContent,
AlertDialogDescription,
AlertDialogFooter,
AlertDialogHeader,
AlertDialogTitle,
} from '@/ui/components/ui/alert-dialog'
import { Badge } from '@/ui/components/ui/badge'
import { Button } from '@/ui/components/ui/button'
import { Card, CardContent } from '@/ui/components/ui/card'
import {
Dialog,
DialogContent,
DialogDescription,
DialogFooter,
DialogHeader,
DialogTitle,
} from '@/ui/components/ui/dialog'
import {
DropdownMenu,
DropdownMenuContent,
DropdownMenuItem,
DropdownMenuTrigger,
} from '@/ui/components/ui/dropdown-menu'
import { Field, FieldDescription, FieldError, FieldLabel } from '@/ui/components/ui/field'
import { Input } from '@/ui/components/ui/input'
import { Label } from '@/ui/components/ui/label'
import {
Dialog,
DialogContent,
DialogDescription,
DialogFooter,
DialogHeader,
DialogTitle,
} from '@/ui/components/ui/dialog'
import { Field, FieldLabel, FieldDescription, FieldError } from '@/ui/components/ui/field'
import {
Select,
SelectContent,
SelectItem,
SelectTrigger,
SelectValue,
Select,
SelectContent,
SelectItem,
SelectTrigger,
SelectValue,
} from '@/ui/components/ui/select'
import { Switch } from '@/ui/components/ui/switch'
import { Badge } from '@/ui/components/ui/badge'
import {
AlertDialog,
AlertDialogAction,
AlertDialogCancel,
AlertDialogContent,
AlertDialogDescription,
AlertDialogFooter,
AlertDialogHeader,
AlertDialogTitle,
} from '@/ui/components/ui/alert-dialog'
import { useQuery, useMutation, useQueryClient } from '@tanstack/react-query'
import { useForm } from '@tanstack/react-form'
import {
DropdownMenu,
DropdownMenuContent,
DropdownMenuItem,
DropdownMenuTrigger,
} from '@/ui/components/ui/dropdown-menu'
import {
Loader2,
Plus,
Trash2,
Cpu,
Globe,
ChevronRight,
Info,
DollarSign,
Maximize2,
Zap,
Search,
MoreVertical,
} from 'lucide-react'
import { useState, useMemo, useEffect } from 'react'
import { toast } from 'sonner'
import { InferResponseType } from 'hono/client'
import { providerConfigSchema, providerModelSchema } from '@shumai/dtos'
import { useForm } from '@tanstack/react-form'
import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query'
import { InferResponseType } from 'hono/client'
import {
ChevronRight,
Cpu,
DollarSign,
Globe,
Info,
Loader2,
Maximize2,
MoreVertical,
Plus,
Search,
Trash2,
Zap,
} from 'lucide-react'
import { useEffect, useMemo, useState } from 'react'
import { toast } from 'sonner'
import { z } from 'zod'
const providerFormSchemaBase = z.object({
@@ -379,7 +379,7 @@ export function ProvidersSettings({ teamId }: ProvidersSettingsProps) {
<AlertDialogFooter>
<AlertDialogCancel onClick={() => setProviderToDelete(null)}>Cancel</AlertDialogCancel>
<AlertDialogAction
className="bg-destructive hover:bg-destructive/90 text-white"
className="bg-destructive hover:bg-destructive/90 text-destructive-foreground"
onClick={() => {
if (providerToDelete) {
deleteMutation.mutate(providerToDelete.id)
@@ -507,7 +507,7 @@ function ProviderFormDialog({
>
<div className="flex-1 overflow-y-auto p-6 pt-2 space-y-8">
{/* Row 1: Basic Config */}
<div className="grid grid-cols-1 md:grid-cols-2 gap-6 p-6 bg-slate-50 dark:bg-slate-900 rounded-2xl border border-slate-200 dark:border-slate-800">
<div className="grid grid-cols-1 md:grid-cols-2 gap-6 p-6 rounded-2xl border">
<form.Field
name="name"
children={(field) => {
@@ -586,8 +586,8 @@ function ProviderFormDialog({
</div>
{/* Row 2: API Key Card */}
<Card className="bg-slate-50 dark:bg-slate-900 rounded-2xl border border-slate-200 dark:border-slate-800">
<CardContent className="p-6">
<Card className="rounded-2xl border bg-transparent">
<CardContent className="p-6 pt-2">
<form.Field
name="config.apiKey"
children={(field) => {
@@ -609,13 +609,9 @@ function ProviderFormDialog({
/>
<FieldDescription className="text-xs mt-2">
You can provide a literal value (e.g.{' '}
<code className="bg-slate-200 dark:bg-slate-800 px-1 rounded text-blue-600 dark:text-blue-400">
sk-...
</code>
) or an Environment variable name (e.g.{' '}
<code className="bg-slate-200 dark:bg-slate-800 px-1 rounded text-blue-600 dark:text-blue-400">
MY_API_KEY
</code>
<code className="bg-muted px-1 rounded text-primary">sk-...</code>) or an
Environment variable name (e.g.{' '}
<code className="bg-muted px-1 rounded text-primary">MY_API_KEY</code>
).
</FieldDescription>
{isInvalid && <FieldError errors={mapErrors(field.state.meta.errors)} />}
@@ -664,7 +660,7 @@ function ProviderFormDialog({
{modelsField.state.value.map((_, index) => (
<div
key={index}
className="group relative p-6 bg-white dark:bg-slate-950 rounded-2xl border border-slate-200 dark:border-slate-800 shadow-sm animate-in fade-in zoom-in-95 duration-300"
className="group relative p-6 bg-transparent rounded-2xl border shadow-sm animate-in fade-in zoom-in-95 duration-300"
>
{/* Row 1: ID and Name */}
<div className="grid grid-cols-1 md:grid-cols-2 gap-6">
@@ -728,7 +724,7 @@ function ProviderFormDialog({
children={(field) => (
<Field
orientation="horizontal"
className="rounded-lg border p-3 shadow-sm bg-slate-50 dark:bg-slate-900 justify-between"
className="rounded-lg border border-border p-3 shadow-sm bg-muted/50 justify-between"
>
<FieldLabel htmlFor={field.name}>Reasoning Support</FieldLabel>
<Switch
@@ -875,7 +871,7 @@ function ProviderFormDialog({
type="button"
variant="ghost"
size="icon"
className="absolute -top-2 -right-2 h-8 w-8 rounded-full bg-white dark:bg-slate-900 border border-slate-200 dark:border-slate-800 text-slate-400 hover:text-red-600 transition-colors shadow-sm"
className="absolute -top-2 -right-2 h-8 w-8 rounded-full bg-background border border-border text-muted-foreground hover:text-destructive transition-colors shadow-sm"
onClick={() => modelsField.removeValue(index)}
>
<Trash2 className="h-4 w-4" />
@@ -890,7 +886,7 @@ function ProviderFormDialog({
</div>
</div>
<DialogFooter className="p-6 pt-4 border-t dark:border-slate-800 gap-2">
<DialogFooter className="p-6 pt-4 border-t border-border gap-2">
<Button type="button" variant="outline" onClick={onClose} disabled={isLoading}>
Cancel
</Button>
@@ -899,7 +895,7 @@ function ProviderFormDialog({
children={([canSubmit, isSubmitting]) => (
<Button
type="submit"
className="bg-blue-600 hover:bg-blue-700 text-white min-w-[120px]"
className="min-w-[120px]"
disabled={!canSubmit || isSubmitting || isLoading}
>
{isSubmitting || isLoading ? (
@@ -926,7 +922,7 @@ function ProviderFormDialog({
<AlertDialogFooter>
<AlertDialogCancel>Cancel</AlertDialogCancel>
<AlertDialogAction
className="bg-red-600 hover:bg-red-700 text-white"
className="bg-destructive hover:bg-destructive/90 text-destructive-foreground"
onClick={() => {
onDelete?.()
setIsDeleteDialogOpen(false)
@@ -83,7 +83,7 @@ export function SandboxSettings({ teamId }: { teamId: string }) {
<Card>
<CardHeader>
<div className="flex items-center gap-2">
<Globe className="w-5 h-5 text-blue-500" />
<Globe className="w-5 h-5 text-primary" />
<CardTitle>Network Sandbox</CardTitle>
</div>
<CardDescription>
@@ -110,17 +110,17 @@ export function SandboxSettings({ teamId }: { teamId: string }) {
</form>
<div className="space-y-2">
<h4 className="text-sm font-medium text-slate-500 mb-3">Allowed Domains</h4>
<h4 className="text-sm font-medium text-muted-foreground mb-3">Allowed Domains</h4>
<div className="flex flex-wrap gap-2">
{sandbox?.allowedDomains.map((domain) => (
<div
key={domain}
className="flex items-center gap-1 px-3 py-1.5 bg-slate-100 dark:bg-slate-800 rounded-full text-sm border border-slate-200 dark:border-slate-700 transition-all hover:border-slate-300 dark:hover:border-slate-600"
className="flex items-center gap-1 px-3 py-1.5 bg-muted rounded-full text-sm border border-border transition-all hover:border-muted-foreground/50"
>
<span className="font-medium text-slate-700 dark:text-slate-300">{domain}</span>
<span className="font-medium text-foreground">{domain}</span>
<button
onClick={() => handleRemoveDomain(domain)}
className="ml-1 text-slate-400 hover:text-red-500 transition-colors"
className="ml-1 text-muted-foreground hover:text-destructive transition-colors"
disabled={isUpdating}
>
<X className="w-3.5 h-3.5" />
@@ -128,7 +128,7 @@ export function SandboxSettings({ teamId }: { teamId: string }) {
</div>
))}
{sandbox?.allowedDomains.length === 0 && (
<div className="text-sm text-slate-400 italic">No custom domains allowed</div>
<div className="text-sm text-muted-foreground italic">No custom domains allowed</div>
)}
</div>
</div>
@@ -136,10 +136,10 @@ export function SandboxSettings({ teamId }: { teamId: string }) {
</Card>
{/* Pending Domains Section */}
<Card className="border-amber-200 dark:border-amber-900 bg-amber-50/10 dark:bg-amber-950/5">
<Card className="border-orange-500/20 bg-orange-500/5">
<CardHeader>
<div className="flex items-center gap-2">
<ShieldAlert className="w-5 h-5 text-amber-500" />
<ShieldAlert className="w-5 h-5 text-orange-500" />
<CardTitle>Pending Domain Approvals</CardTitle>
</div>
<CardDescription>
@@ -150,20 +150,20 @@ export function SandboxSettings({ teamId }: { teamId: string }) {
<CardContent>
<div className="space-y-3">
{sandbox?.pendingDomains && sandbox.pendingDomains.length > 0 ? (
<div className="divide-y divide-slate-100 dark:divide-slate-800">
<div className="divide-y divide-border">
{sandbox.pendingDomains.map((domain) => (
<div
key={domain}
className="flex items-center justify-between py-2.5 first:pt-0 last:pb-0"
>
<span className="font-mono text-sm text-slate-700 dark:text-slate-300 bg-slate-100 dark:bg-slate-800 px-2 py-1 rounded break-all">
<span className="font-mono text-sm text-foreground bg-muted px-2 py-1 rounded break-all">
{domain}
</span>
<div className="flex items-center gap-2">
<Button
size="sm"
variant="outline"
className="h-8 border-emerald-200 text-emerald-600 hover:bg-emerald-50 hover:text-emerald-700 dark:border-emerald-900 dark:text-emerald-400 dark:hover:bg-emerald-950/20"
className="h-8 border-emerald-500/20 text-emerald-600 hover:bg-emerald-500/10 hover:text-emerald-600 dark:text-emerald-400 dark:hover:bg-emerald-500/20"
onClick={() => handleApproveDomain(domain)}
disabled={isUpdating}
>
@@ -173,7 +173,7 @@ export function SandboxSettings({ teamId }: { teamId: string }) {
<Button
size="sm"
variant="outline"
className="h-8 border-red-200 text-red-600 hover:bg-red-50 hover:text-red-700 dark:border-red-900 dark:text-red-400 dark:hover:bg-red-950/20"
className="h-8 border-destructive/20 text-destructive hover:bg-destructive/10"
onClick={() => handleDeletePendingDomain(domain)}
disabled={isUpdating}
>
@@ -185,7 +185,7 @@ export function SandboxSettings({ teamId }: { teamId: string }) {
))}
</div>
) : (
<div className="text-sm text-slate-400 italic py-2">
<div className="text-sm text-muted-foreground italic py-2">
No pending domains requiring approval
</div>
)}
@@ -172,7 +172,7 @@ export const SkillsConfigCard: React.FC<SkillsConfigCardProps> = ({ teamId }) =>
<AlertDialogFooter>
<AlertDialogCancel>Cancel</AlertDialogCancel>
<AlertDialogAction
className="bg-destructive hover:bg-destructive/90 text-white"
className="bg-destructive hover:bg-destructive/90 text-destructive-foreground"
onClick={() => {
if (selectedSkill) {
deleteMutation.mutate(selectedSkill.id)
@@ -222,7 +222,7 @@ const SkillItem = ({
e.stopPropagation()
onDelete()
}}
className="text-red-500 focus:text-red-500 gap-2 cursor-pointer"
className="text-destructive focus:text-destructive gap-2 cursor-pointer"
>
<Trash2 className="w-4 h-4" /> Delete
</DropdownMenuItem>
@@ -382,8 +382,8 @@ const AddSkillDialog = ({
className={cn(
'group relative h-32 border-2 border-dashed rounded-xl flex flex-col items-center justify-center transition-all cursor-pointer',
isProcessing
? 'opacity-50 cursor-not-allowed bg-slate-50 dark:bg-slate-900 border-slate-200 dark:border-slate-800'
: 'hover:bg-blue-50/50 dark:hover:bg-blue-900/10 hover:border-blue-500/50 border-slate-200 dark:border-slate-800',
? 'opacity-50 cursor-not-allowed bg-muted/50 border-border'
: 'hover:bg-primary/5 hover:border-primary/50 border-border',
)}
>
<input
@@ -393,20 +393,20 @@ const AddSkillDialog = ({
accept=".zip"
onChange={(e) => handleFileUpload(e.target.files)}
/>
<div className="p-3 bg-slate-100 dark:bg-slate-800 rounded-full group-hover:bg-blue-100 dark:group-hover:bg-blue-900/30 transition-colors">
<Upload className="w-6 h-6 text-slate-400 group-hover:text-blue-500" />
<div className="p-3 bg-muted rounded-full group-hover:bg-primary/10 transition-colors">
<Upload className="w-6 h-6 text-muted-foreground group-hover:text-primary" />
</div>
<div className="mt-3 text-center">
<p className="text-sm font-medium text-slate-700 dark:text-slate-300">
<p className="text-sm font-medium text-foreground">
Select ZIP file
</p>
<p className="text-[10px] text-slate-500 dark:text-slate-400 mt-1 uppercase tracking-wider font-semibold">
<p className="text-[10px] text-muted-foreground mt-1 uppercase tracking-wider font-semibold">
Packages must contain a SKILL.md
</p>
</div>
</div>
{isProcessing && !githubUrl && (
<div className="flex items-center gap-2 text-sm text-blue-600 dark:text-blue-400 justify-center bg-blue-50 dark:bg-blue-900/10 py-2 rounded-lg animate-pulse">
<div className="flex items-center gap-2 text-sm text-primary justify-center bg-primary/10 py-2 rounded-lg animate-pulse">
<Loader2 className="w-4 h-4 animate-spin" />
Processing package...
</div>
@@ -415,10 +415,10 @@ const AddSkillDialog = ({
<div className="relative">
<div className="absolute inset-0 flex items-center">
<span className="w-full border-t border-slate-200 dark:border-slate-800" />
<span className="w-full border-t border-border" />
</div>
<div className="relative flex justify-center text-xs uppercase">
<span className="bg-white dark:bg-slate-950 px-2 text-slate-500 font-bold">OR</span>
<span className="bg-background px-2 text-muted-foreground font-bold">OR</span>
</div>
</div>
@@ -428,7 +428,7 @@ const AddSkillDialog = ({
<Label htmlFor="githubUrl">GitHub Repository URL</Label>
<div className="flex gap-2">
<div className="relative flex-1">
<Github className="absolute left-3 top-2.5 w-4 h-4 text-slate-400" />
<Github className="absolute left-3 top-2.5 w-4 h-4 text-muted-foreground" />
<Input
id="githubUrl"
placeholder="https://github.com/owner/repo"
@@ -450,7 +450,7 @@ const AddSkillDialog = ({
)}
</Button>
</div>
<p className="text-[10px] text-slate-500 dark:text-slate-400 italic">
<p className="text-[10px] text-muted-foreground italic">
Example: https://github.com/google/gemini-cli
</p>
</div>
@@ -540,7 +540,7 @@ const ConfigSkillDialog = ({
<DialogHeader>
<div className="flex items-center justify-between">
<DialogTitle className="flex items-center gap-2">
<Code className="w-5 h-5 text-blue-500" />
<Code className="w-5 h-5 text-primary" />
Configure Skill: {skill.name}
</DialogTitle>
</div>
@@ -551,8 +551,8 @@ const ConfigSkillDialog = ({
<div className="py-4 space-y-4 max-h-[60vh] overflow-y-auto pr-2 custom-scrollbar">
{envVars.length === 0 ? (
<div className="text-center py-10 bg-slate-50 dark:bg-slate-900 rounded-xl border border-dashed border-slate-200 dark:border-slate-800">
<p className="text-slate-500 dark:text-slate-400 text-sm italic">
<div className="text-center py-10 bg-muted/50 rounded-xl border border-dashed border-border">
<p className="text-muted-foreground text-sm italic">
No environment variables found. Click "Add Variable" to create one.
</p>
</div>
@@ -560,38 +560,38 @@ const ConfigSkillDialog = ({
envVars.map((env: { name: string; default?: string | undefined }, index: number) => (
<div
key={index}
className="p-4 bg-slate-100/50 dark:bg-slate-800/50 rounded-xl border border-slate-200 dark:border-slate-700 space-y-3 relative group"
className="p-4 bg-muted/50 rounded-xl border border-border space-y-3 relative group"
>
<button
onClick={() => removeEnvVar(index)}
className="absolute top-2 right-2 p-1 text-slate-400 hover:text-red-500 hover:bg-red-50 dark:hover:bg-red-900/20 rounded-md transition-colors opacity-0 group-hover:opacity-100"
className="absolute top-2 right-2 p-1 text-muted-foreground hover:text-destructive hover:bg-destructive/10 rounded-md transition-colors opacity-0 group-hover:opacity-100"
>
<X className="w-4 h-4" />
</button>
<div className="space-y-1.5">
<Label className="text-[10px] uppercase tracking-wider font-bold text-slate-400">
<Label className="text-[10px] uppercase tracking-wider font-bold text-muted-foreground">
Variable Name
</Label>
<Input
value={env.name}
onChange={(e) => handleEnvVarNameChange(index, e.target.value)}
placeholder="e.app. API_KEY"
className="h-8 bg-white dark:bg-slate-950 border-slate-200 dark:border-slate-800 text-sm font-mono"
className="h-8 bg-background border-border text-sm font-mono"
/>
</div>
<div className="space-y-1.5">
<Label className="text-[10px] uppercase tracking-wider font-bold text-slate-400">
<Label className="text-[10px] uppercase tracking-wider font-bold text-muted-foreground">
Default Value
</Label>
<Input
value={env.default || ''}
onChange={(e) => handleEnvVarValueChange(index, e.target.value)}
placeholder="Optional default value..."
className="h-8 bg-white dark:bg-slate-950 border-slate-200 dark:border-slate-800 text-sm"
className="h-8 bg-background border-border text-sm"
/>
<p className="text-[10px] text-slate-500 italic">
<p className="text-[10px] text-muted-foreground italic">
If left empty, the value will be read from the host machine's environment.
</p>
</div>
@@ -600,12 +600,12 @@ const ConfigSkillDialog = ({
)}
</div>
<DialogFooter className="flex items-center justify-between sm:justify-between w-full pt-2 border-t border-slate-100 dark:border-slate-800">
<DialogFooter className="flex items-center justify-between sm:justify-between w-full pt-2 border-t border-border">
<Button
variant="ghost"
size="sm"
onClick={addEnvVar}
className="h-8 gap-1.5 text-blue-600 hover:text-blue-700 hover:bg-blue-50 dark:text-blue-400 dark:hover:bg-blue-900/20"
className="h-8 gap-1.5 text-primary hover:text-primary hover:bg-primary/10"
>
<Plus className="w-3.5 h-3.5" /> Add Variable
</Button>
@@ -616,7 +616,7 @@ const ConfigSkillDialog = ({
<Button
onClick={handleSave}
disabled={isSaving}
className="px-8 bg-blue-600 hover:bg-blue-700 text-white"
className="px-8"
>
{isSaving ? <Loader2 className="w-4 h-4 animate-spin mr-2" /> : null}
Save Changes
@@ -159,7 +159,7 @@ export const SpriteScrubber: React.FC<SpriteScrubberProps> = ({
return (
<div
ref={containerRef}
className={`relative w-full h-full overflow-hidden cursor-crosshair group bg-gray-900 select-none ${className}`}
className={`relative w-full h-full overflow-hidden cursor-crosshair group bg-black select-none ${className}`}
onMouseEnter={handleMouseEnter}
onMouseLeave={handleMouseLeave}
onMouseMove={handleMouseMove}