MCPcopy Create free account
hub / github.com/UsefulSoftwareCo/executor / ModeSwitch

Function ModeSwitch

packages/onboarding-demo/src/app.tsx:150–173  ·  view source on GitHub ↗
(props: { readonly mode: Mode; readonly onChange: (mode: Mode) => void })

Source from the content-addressed store, hash-verified

148type Mode = "current" | "next";
149
150function ModeSwitch(props: { readonly mode: Mode; readonly onChange: (mode: Mode) => void }) {
151 const option = (mode: Mode, label: string) => (
152 // oxlint-disable-next-line react/forbid-elements
153 <button
154 key={mode}
155 type="button"
156 onClick={() => props.onChange(mode)}
157 className={cn(
158 "rounded-full px-2.5 py-1 text-xs font-medium transition-colors",
159 props.mode === mode
160 ? "bg-foreground text-background"
161 : "text-muted-foreground hover:text-foreground",
162 )}
163 >
164 {label}
165 </button>
166 );
167 return (
168 <div className="fixed bottom-4 right-4 z-50 flex items-center gap-0.5 rounded-full border border-border bg-card/95 p-1 shadow-lg backdrop-blur-sm">
169 {option("current", "Current")}
170 {option("next", "Reworked")}
171 </div>
172 );
173}
174
175const modeFromHash = (): Mode => {
176 const hash = globalThis.location?.hash ?? "";

Callers

nothing calls this directly

Calls 1

optionFunction · 0.85

Tested by

no test coverage detected