Skip to content

Commit 85aaa86

Browse files
author
belledw
committed
added 'pet settings' menu
1 parent 963c16d commit 85aaa86

3 files changed

Lines changed: 118 additions & 1 deletion

File tree

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
"use client";
2+
import { ChevronDownIcon } from "lucide-react";
3+
import * as React from "react";
4+
5+
import { Button } from "@/components/ui/button";
6+
import { Calendar } from "@/components/ui/calendar";
7+
import { Label } from "@/components/ui/label";
8+
import {
9+
Popover,
10+
PopoverContent,
11+
PopoverTrigger,
12+
} from "@/components/ui/popover";
13+
import { dm_sans } from "@/lib/fonts";
14+
15+
export function DOBPicker({ prevDOB }: { prevDOB: string }) {
16+
const [open, setOpen] = React.useState(false);
17+
const [date, setDate] = React.useState<Date | undefined>(undefined);
18+
return (
19+
<div className="flex flex-col gap-3">
20+
<Label htmlFor="date" className="px-1">
21+
Date of birth
22+
</Label>
23+
<Popover open={open} onOpenChange={setOpen}>
24+
<PopoverTrigger asChild>
25+
<Button
26+
variant="outline"
27+
id="date"
28+
className="w-48 justify-between font-normal"
29+
>
30+
{date ? date.toLocaleDateString() : prevDOB}
31+
<ChevronDownIcon />
32+
</Button>
33+
</PopoverTrigger>
34+
<PopoverContent className="w-auto overflow-hidden p-0" align="start">
35+
<Calendar
36+
className={`${dm_sans.className}`}
37+
mode="single"
38+
selected={date}
39+
captionLayout="dropdown"
40+
onSelect={(date) => {
41+
setDate(date);
42+
setOpen(false);
43+
}}
44+
/>
45+
</PopoverContent>
46+
</Popover>
47+
</div>
48+
);
49+
}
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
"use client";
2+
3+
import { Check, X } from "lucide-react";
4+
5+
import { DOBPicker } from "@/components/ui/dob-picker";
6+
import { Field, FieldGroup, FieldLabel } from "@/components/ui/field";
7+
8+
import { Button } from "./button";
9+
import { CardTitle } from "./card";
10+
import { Input } from "./input";
11+
12+
interface PetSettingsProps {
13+
className?: string;
14+
petName: string;
15+
petType: string;
16+
petDOB: string;
17+
onClickClose: () => void;
18+
}
19+
20+
export function PetSettings(props: PetSettingsProps) {
21+
return (
22+
<div className="flex flex-col gap-5">
23+
<CardTitle className="flex gap-2 text-3xl">
24+
Settings for {props.petName}
25+
</CardTitle>
26+
<FieldGroup>
27+
<Field>
28+
<FieldLabel htmlFor="checkout-7j9-card-name-43j">Pet Name</FieldLabel>
29+
<Input id="checkout-7j9-card-name-43j" placeholder={props.petName} />
30+
</Field>
31+
<div className="lg:max-w-1/2 flex gap-5">
32+
<Field className="-mt-1">
33+
<FieldLabel htmlFor="checkout-7j9-card-name">Pet Type</FieldLabel>
34+
<Input id="checkout-7j9-card-name" placeholder={props.petType} />
35+
</Field>
36+
<DOBPicker prevDOB={props.petDOB} />
37+
</div>
38+
</FieldGroup>
39+
<div className="mt-5 flex items-center gap-5">
40+
<Button
41+
className="gray-600 hover:gray-400 rounded-full"
42+
onClick={props.onClickClose}
43+
>
44+
<Check className="mr-1" /> Save changes
45+
</Button>
46+
<Button
47+
className="rounded-full"
48+
variant="outline"
49+
onClick={props.onClickClose}
50+
>
51+
<X className="mr-1" /> Discard and close
52+
</Button>
53+
</div>
54+
<hr className="my-5"></hr>
55+
</div>
56+
);
57+
}

client/src/pages/pet.tsx

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,19 +8,21 @@ import { EventCard } from "@/components/ui/event-card";
88
import { ChartBarHorizontal } from "@/components/ui/health-chart";
99
import { HealthOverview } from "@/components/ui/health-overview";
1010
import { PetHeader } from "@/components/ui/pet-page-header";
11+
import { PetSettings } from "@/components/ui/pet-settings-menu";
1112
import { TaskCarousel } from "@/components/ui/pet-task-carousel";
1213
import { TextTitle } from "@/components/ui/text-styles";
1314
import { dm_sans } from "@/lib/fonts";
1415

1516
export default function Default() {
1617
const [taskMenu, setTaskMenu] = useState(false);
18+
const [settingsMenu, setSettingsMenu] = useState(false);
1719

1820
return (
1921
<div className={dm_sans.className}>
2022
<h1 className="flex justify-center p-10"> Navbar </h1>
2123
<PetHeader
2224
onClickTask={() => setTaskMenu(true)}
23-
onClickSettings={() => "state function here"}
25+
onClickSettings={() => setSettingsMenu(true)}
2426
petImg=""
2527
petAlt="Spaghetti's Profile Image"
2628
petInit="S"
@@ -34,6 +36,15 @@ export default function Default() {
3436
<AddTask onClickClose={() => setTaskMenu(false)} />
3537
)}
3638

39+
{settingsMenu === true && (
40+
<PetSettings
41+
petName="Spaghetti"
42+
petType="Cat"
43+
petDOB="01/06/2020"
44+
onClickClose={() => setSettingsMenu(false)}
45+
/>
46+
)}
47+
3748
<TextTitle className="mt-5 text-3xl"> Upcoming Tasks </TextTitle>
3849
<div className="flex justify-center md:mx-0">
3950
<TaskCarousel />

0 commit comments

Comments
 (0)