Crew profile
Edit a crew member’s name and shift availability, then save the changes to their ID.
Installation
Use a React 19 project with shadcn configured. Render the installed components inside the Cyber root, and import your global stylesheet in the app entry point.
bunx --bun shadcn@latest add https://www.cyberspec.dev/r/profile-editor.json
Usage
import { Cyber } from "@/components/ui/cyber"
import Recipe from "@/components/recipes/profile-editor"
export default function App() {
return (
<Cyber>
<Recipe />
</Cyber>
)
}
Source
"use client"
import "./recipe-layout.css"
import { useState } from "react"
import { Avatar } from "@/components/ui/avatar"
import { Button } from "@/components/ui/button"
import { Switch } from "@/components/ui/switch"
import { TextField } from "@/components/ui/text-field"
export default function ProfileEditor() {
const [saved, setSaved] = useState({ name: "Mara Voss", available: true })
const [name, setName] = useState(saved.name)
const [available, setAvailable] = useState(saved.available)
const [message, setMessage] = useState("")
const dirty = name.trim() !== saved.name || available !== saved.available
return (
<form className="sink-stack" onSubmit={(event) => {
event.preventDefault()
if (!dirty || !name.trim()) return
setSaved({ name: name.trim(), available })
setName(name.trim())
setMessage("Profile updated.")
}}>
<div className="sink-row">
<Avatar name={saved.name} size="lg" decorative shape="hex" />
<div style={{ minWidth: 0 }}>
<strong style={{ overflowWrap: "anywhere" }}>{saved.name}</strong>
<div className="sink-note">{saved.available ? "Available for a shift" : "Off duty"}</div>
</div>
</div>
<TextField label="Display name" value={name} maxLength={32} required onValueChange={(next) => {
setName(next)
setMessage("")
}} />
<Switch label="Available for a shift" checked={available} onCheckedChange={(next) => {
setAvailable(next)
setMessage("")
}} />
<div className="sink-row">
<Button type="submit" size="sm" disabled={!dirty || !name.trim()}>Save profile</Button>
<span className="sink-note" role="status">{dirty ? "Unsaved changes" : message}</span>
</div>
</form>
)
}
Components in this recipe
- Avatar — A portrait in a cut frame, with initials over a generated scanline field when there's no image.
- Text field — A labelled text input in a cut frame, with a hint, an error and an optional icon.
- Switch — A block that slides across a cut track and lights, with its state printed beside it.