Skip to content

Commit 6a1fa8f

Browse files
authored
Merge branch 'feat/setup-tailwind-shadcn' into mm-feature/update-listitem-singlelist-styling
2 parents deaad99 + e0db288 commit 6a1fa8f

File tree

7 files changed

+189
-22
lines changed

7 files changed

+189
-22
lines changed

package-lock.json

Lines changed: 105 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: 2 additions & 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",
@@ -20,6 +21,7 @@
2021
"react": "^18.3.1",
2122
"react-dom": "^18.3.1",
2223
"react-hot-toast": "^2.4.1",
24+
"react-icon": "^1.0.0",
2325
"react-icons": "^5.3.0",
2426
"react-router-dom": "^6.26.0",
2527
"tailwind-merge": "^2.5.2",

src/components/ManageListForms/AddItemForm.jsx

Lines changed: 39 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({
@@ -30,7 +24,9 @@ export default function AddItemForm({ listPath, data, handleOpenModal }) {
3024

3125
const formattedItemName = formData.itemName
3226
.toLowerCase()
33-
.replace(/[^a-z]/g, '');
27+
.replace(/^\s\s*/, '')
28+
.replace(/\s\s*$/, '')
29+
.replace(/[^a-zA-Z ]/g, '');
3430

3531
const match = data.find((item) => item.name === formattedItemName);
3632

@@ -60,7 +56,7 @@ export default function AddItemForm({ listPath, data, handleOpenModal }) {
6056
setFormData((prevFormData) => ({ ...prevFormData, [name]: value }));
6157
};
6258

63-
const handleSelectChange = (value) => {
59+
const handleRadioChange = (value) => {
6460
setFormData((prevFormData) => ({
6561
...prevFormData,
6662
daysUntilNextPurchase: value,
@@ -90,16 +86,40 @@ export default function AddItemForm({ listPath, data, handleOpenModal }) {
9086
<label htmlFor="daysUntilNextPurchase" className="text-md font-medium">
9187
How soon would you like to buy this again?
9288
</label>
93-
<Select onValueChange={handleSelectChange}>
94-
<SelectTrigger>
95-
<SelectValue placeholder="Select Time" />
96-
</SelectTrigger>
97-
<SelectContent className="bg-white">
98-
<SelectItem value="7">Soon (7 days)</SelectItem>
99-
<SelectItem value="14">Kind of soon (14 days)</SelectItem>
100-
<SelectItem value="30">Not soon (30 days)</SelectItem>
101-
</SelectContent>
102-
</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>
103123
</div>
104124
<div className="flex flex-col items-start gap-2 w-full">
105125
<label htmlFor="quantity" className="text-md font-medium">

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': '#595959',
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)