Skip to content

Commit e0db288

Browse files
authored
Merge pull request #50 from the-collab-lab/hm-add-item-radio-buttons
2 parents 5d88730 + adec26e commit e0db288

File tree

8 files changed

+162
-24
lines changed

8 files changed

+162
-24
lines changed

package-lock.json

Lines changed: 76 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
"dependencies": {
1010
"@radix-ui/react-alert-dialog": "^1.1.2",
1111
"@radix-ui/react-dialog": "^1.1.1",
12+
"@radix-ui/react-radio-group": "^1.2.1",
1213
"@radix-ui/react-select": "^2.1.2",
1314
"@radix-ui/react-slot": "^1.1.0",
1415
"@radix-ui/react-tooltip": "^1.1.3",

src/components/ListItem.jsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ export function ListItem({
102102
id={id}
103103
onClick={() => setIsAlertOpen(true)}
104104
>
105-
<Trash2 className="text-main-green w-6 h-6 md:w-7 md:h-7" />
105+
<Trash2 className="text-primary-green w-6 h-6 md:w-7 md:h-7" />
106106
</Button>
107107
</AlertDialogTrigger>
108108
<AlertDialogContent>
@@ -117,7 +117,10 @@ export function ListItem({
117117
<AlertDialogCancel onClick={() => setIsAlertOpen(false)}>
118118
Cancel
119119
</AlertDialogCancel>
120-
<AlertDialogAction onClick={handleDelete}>
120+
<AlertDialogAction
121+
onClick={handleDelete}
122+
className="bg-primary-pink text-white"
123+
>
121124
Continue
122125
</AlertDialogAction>
123126
</AlertDialogFooter>

src/components/ManageListForms/AddItemForm.jsx

Lines changed: 37 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,7 @@ import { addItem } from '../../api/firebase';
33
import toast from 'react-hot-toast';
44
import { Button } from '../ui/button';
55
import { Input } from '../ui/input';
6-
import {
7-
Select,
8-
SelectTrigger,
9-
SelectContent,
10-
SelectItem,
11-
SelectValue,
12-
} from '../ui/select';
6+
import { RadioGroup, RadioGroupItem } from '@/components/ui/radio-group';
137

148
export default function AddItemForm({ listPath, data, handleOpenModal }) {
159
const [formData, setFormData] = useState({
@@ -62,7 +56,7 @@ export default function AddItemForm({ listPath, data, handleOpenModal }) {
6256
setFormData((prevFormData) => ({ ...prevFormData, [name]: value }));
6357
};
6458

65-
const handleSelectChange = (value) => {
59+
const handleRadioChange = (value) => {
6660
setFormData((prevFormData) => ({
6761
...prevFormData,
6862
daysUntilNextPurchase: value,
@@ -92,16 +86,40 @@ export default function AddItemForm({ listPath, data, handleOpenModal }) {
9286
<label htmlFor="daysUntilNextPurchase" className="text-md font-medium">
9387
How soon would you like to buy this again?
9488
</label>
95-
<Select onValueChange={handleSelectChange}>
96-
<SelectTrigger>
97-
<SelectValue placeholder="Select Time" />
98-
</SelectTrigger>
99-
<SelectContent>
100-
<SelectItem value="7">Soon (7 days)</SelectItem>
101-
<SelectItem value="14">Kind of soon (14 days)</SelectItem>
102-
<SelectItem value="30">Not soon (30 days)</SelectItem>
103-
</SelectContent>
104-
</Select>
89+
<RadioGroup
90+
onValueChange={handleRadioChange}
91+
className="flex my-2 items-center justify-center gap-4"
92+
id="daysUntilNextPurchase"
93+
>
94+
<div className="flex flex-col items-center justify-center rounded-xl border border-light-pink gap-4 w-28 h-28 shadow-bottom-right transition-transform duration-200 ease-in-out transform active:scale-95">
95+
<RadioGroupItem
96+
value="7"
97+
id="soon"
98+
name="timeFrame"
99+
className="border border-soon text-soon"
100+
/>
101+
<label htmlFor="soon" className="font-semibold text-sm">
102+
Soon
103+
</label>
104+
</div>
105+
<div className="flex flex-col items-center justify-center rounded-xl border border-light-pink gap-4 w-28 h-28 shadow-bottom-right transition-transform duration-200 ease-in-out transform active:scale-95">
106+
<RadioGroupItem
107+
value="14"
108+
id="kind-of-soon"
109+
name="timeFrame"
110+
className="border border-kind-of-soon text-kind-of-soon"
111+
/>
112+
<label htmlFor="kind-of-soon" className="font-semibold text-sm">
113+
Kind of soon
114+
</label>
115+
</div>
116+
<div className="flex flex-col items-center justify-center rounded-xl border border-light-pink gap-4 w-28 h-28 shadow-bottom-right transition-transform duration-200 ease-in-out transform active:scale-95">
117+
<RadioGroupItem value="30" id="not-of-soon" name="timeFrame" />
118+
<label htmlFor="not of soon" className="font-semibold text-sm">
119+
Not soon
120+
</label>
121+
</div>
122+
</RadioGroup>
105123
</div>
106124
<div className="flex flex-col items-start gap-2 w-full">
107125
<label htmlFor="quantity" className="text-md font-medium">
@@ -123,7 +141,7 @@ export default function AddItemForm({ listPath, data, handleOpenModal }) {
123141
<div className="flex w-full">
124142
<Button
125143
type="submit"
126-
className="bg-pink text-white rounded-xl w-full hover:bg-pink hover:bg-opacity-75 text-sm"
144+
className="bg-primary-pink text-white rounded-xl w-full hover:bg-primary-pink hover:bg-opacity-75 text-sm"
127145
>
128146
Add Item
129147
</Button>

src/components/ui/dialog.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ const DialogContent = React.forwardRef(
3939
>
4040
{children}
4141
<DialogPrimitive.Close className="absolute right-4 top-4 rounded-sm opacity-70 ring-offset-white transition-opacity hover:opacity-100 focus:outline-none focus:ring-0 focus:ring-slate-950 focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-slate-100 data-[state=open]:text-slate-500 dark:ring-offset-slate-950 dark:focus:ring-slate-300 dark:data-[state=open]:bg-slate-800 dark:data-[state=open]:text-slate-400">
42-
<X className="h-7 w-7 text-grey" />
42+
<X className="h-7 w-7 text-light-grey" />
4343
</DialogPrimitive.Close>
4444
</DialogPrimitive.Content>
4545
</DialogPortal>

src/components/ui/radio-group.jsx

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
import * as React from 'react';
2+
import * as RadioGroupPrimitive from '@radix-ui/react-radio-group';
3+
import { Circle } from 'lucide-react';
4+
5+
import { cn } from '@/lib/utils';
6+
7+
const RadioGroup = React.forwardRef(({ className, ...props }, ref) => {
8+
return (
9+
<RadioGroupPrimitive.Root
10+
className={cn('grid gap-2', className)}
11+
{...props}
12+
ref={ref}
13+
/>
14+
);
15+
});
16+
RadioGroup.displayName = RadioGroupPrimitive.Root.displayName;
17+
18+
const RadioGroupItem = React.forwardRef(({ className, ...props }, ref) => {
19+
return (
20+
<RadioGroupPrimitive.Item
21+
ref={ref}
22+
className={cn(
23+
'aspect-square h-4 w-4 rounded-full border border-primary-green text-primary-green ring-offset-white focus:outline-none focus-visible:ring-2 focus-visible:ring-slate-950 focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 dark:border-slate-50 dark:text-slate-50 dark:ring-offset-slate-950 dark:focus-visible:ring-slate-300',
24+
className,
25+
)}
26+
{...props}
27+
>
28+
<RadioGroupPrimitive.Indicator className="flex items-center justify-center">
29+
<Circle className="h-2.5 w-2.5 fill-current text-current" />
30+
</RadioGroupPrimitive.Indicator>
31+
</RadioGroupPrimitive.Item>
32+
);
33+
});
34+
RadioGroupItem.displayName = RadioGroupPrimitive.Item.displayName;
35+
36+
export { RadioGroup, RadioGroupItem };

src/index.css

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,7 @@ input[type='number'] {
1616
#root {
1717
background-color: #201c24;
1818
}
19+
20+
.shadow-bottom-right {
21+
box-shadow: 4px 4px 4px rgba(0, 0, 0, 0.3);
22+
}

tailwind.config.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ export default {
2323
'dark-grey': '#7A7A7A',
2424
'light-grey': '#A3A3A3',
2525
'text-grey': '#B5B5B5',
26-
soon: '#FFB74D',
27-
'kind-of-soon': '#FEE720',
26+
soon: '#FEE720',
27+
'kind-of-soon': '#FFB74D',
2828
'not-soon': '#81C784',
2929
inactive: '#B0BEC5',
3030
overdue: '#FF5252',

0 commit comments

Comments
 (0)