Skip to content

Commit d2f0a55

Browse files
authored
Merge pull request #16 from filipepacheco/feat/change-verified-badge-color
feat: change verified badge color, position and added tooltip
2 parents a25af06 + 2d9662c commit d2f0a55

File tree

5 files changed

+71
-9
lines changed

5 files changed

+71
-9
lines changed

src/components/ShelterListItem/ShelterListItem.tsx

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
import { useMemo } from 'react';
22
import { format } from 'date-fns';
33
import { useNavigate } from 'react-router-dom';
4-
import { BadgeCheck, ChevronRight } from 'lucide-react';
4+
import { ChevronRight } from 'lucide-react';
55

66
import { IShelterListItemProps, IShelterAvailabilityProps } from './types';
77
import { cn, getAvailabilityProps, getSupplyPriorityProps } from '@/lib/utils';
88
import { Separator } from '../ui/separator';
99
import { Chip } from '../Chip';
1010
import { Button } from '../ui/button';
1111
import { SupplyPriority } from '@/service/supply/types';
12+
import { VerifiedBadge } from '@/components/VerifiedBadge/VerifiedBadge.tsx';
1213

1314
const ShelterListItem = (props: IShelterListItemProps) => {
1415
const { data } = props;
@@ -39,15 +40,15 @@ const ShelterListItem = (props: IShelterListItemProps) => {
3940
<ChevronRight className="h-5 w-5" />
4041
</Button>
4142
<div className="flex items-center gap-1">
42-
{data.verified && (
43-
<BadgeCheck className="h-5 w-5 stroke-white fill-red-600" />
44-
)}
4543
<h3
46-
className="font-semibold text-lg mr-12 hover:cursor-pointer hover:text-slate-500"
44+
className="font-semibold text-lg hover:cursor-pointer hover:text-slate-500"
4745
onClick={() => navigate(`/abrigo/${data.id}`)}
4846
>
4947
{data.name}
5048
</h3>
49+
{data.verified && (
50+
<VerifiedBadge />
51+
)}
5152
</div>
5253
<h6 className={cn('font-semibold text-md', availabilityClassName)}>
5354
{availability}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import { BadgeCheck } from 'lucide-react';
2+
import WithTooltip from '@/components/ui/with-tooltip.tsx';
3+
4+
const VerifiedBadge = () => {
5+
return (
6+
<WithTooltip content="Abrigo verificado">
7+
<BadgeCheck className="h-5 w-5 stroke-white" fill="#1D61C8" />
8+
</WithTooltip>
9+
)
10+
}
11+
12+
export { VerifiedBadge };

src/components/ui/with-tooltip.tsx

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import * as Tooltip from '@radix-ui/react-tooltip';
2+
import { useState, ReactNode } from 'react';
3+
4+
interface WithTooltipProps {
5+
children: ReactNode;
6+
content: string;
7+
}
8+
9+
const WithTooltip = ({ children, content }: WithTooltipProps) => {
10+
const [open, setOpen] = useState(false);
11+
12+
return (
13+
<Tooltip.Provider>
14+
<Tooltip.Root open={open} onOpenChange={setOpen}>
15+
<Tooltip.Trigger asChild onClick={() => setOpen(!open)}>
16+
{children}
17+
</Tooltip.Trigger>
18+
<Tooltip.Portal>
19+
<Tooltip.Content className="text-white bg-gray-950 data-[state=delayed-open]:data-[side=top]:animate-slideDownAndFade data-[state=delayed-open]:data-[side=right]:animate-slideLeftAndFade data-[state=delayed-open]:data-[side=left]:animate-slideRightAndFade data-[state=delayed-open]:data-[side=bottom]:animate-slideUpAndFade text-violet11 select-none rounded-[4px] px-[15px] py-[10px] text-[12px] leading-none shadow-[hsl(206_22%_7%_/_35%)_0px_10px_38px_-10px,_hsl(206_22%_7%_/_20%)_0px_10px_20px_-15px] will-change-[transform,opacity]">
20+
{content}
21+
</Tooltip.Content>
22+
</Tooltip.Portal>
23+
</Tooltip.Root>
24+
</Tooltip.Provider>
25+
);
26+
};
27+
28+
export default WithTooltip;

src/pages/Shelter/Shelter.tsx

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { useMemo } from 'react';
2-
import { BadgeCheck, ChevronLeft, Pencil } from 'lucide-react';
2+
import { ChevronLeft, Pencil } from 'lucide-react';
33
import { useNavigate, useParams } from 'react-router-dom';
44

55
import { CardAboutShelter, Header, LoadingScreen } from '@/components';
@@ -10,6 +10,7 @@ import { Button } from '@/components/ui/button';
1010
import { ShelterCategoryItems } from './components';
1111
import { IShelterCategoryItemsProps } from './components/ShelterCategoryItems/types';
1212
import { SupplyPriority } from '@/service/supply/types';
13+
import { VerifiedBadge } from '@/components/VerifiedBadge/VerifiedBadge.tsx';
1314

1415
const Shelter = () => {
1516
const params = useParams();
@@ -54,12 +55,12 @@ const Shelter = () => {
5455
/>
5556
<div className="p-4 flex flex-col max-w-5xl w-full">
5657
<div className="flex items-center gap-1">
57-
{shelter.verified && (
58-
<BadgeCheck className="h-6 w-6 stroke-white fill-red-600" />
59-
)}
6058
<h1 className="text-[#2f2f2f] font-semibold text-2xl">
6159
{shelter.name}
6260
</h1>
61+
{shelter.verified && (
62+
<VerifiedBadge />
63+
)}
6364
</div>
6465
<div className="flex flex-1 items-center justify-between">
6566
<h1 className={cn(availabilityClassName, 'font-semibold')}>

tailwind.config.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,22 @@ module.exports = {
6464
sm: 'calc(var(--radius) - 4px)',
6565
},
6666
keyframes: {
67+
slideDownAndFade: {
68+
from: { opacity: '0', transform: 'translateY(-2px)' },
69+
to: { opacity: '1', transform: 'translateY(0)' },
70+
},
71+
slideLeftAndFade: {
72+
from: { opacity: '0', transform: 'translateX(2px)' },
73+
to: { opacity: '1', transform: 'translateX(0)' },
74+
},
75+
slideUpAndFade: {
76+
from: { opacity: '0', transform: 'translateY(2px)' },
77+
to: { opacity: '1', transform: 'translateY(0)' },
78+
},
79+
slideRightAndFade: {
80+
from: { opacity: '0', transform: 'translateX(-2px)' },
81+
to: { opacity: '1', transform: 'translateX(0)' },
82+
},
6783
'accordion-down': {
6884
from: { height: '0' },
6985
to: { height: 'var(--radix-accordion-content-height)' },
@@ -76,6 +92,10 @@ module.exports = {
7692
animation: {
7793
'accordion-down': 'accordion-down 0.2s ease-out',
7894
'accordion-up': 'accordion-up 0.2s ease-out',
95+
slideDownAndFade: 'slideDownAndFade 400ms cubic-bezier(0.16, 1, 0.3, 1)',
96+
slideLeftAndFade: 'slideLeftAndFade 400ms cubic-bezier(0.16, 1, 0.3, 1)',
97+
slideUpAndFade: 'slideUpAndFade 400ms cubic-bezier(0.16, 1, 0.3, 1)',
98+
slideRightAndFade: 'slideRightAndFade 400ms cubic-bezier(0.16, 1, 0.3, 1)',
7999
},
80100
},
81101
},

0 commit comments

Comments
 (0)