({
types,
onAdd,
}: {
types: GuardType[]
onAdd: (type: string) => void
})
| 192 | // ==================== Add Guard Button ==================== |
| 193 | |
| 194 | function AddGuardButton({ |
| 195 | types, |
| 196 | onAdd, |
| 197 | }: { |
| 198 | types: GuardType[] |
| 199 | onAdd: (type: string) => void |
| 200 | }) { |
| 201 | const [open, setOpen] = useState(false) |
| 202 | |
| 203 | if (!open) { |
| 204 | return ( |
| 205 | <button |
| 206 | onClick={() => setOpen(true)} |
| 207 | className="border border-dashed border-border rounded-lg px-3 py-2 text-[12px] text-text-muted hover:text-text hover:border-text-muted transition-colors w-full text-left" |
| 208 | > |
| 209 | + Add Guard |
| 210 | </button> |
| 211 | ) |
| 212 | } |
| 213 | |
| 214 | return ( |
| 215 | <div className="border border-border rounded-lg bg-bg-secondary p-3 space-y-1.5"> |
| 216 | <p className="text-[11px] text-text-muted mb-1.5">Select a guard type:</p> |
| 217 | {types.map(({ type, label, desc }) => ( |
| 218 | <button |
| 219 | key={type} |
| 220 | onClick={() => { onAdd(type); setOpen(false) }} |
| 221 | className="block w-full text-left px-2.5 py-2 rounded-md hover:bg-bg-tertiary transition-colors" |
| 222 | > |
| 223 | <span className="text-[13px] text-text font-medium">{label}</span> |
| 224 | <span className="block text-[11px] text-text-muted/60">{desc}</span> |
| 225 | </button> |
| 226 | ))} |
| 227 | <button onClick={() => setOpen(false)} className="text-[11px] text-text-muted hover:text-text mt-1"> |
| 228 | Cancel |
| 229 | </button> |
| 230 | </div> |
| 231 | ) |
| 232 | } |
| 233 | |
| 234 | // ==================== Guard Option Editors ==================== |
| 235 |
nothing calls this directly
no outgoing calls
no test coverage detected