From 2d9662c8a95c82881d6f8e9dd6ab87ae33c7231a Mon Sep 17 00:00:00 2001 From: Lipe Date: Wed, 8 May 2024 23:44:03 -0300 Subject: [PATCH] feat: change verified badge color, position and added tooltip --- .../ShelterListItem/ShelterListItem.tsx | 11 ++++---- .../VerifiedBadge/VerifiedBadge.tsx | 12 ++++++++ src/components/ui/with-tooltip.tsx | 28 +++++++++++++++++++ src/pages/Shelter/Shelter.tsx | 9 +++--- tailwind.config.js | 20 +++++++++++++ 5 files changed, 71 insertions(+), 9 deletions(-) create mode 100644 src/components/VerifiedBadge/VerifiedBadge.tsx create mode 100644 src/components/ui/with-tooltip.tsx diff --git a/src/components/ShelterListItem/ShelterListItem.tsx b/src/components/ShelterListItem/ShelterListItem.tsx index 60806624..3c68e80a 100644 --- a/src/components/ShelterListItem/ShelterListItem.tsx +++ b/src/components/ShelterListItem/ShelterListItem.tsx @@ -1,7 +1,7 @@ import { useMemo } from 'react'; import { format } from 'date-fns'; import { useNavigate } from 'react-router-dom'; -import { BadgeCheck, ChevronRight } from 'lucide-react'; +import { ChevronRight } from 'lucide-react'; import { IShelterListItemProps, IShelterAvailabilityProps } from './types'; import { cn, getAvailabilityProps, getSupplyPriorityProps } from '@/lib/utils'; @@ -9,6 +9,7 @@ import { Separator } from '../ui/separator'; import { Chip } from '../Chip'; import { Button } from '../ui/button'; import { SupplyPriority } from '@/service/supply/types'; +import { VerifiedBadge } from '@/components/VerifiedBadge/VerifiedBadge.tsx'; const ShelterListItem = (props: IShelterListItemProps) => { const { data } = props; @@ -39,15 +40,15 @@ const ShelterListItem = (props: IShelterListItemProps) => {
- {data.verified && ( - - )}

navigate(`/abrigo/${data.id}`)} > {data.name}

+ {data.verified && ( + + )}
{availability} diff --git a/src/components/VerifiedBadge/VerifiedBadge.tsx b/src/components/VerifiedBadge/VerifiedBadge.tsx new file mode 100644 index 00000000..48629be7 --- /dev/null +++ b/src/components/VerifiedBadge/VerifiedBadge.tsx @@ -0,0 +1,12 @@ +import { BadgeCheck } from 'lucide-react'; +import WithTooltip from '@/components/ui/with-tooltip.tsx'; + +const VerifiedBadge = () => { + return ( + + + + ) +} + +export { VerifiedBadge }; \ No newline at end of file diff --git a/src/components/ui/with-tooltip.tsx b/src/components/ui/with-tooltip.tsx new file mode 100644 index 00000000..6f62b108 --- /dev/null +++ b/src/components/ui/with-tooltip.tsx @@ -0,0 +1,28 @@ +import * as Tooltip from '@radix-ui/react-tooltip'; +import { useState, ReactNode } from 'react'; + +interface WithTooltipProps { + children: ReactNode; + content: string; +} + +const WithTooltip = ({ children, content }: WithTooltipProps) => { + const [open, setOpen] = useState(false); + + return ( + + + setOpen(!open)}> + {children} + + + + {content} + + + + + ); +}; + +export default WithTooltip; \ No newline at end of file diff --git a/src/pages/Shelter/Shelter.tsx b/src/pages/Shelter/Shelter.tsx index 4f0e6897..3db35200 100644 --- a/src/pages/Shelter/Shelter.tsx +++ b/src/pages/Shelter/Shelter.tsx @@ -1,5 +1,5 @@ import { useMemo } from 'react'; -import { BadgeCheck, ChevronLeft, Pencil } from 'lucide-react'; +import { ChevronLeft, Pencil } from 'lucide-react'; import { useNavigate, useParams } from 'react-router-dom'; import { CardAboutShelter, Header, LoadingScreen } from '@/components'; @@ -10,6 +10,7 @@ import { Button } from '@/components/ui/button'; import { ShelterCategoryItems } from './components'; import { IShelterCategoryItemsProps } from './components/ShelterCategoryItems/types'; import { SupplyPriority } from '@/service/supply/types'; +import { VerifiedBadge } from '@/components/VerifiedBadge/VerifiedBadge.tsx'; const Shelter = () => { const params = useParams(); @@ -54,12 +55,12 @@ const Shelter = () => { />
- {shelter.verified && ( - - )}

{shelter.name}

+ {shelter.verified && ( + + )}

diff --git a/tailwind.config.js b/tailwind.config.js index 176f9944..917cdbf5 100644 --- a/tailwind.config.js +++ b/tailwind.config.js @@ -64,6 +64,22 @@ module.exports = { sm: 'calc(var(--radius) - 4px)', }, keyframes: { + slideDownAndFade: { + from: { opacity: '0', transform: 'translateY(-2px)' }, + to: { opacity: '1', transform: 'translateY(0)' }, + }, + slideLeftAndFade: { + from: { opacity: '0', transform: 'translateX(2px)' }, + to: { opacity: '1', transform: 'translateX(0)' }, + }, + slideUpAndFade: { + from: { opacity: '0', transform: 'translateY(2px)' }, + to: { opacity: '1', transform: 'translateY(0)' }, + }, + slideRightAndFade: { + from: { opacity: '0', transform: 'translateX(-2px)' }, + to: { opacity: '1', transform: 'translateX(0)' }, + }, 'accordion-down': { from: { height: '0' }, to: { height: 'var(--radix-accordion-content-height)' }, @@ -76,6 +92,10 @@ module.exports = { animation: { 'accordion-down': 'accordion-down 0.2s ease-out', 'accordion-up': 'accordion-up 0.2s ease-out', + slideDownAndFade: 'slideDownAndFade 400ms cubic-bezier(0.16, 1, 0.3, 1)', + slideLeftAndFade: 'slideLeftAndFade 400ms cubic-bezier(0.16, 1, 0.3, 1)', + slideUpAndFade: 'slideUpAndFade 400ms cubic-bezier(0.16, 1, 0.3, 1)', + slideRightAndFade: 'slideRightAndFade 400ms cubic-bezier(0.16, 1, 0.3, 1)', }, }, },