feat(ui): implement pills-style AppSwitcher with consistent button widths
Replace segmented control with pills-style switcher for better visual consistency.
This commit is contained in:
36
src/App.tsx
36
src/App.tsx
@@ -5,6 +5,7 @@ import ProviderList from "./components/ProviderList";
|
|||||||
import AddProviderModal from "./components/AddProviderModal";
|
import AddProviderModal from "./components/AddProviderModal";
|
||||||
import EditProviderModal from "./components/EditProviderModal";
|
import EditProviderModal from "./components/EditProviderModal";
|
||||||
import { ConfirmDialog } from "./components/ConfirmDialog";
|
import { ConfirmDialog } from "./components/ConfirmDialog";
|
||||||
|
import { AppSwitcher } from "./components/AppSwitcher";
|
||||||
import "./App.css";
|
import "./App.css";
|
||||||
|
|
||||||
function App() {
|
function App() {
|
||||||
@@ -182,39 +183,10 @@ function App() {
|
|||||||
<header className="app-header">
|
<header className="app-header">
|
||||||
<h1>{activeApp === "claude" ? "Claude Code" : "Codex"} 供应商切换器</h1>
|
<h1>{activeApp === "claude" ? "Claude Code" : "Codex"} 供应商切换器</h1>
|
||||||
<div className="app-tabs">
|
<div className="app-tabs">
|
||||||
<div className="segmented" role="tablist" aria-label="选择应用">
|
<AppSwitcher
|
||||||
<span
|
activeApp={activeApp}
|
||||||
className="segmented-thumb"
|
onSwitch={setActiveApp}
|
||||||
style={{
|
|
||||||
transform:
|
|
||||||
activeApp === "claude"
|
|
||||||
? "translateX(0%)"
|
|
||||||
: "translateX(100%)",
|
|
||||||
}}
|
|
||||||
/>
|
/>
|
||||||
<button
|
|
||||||
type="button"
|
|
||||||
role="tab"
|
|
||||||
aria-selected={activeApp === "claude"}
|
|
||||||
className={`segmented-item ${
|
|
||||||
activeApp === "claude" ? "active" : ""
|
|
||||||
}`}
|
|
||||||
onClick={() => setActiveApp("claude")}
|
|
||||||
>
|
|
||||||
Claude Code
|
|
||||||
</button>
|
|
||||||
<button
|
|
||||||
type="button"
|
|
||||||
role="tab"
|
|
||||||
aria-selected={activeApp === "codex"}
|
|
||||||
className={`segmented-item ${
|
|
||||||
activeApp === "codex" ? "active" : ""
|
|
||||||
}`}
|
|
||||||
onClick={() => setActiveApp("codex")}
|
|
||||||
>
|
|
||||||
Codex
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
<div className="header-actions">
|
<div className="header-actions">
|
||||||
<button className="add-btn" onClick={() => setIsAddModalOpen(true)}>
|
<button className="add-btn" onClick={() => setIsAddModalOpen(true)}>
|
||||||
|
|||||||
66
src/components/AppSwitcher.css
Normal file
66
src/components/AppSwitcher.css
Normal file
@@ -0,0 +1,66 @@
|
|||||||
|
/* 药丸式切换按钮 */
|
||||||
|
.switcher-pills {
|
||||||
|
display: inline-flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 12px;
|
||||||
|
background: rgba(255, 255, 255, 0.08);
|
||||||
|
padding: 6px 8px;
|
||||||
|
border-radius: 50px;
|
||||||
|
backdrop-filter: blur(10px);
|
||||||
|
}
|
||||||
|
|
||||||
|
.switcher-pill {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
gap: 8px;
|
||||||
|
padding: 8px 16px;
|
||||||
|
background: transparent;
|
||||||
|
border: none;
|
||||||
|
border-radius: 50px;
|
||||||
|
color: rgba(255, 255, 255, 0.6);
|
||||||
|
font-size: 14px;
|
||||||
|
font-weight: 600;
|
||||||
|
cursor: pointer;
|
||||||
|
transition: all 200ms ease;
|
||||||
|
min-width: 120px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.switcher-pill:hover:not(.active) {
|
||||||
|
color: rgba(255, 255, 255, 0.8);
|
||||||
|
background: rgba(255, 255, 255, 0.05);
|
||||||
|
}
|
||||||
|
|
||||||
|
.switcher-pill.active {
|
||||||
|
background: rgba(255, 255, 255, 0.15);
|
||||||
|
color: white;
|
||||||
|
box-shadow:
|
||||||
|
inset 0 1px 3px rgba(0, 0, 0, 0.1),
|
||||||
|
0 1px 0 rgba(255, 255, 255, 0.1);
|
||||||
|
}
|
||||||
|
|
||||||
|
.pill-dot {
|
||||||
|
width: 8px;
|
||||||
|
height: 8px;
|
||||||
|
border-radius: 50%;
|
||||||
|
background: currentColor;
|
||||||
|
opacity: 0.4;
|
||||||
|
transition: all 200ms ease;
|
||||||
|
}
|
||||||
|
|
||||||
|
.switcher-pill.active .pill-dot {
|
||||||
|
opacity: 1;
|
||||||
|
box-shadow: 0 0 8px currentColor;
|
||||||
|
animation: pulse 2s infinite;
|
||||||
|
}
|
||||||
|
|
||||||
|
.pills-divider {
|
||||||
|
width: 1px;
|
||||||
|
height: 20px;
|
||||||
|
background: rgba(255, 255, 255, 0.2);
|
||||||
|
}
|
||||||
|
|
||||||
|
@keyframes pulse {
|
||||||
|
0%, 100% { transform: scale(1); opacity: 1; }
|
||||||
|
50% { transform: scale(1.2); opacity: 0.8; }
|
||||||
|
}
|
||||||
36
src/components/AppSwitcher.tsx
Normal file
36
src/components/AppSwitcher.tsx
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
import { AppType } from "../lib/tauri-api";
|
||||||
|
import "./AppSwitcher.css";
|
||||||
|
|
||||||
|
interface AppSwitcherProps {
|
||||||
|
activeApp: AppType;
|
||||||
|
onSwitch: (app: AppType) => void;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function AppSwitcher({ activeApp, onSwitch }: AppSwitcherProps) {
|
||||||
|
const handleSwitch = (app: AppType) => {
|
||||||
|
if (app === activeApp) return;
|
||||||
|
onSwitch(app);
|
||||||
|
};
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className="switcher-pills">
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
className={`switcher-pill ${activeApp === "claude" ? "active" : ""}`}
|
||||||
|
onClick={() => handleSwitch("claude")}
|
||||||
|
>
|
||||||
|
<span className="pill-dot" />
|
||||||
|
<span>Claude Code</span>
|
||||||
|
</button>
|
||||||
|
<div className="pills-divider" />
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
className={`switcher-pill ${activeApp === "codex" ? "active" : ""}`}
|
||||||
|
onClick={() => handleSwitch("codex")}
|
||||||
|
>
|
||||||
|
<span className="pill-dot" />
|
||||||
|
<span>Codex</span>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user