Skip to content

Commit 0dc23cd

Browse files
danbimclaude
andcommitted
feat: move save button to sticky top bar on job form pages
Add a sticky header to JobForm with the title, Cancel, Save, and any extra actions (Notes/Delete on the edit page). Remove the bottom button bar and the separate h1 from both new and edit pages. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent 9dbd4e6 commit 0dc23cd

3 files changed

Lines changed: 43 additions & 26 deletions

File tree

app/components/job-form.tsx

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import type { JobOpening } from '~/db/schema'
1919
type JobFormProps = {
2020
job?: JobOpening
2121
errors?: Record<string, string>
22+
headerActions?: React.ReactNode
2223
}
2324

2425
const CURRENCIES = ['EUR', 'USD', 'GBP', 'CHF']
@@ -59,7 +60,7 @@ const RATING_CRITERIA = [
5960
{ name: 'ratingJobSecurity', label: 'Job Security' },
6061
]
6162

62-
export function JobForm({ job, errors }: JobFormProps) {
63+
export function JobForm({ job, errors, headerActions }: JobFormProps) {
6364
const [description, setDescription] = useState(job?.description ?? '')
6465
const [showPreview, setShowPreview] = useState(false)
6566

@@ -88,6 +89,27 @@ export function JobForm({ job, errors }: JobFormProps) {
8889

8990
return (
9091
<Form method="post" className="space-y-6">
92+
<div className="sticky top-0 z-10 bg-background border-b py-3 -mx-4 px-4">
93+
<div className="flex items-center justify-between">
94+
<h1 className="text-3xl font-bold">
95+
{job ? 'Edit Job Opening' : 'Add Job Opening'}
96+
</h1>
97+
<div className="flex gap-2">
98+
<Button
99+
type="button"
100+
variant="outline"
101+
onClick={() => history.back()}
102+
>
103+
Cancel
104+
</Button>
105+
{headerActions}
106+
<Button type="submit">
107+
{job ? 'Update' : 'Create'} Job Opening
108+
</Button>
109+
</div>
110+
</div>
111+
</div>
112+
91113
<Card>
92114
<CardHeader>
93115
<CardTitle>Basic Information</CardTitle>
@@ -381,12 +403,6 @@ export function JobForm({ job, errors }: JobFormProps) {
381403
</CardContent>
382404
</Card>
383405

384-
<div className="flex gap-4">
385-
<Button type="submit">{job ? 'Update' : 'Create'} Job Opening</Button>
386-
<Button type="button" variant="outline" onClick={() => history.back()}>
387-
Cancel
388-
</Button>
389-
</div>
390406
</Form>
391407
)
392408
}

app/routes/jobs.$id.edit.tsx

Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -101,25 +101,27 @@ export default function EditJob() {
101101

102102
return (
103103
<div className="container mx-auto py-8 max-w-3xl">
104-
<div className="flex justify-between items-center mb-6">
105-
<h1 className="text-3xl font-bold">Edit Job Opening</h1>
106-
<div className="flex gap-2">
107-
<Button
108-
type="button"
109-
variant="outline"
110-
onClick={() => setNotesPanelOpen(true)}
111-
>
112-
Notes ({noteCount})
113-
</Button>
114-
<Form method="post">
115-
<input type="hidden" name="intent" value="delete" />
116-
<Button type="submit" variant="destructive">
117-
Delete
104+
<JobForm
105+
job={job}
106+
errors={actionData?.errors}
107+
headerActions={
108+
<>
109+
<Button
110+
type="button"
111+
variant="outline"
112+
onClick={() => setNotesPanelOpen(true)}
113+
>
114+
Notes ({noteCount})
118115
</Button>
119-
</Form>
120-
</div>
121-
</div>
122-
<JobForm job={job} errors={actionData?.errors} />
116+
<Form method="post">
117+
<input type="hidden" name="intent" value="delete" />
118+
<Button type="submit" variant="destructive">
119+
Delete
120+
</Button>
121+
</Form>
122+
</>
123+
}
124+
/>
123125

124126
<NotesPanel
125127
jobId={job.id}

app/routes/jobs.new.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,6 @@ export default function NewJob() {
5959

6060
return (
6161
<div className="container mx-auto py-8 max-w-3xl">
62-
<h1 className="text-3xl font-bold mb-6">Add Job Opening</h1>
6362
<JobForm errors={actionData?.errors} />
6463
</div>
6564
)

0 commit comments

Comments
 (0)