From 4f556e5983fbfc9c905b564a7ede7be97ba48e36 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adrian=20Or=C5=82=C3=B3w?= <adrian.orlow@fishbrain.com> Date: Tue, 16 Jan 2024 14:54:53 +0100 Subject: [PATCH] fix: rfc changes --- .../vectors/icons/magnifier-zoom-in.svg | 11 -------- .../vectors/icons/magnifier-zoom-out.svg | 11 -------- .../MapAdditionalActions.component.test.tsx | 18 +++++-------- .../MapAdditionalActions.component.tsx | 14 +++++----- src/shared/Icon/Icon.component.tsx | 6 +++++ .../Icon/Icons/LocationIcon.tsx} | 22 ++++++++++++--- src/shared/Icon/Icons/MagnifierZoomIn.tsx | 27 +++++++++++++++++++ src/shared/Icon/Icons/MagnifierZoomOut.tsx | 27 +++++++++++++++++++ src/types/iconTypes.ts | 3 +++ 9 files changed, 95 insertions(+), 44 deletions(-) delete mode 100644 src/assets/vectors/icons/magnifier-zoom-in.svg delete mode 100644 src/assets/vectors/icons/magnifier-zoom-out.svg rename src/{assets/vectors/icons/location.svg => shared/Icon/Icons/LocationIcon.tsx} (66%) create mode 100644 src/shared/Icon/Icons/MagnifierZoomIn.tsx create mode 100644 src/shared/Icon/Icons/MagnifierZoomOut.tsx diff --git a/src/assets/vectors/icons/magnifier-zoom-in.svg b/src/assets/vectors/icons/magnifier-zoom-in.svg deleted file mode 100644 index 10df8aa3..00000000 --- a/src/assets/vectors/icons/magnifier-zoom-in.svg +++ /dev/null @@ -1,11 +0,0 @@ -<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg"> -<g clip-path="url(#clip0_4_190)"> -<path d="M15 12H12V15H9V12H6V9H9V6H12V9H15V12Z" fill="#8E92A1"/> -<path d="M23.5605 19.9395L19.5 15.879C20.4798 14.2558 20.9985 12.396 21 10.5C21 4.71 16.2885 0 10.5 0C4.7115 0 0 4.71 0 10.5C0 16.29 4.7115 21 10.5 21C12.3962 20.9994 14.2562 20.4808 15.879 19.5L19.9395 23.5605C20.0785 23.7003 20.2437 23.8112 20.4257 23.8869C20.6077 23.9626 20.8029 24.0016 21 24.0016C21.1971 24.0016 21.3923 23.9626 21.5743 23.8869C21.7563 23.8112 21.9215 23.7003 22.0605 23.5605L23.5605 22.0605C23.6999 21.9213 23.8105 21.756 23.886 21.574C23.9615 21.3921 24.0003 21.197 24.0003 21C24.0003 20.803 23.9615 20.6079 23.886 20.426C23.8105 20.244 23.6999 20.0787 23.5605 19.9395V19.9395ZM10.5 18C8.51068 17.9998 6.60291 17.2094 5.19639 15.8026C3.78987 14.3957 2.9998 12.4878 3 10.4985C3.0002 8.50918 3.79064 6.60141 5.19745 5.19489C6.60425 3.78837 8.51218 2.9983 10.5015 2.9985C12.4908 2.9987 14.3986 3.78915 15.8051 5.19595C17.2116 6.60275 18.0017 8.51068 18.0015 10.5C18.0013 12.4893 17.2109 14.3971 15.8041 15.8036C14.3972 17.2101 12.4893 18.0002 10.5 18V18Z" fill="#8E92A1"/> -</g> -<defs> -<clipPath id="clip0_4_190"> -<rect width="24" height="24" fill="white"/> -</clipPath> -</defs> -</svg> diff --git a/src/assets/vectors/icons/magnifier-zoom-out.svg b/src/assets/vectors/icons/magnifier-zoom-out.svg deleted file mode 100644 index 939f1a35..00000000 --- a/src/assets/vectors/icons/magnifier-zoom-out.svg +++ /dev/null @@ -1,11 +0,0 @@ -<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg"> -<g clip-path="url(#clip0_4_194)"> -<path d="M6 9H15V12H6V9Z" fill="#8E92A1"/> -<path d="M23.5605 19.9395L19.5 15.879C20.4798 14.2558 20.9985 12.396 21 10.5C21 4.71 16.2885 0 10.5 0C4.7115 0 0 4.71 0 10.5C0 16.29 4.7115 21 10.5 21C12.3962 20.9994 14.2562 20.4808 15.879 19.5L19.9395 23.5605C20.0785 23.7003 20.2437 23.8112 20.4257 23.8869C20.6077 23.9626 20.8029 24.0016 21 24.0016C21.1971 24.0016 21.3923 23.9626 21.5743 23.8869C21.7563 23.8112 21.9215 23.7003 22.0605 23.5605L23.5605 22.0605C23.6999 21.9213 23.8105 21.756 23.886 21.574C23.9615 21.3921 24.0003 21.197 24.0003 21C24.0003 20.803 23.9615 20.6079 23.886 20.426C23.8105 20.244 23.6999 20.0787 23.5605 19.9395V19.9395ZM10.5 18C8.51068 17.9998 6.60291 17.2094 5.19639 15.8026C3.78987 14.3957 2.9998 12.4878 3 10.4985C3.0002 8.50918 3.79064 6.60141 5.19745 5.19489C6.60425 3.78837 8.51218 2.9983 10.5015 2.9985C12.4908 2.9987 14.3986 3.78915 15.8051 5.19595C17.2116 6.60275 18.0017 8.51068 18.0015 10.5C18.0013 12.4893 17.2109 14.3971 15.8041 15.8036C14.3972 17.2101 12.4893 18.0002 10.5 18V18Z" fill="#8E92A1"/> -</g> -<defs> -<clipPath id="clip0_4_194"> -<rect width="24" height="24" fill="white"/> -</clipPath> -</defs> -</svg> diff --git a/src/components/Map/MapAdditionalActions/MapAdditionalActions.component.test.tsx b/src/components/Map/MapAdditionalActions/MapAdditionalActions.component.test.tsx index 09f91627..f65f5b60 100644 --- a/src/components/Map/MapAdditionalActions/MapAdditionalActions.component.test.tsx +++ b/src/components/Map/MapAdditionalActions/MapAdditionalActions.component.test.tsx @@ -77,20 +77,17 @@ describe('MapAdditionalActions - component', () => { }); it('should render zoom in button', () => { - const image = screen.getByAltText('zoom in button icon'); - const button = image.closest('button'); + const button = screen.getByTestId('zoom-in-button'); expect(button).toBeInTheDocument(); }); it('should render zoom out button', () => { - const image = screen.getByAltText('zoom out button icon'); - const button = image.closest('button'); + const button = screen.getByTestId('zoom-out-button'); expect(button).toBeInTheDocument(); }); it('should render location button', () => { - const image = screen.getByAltText('location button icon'); - const button = image.closest('button'); + const button = screen.getByTestId('location-button'); expect(button).toBeInTheDocument(); }); }); @@ -98,8 +95,7 @@ describe('MapAdditionalActions - component', () => { describe('when clicked on zoom in button', () => { it('should dispatch varyPositionZoom action with valid delta', () => { const { store } = renderComponent(INITIAL_STORE_STATE_MOCK); - const image = screen.getByAltText('zoom in button icon'); - const button = image.closest('button'); + const button = screen.getByTestId('zoom-in-button'); button!.click(); const actions = store.getActions(); @@ -113,8 +109,7 @@ describe('MapAdditionalActions - component', () => { describe('when clicked on zoom in button', () => { it('should dispatch varyPositionZoom action with valid delta', () => { const { store } = renderComponent(INITIAL_STORE_STATE_MOCK); - const image = screen.getByAltText('zoom out button icon'); - const button = image.closest('button'); + const button = screen.getByTestId('zoom-out-button'); button!.click(); const actions = store.getActions(); @@ -153,8 +148,7 @@ describe('MapAdditionalActions - component', () => { }, }); - const image = screen.getByAltText('location button icon'); - const button = image.closest('button'); + const button = screen.getByTestId('location-button'); act(() => { button!.click(); }); diff --git a/src/components/Map/MapAdditionalActions/MapAdditionalActions.component.tsx b/src/components/Map/MapAdditionalActions/MapAdditionalActions.component.tsx index 396ec54a..524e00c1 100644 --- a/src/components/Map/MapAdditionalActions/MapAdditionalActions.component.tsx +++ b/src/components/Map/MapAdditionalActions/MapAdditionalActions.component.tsx @@ -1,7 +1,4 @@ -import locationIcon from '@/assets/vectors/icons/location.svg'; -import magnifierZoomInIcon from '@/assets/vectors/icons/magnifier-zoom-in.svg'; -import magnifierZoomOutIcon from '@/assets/vectors/icons/magnifier-zoom-out.svg'; -import Image from 'next/image'; +import { Icon } from '@/shared/Icon'; import { twMerge } from 'tailwind-merge'; import { useAddtionalActions } from './utils/useAdditionalActions'; @@ -19,24 +16,27 @@ export const MapAdditionalActions = (): JSX.Element => { type="button" className="flex h-[48px] w-[48px] items-center justify-center rounded-full bg-white" onClick={zoomInToBioEntities} + data-testid="location-button" > - <Image src={locationIcon} alt="location button icon" height={28} width={28} /> + <Icon className="h-[28px] w-[28px]" name="location" /> </button> <div className="flex h-auto w-[48px] flex-col items-center justify-center rounded-full bg-white py-2"> <button type="button" className="flex h-[48px] w-[48px] items-center justify-center" onClick={zoomIn} + data-testid="zoom-in-button" > - <Image src={magnifierZoomInIcon} alt="zoom in button icon" height={24} width={24} /> + <Icon className="h-[24px] w-[24px]" name="magnifier-zoom-in" /> </button> <div className="h-[1px] w-[32px] bg-[#F1F1F1]" /> <button type="button" className="flex h-[48px] w-[48px] items-center justify-center" onClick={zoomOut} + data-testid="zoom-out-button" > - <Image src={magnifierZoomOutIcon} alt="zoom out button icon" height={24} width={24} /> + <Icon className="h-[24px] w-[24px]" name="magnifier-zoom-out" /> </button> </div> </div> diff --git a/src/shared/Icon/Icon.component.tsx b/src/shared/Icon/Icon.component.tsx index a4b4ee63..0dae32d4 100644 --- a/src/shared/Icon/Icon.component.tsx +++ b/src/shared/Icon/Icon.component.tsx @@ -15,6 +15,9 @@ import { CloseIcon } from '@/shared/Icon/Icons/CloseIcon'; import { Pin } from '@/shared/Icon/Icons/Pin'; import type { IconTypes } from '@/types/iconTypes'; +import { LocationIcon } from './Icons/LocationIcon'; +import { MaginfierZoomInIcon } from './Icons/MagnifierZoomIn'; +import { MaginfierZoomOutIcon } from './Icons/MagnifierZoomOut'; export interface IconProps { className?: string; @@ -37,6 +40,9 @@ const icons = { page: PageIcon, plugin: PluginIcon, close: CloseIcon, + location: LocationIcon, + 'magnifier-zoom-in': MaginfierZoomInIcon, + 'magnifier-zoom-out': MaginfierZoomOutIcon, } as const; export const Icon = ({ name, className = '', ...rest }: IconProps): JSX.Element => { diff --git a/src/assets/vectors/icons/location.svg b/src/shared/Icon/Icons/LocationIcon.tsx similarity index 66% rename from src/assets/vectors/icons/location.svg rename to src/shared/Icon/Icons/LocationIcon.tsx index 2c376ca5..d931d331 100644 --- a/src/assets/vectors/icons/location.svg +++ b/src/shared/Icon/Icons/LocationIcon.tsx @@ -1,3 +1,19 @@ -<svg width="28" height="28" viewBox="0 0 28 28" fill="none" xmlns="http://www.w3.org/2000/svg"> -<path d="M13.9998 9.33073C11.4215 9.33073 9.33317 11.4191 9.33317 13.9974C9.33317 16.5757 11.4215 18.6641 13.9998 18.6641C16.5782 18.6641 18.6665 16.5757 18.6665 13.9974C18.6665 11.4191 16.5782 9.33073 13.9998 9.33073ZM24.4298 12.8307C24.1656 10.4649 23.1047 8.25919 21.4214 6.57587C19.738 4.89255 17.5324 3.83166 15.1665 3.5674V1.16406H12.8332V3.5674C10.4673 3.83166 8.26163 4.89255 6.57831 6.57587C4.895 8.25919 3.8341 10.4649 3.56984 12.8307H1.1665V15.1641H3.56984C3.8341 17.5299 4.895 19.7356 6.57831 21.4189C8.26163 23.1022 10.4673 24.1631 12.8332 24.4274V26.8307H15.1665V24.4274C17.5324 24.1631 19.738 23.1022 21.4214 21.4189C23.1047 19.7356 24.1656 17.5299 24.4298 15.1641H26.8332V12.8307H24.4298V12.8307ZM13.9998 22.1641C9.48484 22.1641 5.83317 18.5124 5.83317 13.9974C5.83317 9.4824 9.48484 5.83073 13.9998 5.83073C18.5148 5.83073 22.1665 9.4824 22.1665 13.9974C22.1665 18.5124 18.5148 22.1641 13.9998 22.1641Z" fill="#8E92A1"/> -</svg> +interface LocationIconProps { + className?: string; +} + +export const LocationIcon = ({ className }: LocationIconProps): JSX.Element => ( + <svg + width="28" + height="28" + viewBox="0 0 28 28" + fill="none" + xmlns="http://www.w3.org/2000/svg" + className={className} + > + <path + d="M13.9998 9.33073C11.4215 9.33073 9.33317 11.4191 9.33317 13.9974C9.33317 16.5757 11.4215 18.6641 13.9998 18.6641C16.5782 18.6641 18.6665 16.5757 18.6665 13.9974C18.6665 11.4191 16.5782 9.33073 13.9998 9.33073ZM24.4298 12.8307C24.1656 10.4649 23.1047 8.25919 21.4214 6.57587C19.738 4.89255 17.5324 3.83166 15.1665 3.5674V1.16406H12.8332V3.5674C10.4673 3.83166 8.26163 4.89255 6.57831 6.57587C4.895 8.25919 3.8341 10.4649 3.56984 12.8307H1.1665V15.1641H3.56984C3.8341 17.5299 4.895 19.7356 6.57831 21.4189C8.26163 23.1022 10.4673 24.1631 12.8332 24.4274V26.8307H15.1665V24.4274C17.5324 24.1631 19.738 23.1022 21.4214 21.4189C23.1047 19.7356 24.1656 17.5299 24.4298 15.1641H26.8332V12.8307H24.4298V12.8307ZM13.9998 22.1641C9.48484 22.1641 5.83317 18.5124 5.83317 13.9974C5.83317 9.4824 9.48484 5.83073 13.9998 5.83073C18.5148 5.83073 22.1665 9.4824 22.1665 13.9974C22.1665 18.5124 18.5148 22.1641 13.9998 22.1641Z" + fill="#8E92A1" + /> + </svg> +); diff --git a/src/shared/Icon/Icons/MagnifierZoomIn.tsx b/src/shared/Icon/Icons/MagnifierZoomIn.tsx new file mode 100644 index 00000000..574eba97 --- /dev/null +++ b/src/shared/Icon/Icons/MagnifierZoomIn.tsx @@ -0,0 +1,27 @@ +interface MaginfierZoomInProps { + className?: string; +} + +export const MaginfierZoomInIcon = ({ className }: MaginfierZoomInProps): JSX.Element => ( + <svg + width="24" + height="24" + viewBox="0 0 24 24" + fill="none" + xmlns="http://www.w3.org/2000/svg" + className={className} + > + <g clipPath="url(#clip0_4_190)"> + <path d="M15 12H12V15H9V12H6V9H9V6H12V9H15V12Z" fill="#8E92A1" /> + <path + d="M23.5605 19.9395L19.5 15.879C20.4798 14.2558 20.9985 12.396 21 10.5C21 4.71 16.2885 0 10.5 0C4.7115 0 0 4.71 0 10.5C0 16.29 4.7115 21 10.5 21C12.3962 20.9994 14.2562 20.4808 15.879 19.5L19.9395 23.5605C20.0785 23.7003 20.2437 23.8112 20.4257 23.8869C20.6077 23.9626 20.8029 24.0016 21 24.0016C21.1971 24.0016 21.3923 23.9626 21.5743 23.8869C21.7563 23.8112 21.9215 23.7003 22.0605 23.5605L23.5605 22.0605C23.6999 21.9213 23.8105 21.756 23.886 21.574C23.9615 21.3921 24.0003 21.197 24.0003 21C24.0003 20.803 23.9615 20.6079 23.886 20.426C23.8105 20.244 23.6999 20.0787 23.5605 19.9395V19.9395ZM10.5 18C8.51068 17.9998 6.60291 17.2094 5.19639 15.8026C3.78987 14.3957 2.9998 12.4878 3 10.4985C3.0002 8.50918 3.79064 6.60141 5.19745 5.19489C6.60425 3.78837 8.51218 2.9983 10.5015 2.9985C12.4908 2.9987 14.3986 3.78915 15.8051 5.19595C17.2116 6.60275 18.0017 8.51068 18.0015 10.5C18.0013 12.4893 17.2109 14.3971 15.8041 15.8036C14.3972 17.2101 12.4893 18.0002 10.5 18V18Z" + fill="#8E92A1" + /> + </g> + <defs> + <clipPath id="clip0_4_190"> + <rect width="24" height="24" fill="white" /> + </clipPath> + </defs> + </svg> +); diff --git a/src/shared/Icon/Icons/MagnifierZoomOut.tsx b/src/shared/Icon/Icons/MagnifierZoomOut.tsx new file mode 100644 index 00000000..56978cc5 --- /dev/null +++ b/src/shared/Icon/Icons/MagnifierZoomOut.tsx @@ -0,0 +1,27 @@ +interface MaginfierZoomOutProps { + className?: string; +} + +export const MaginfierZoomOutIcon = ({ className }: MaginfierZoomOutProps): JSX.Element => ( + <svg + width="24" + height="24" + viewBox="0 0 24 24" + fill="none" + xmlns="http://www.w3.org/2000/svg" + className={className} + > + <g clipPath="url(#clip0_4_194)"> + <path d="M6 9H15V12H6V9Z" fill="#8E92A1" /> + <path + d="M23.5605 19.9395L19.5 15.879C20.4798 14.2558 20.9985 12.396 21 10.5C21 4.71 16.2885 0 10.5 0C4.7115 0 0 4.71 0 10.5C0 16.29 4.7115 21 10.5 21C12.3962 20.9994 14.2562 20.4808 15.879 19.5L19.9395 23.5605C20.0785 23.7003 20.2437 23.8112 20.4257 23.8869C20.6077 23.9626 20.8029 24.0016 21 24.0016C21.1971 24.0016 21.3923 23.9626 21.5743 23.8869C21.7563 23.8112 21.9215 23.7003 22.0605 23.5605L23.5605 22.0605C23.6999 21.9213 23.8105 21.756 23.886 21.574C23.9615 21.3921 24.0003 21.197 24.0003 21C24.0003 20.803 23.9615 20.6079 23.886 20.426C23.8105 20.244 23.6999 20.0787 23.5605 19.9395V19.9395ZM10.5 18C8.51068 17.9998 6.60291 17.2094 5.19639 15.8026C3.78987 14.3957 2.9998 12.4878 3 10.4985C3.0002 8.50918 3.79064 6.60141 5.19745 5.19489C6.60425 3.78837 8.51218 2.9983 10.5015 2.9985C12.4908 2.9987 14.3986 3.78915 15.8051 5.19595C17.2116 6.60275 18.0017 8.51068 18.0015 10.5C18.0013 12.4893 17.2109 14.3971 15.8041 15.8036C14.3972 17.2101 12.4893 18.0002 10.5 18V18Z" + fill="#8E92A1" + /> + </g> + <defs> + <clipPath id="clip0_4_194"> + <rect width="24" height="24" fill="white" /> + </clipPath> + </defs> + </svg> +); diff --git a/src/types/iconTypes.ts b/src/types/iconTypes.ts index c37714cb..c125f09c 100644 --- a/src/types/iconTypes.ts +++ b/src/types/iconTypes.ts @@ -13,4 +13,7 @@ export type IconTypes = | 'page' | 'plugin' | 'close' + | 'location' + | 'magnifier-zoom-in' + | 'magnifier-zoom-out' | 'pin'; -- GitLab