Skip to content

Commit

Permalink
new design for view gallery and images
Browse files Browse the repository at this point in the history
  • Loading branch information
diego-morales-flores-1996 committed Jun 14, 2024
1 parent 4c69db4 commit 15c0e9f
Show file tree
Hide file tree
Showing 10 changed files with 194 additions and 68 deletions.
3 changes: 3 additions & 0 deletions src/assets/icons/image-icon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 7 additions & 1 deletion src/components/elements/Button/Button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ export interface IButtonProps extends Omit<HTMLProps<HTMLElement>, "as"> {
| "white-toggle"
| "white-border"
| "orange"
| "transparent-toggle";
| "transparent-toggle"
| "white-button-map";
fullWidth?: boolean;
shallow?: boolean;
}
Expand Down Expand Up @@ -151,6 +152,11 @@ const Button: FC<IButtonProps> = props => {
container: "group bg-transparent px-3 py-1 rounded",
span: "text-14-light text-darkCustom-100"
};
case "white-button-map":
return {
container: "h-fit rounded-lg bg-white px-4 py-2 shadow hover:bg-neutral-200",
span: "flex items-center gap-2"
};
default:
return { container: "", span: "" };
}
Expand Down
6 changes: 4 additions & 2 deletions src/components/elements/Map-mapbox/Map.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import type { TooltipType } from "./Map.d";
import CheckPolygonControl from "./MapControls/CheckPolygonControl";
import EditControl from "./MapControls/EditControl";
import { FilterControl } from "./MapControls/FilterControl";
import ImageCheck from "./MapControls/ImageCheck";
import ImageControl from "./MapControls/ImageControl";
import PolygonCheck from "./MapControls/PolygonCheck";
import { StyleControl } from "./MapControls/StyleControl";
Expand Down Expand Up @@ -274,8 +275,9 @@ export const MapContainer = ({
<Icon name={IconNames.IC_EARTH_MAP} className="h-5 w-5 lg:h-6 lg:w-6" />
</button>
</ControlGroup>
<ControlGroup position="bottom-right" className="bottom-8">
<ViewImageCarousel viewImages={viewImages} setViewImages={setViewImages} />
<ControlGroup position="bottom-right" className="bottom-8 flex flex-row gap-2">
<ImageCheck />
<ViewImageCarousel />
</ControlGroup>
</When>
<When condition={showLegend}>
Expand Down
23 changes: 23 additions & 0 deletions src/components/elements/Map-mapbox/MapControls/ImageCheck.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { useT } from "@transifex/react";
import { useState } from "react";

import Button from "../../Button/Button";
import Checkbox from "../../Inputs/Checkbox/Checkbox";
import Text from "../../Text/Text";
import { MiniGallery } from "./MiniGallery";

const ImageCheck = () => {
const t = useT();
const [viewImages, setViewImages] = useState(false);
return (
<div className="relarive">
<MiniGallery viewImages={viewImages} setViewImages={setViewImages} />
<Button variant="white-button-map" className="flex items-center gap-2" onClick={() => setViewImages(!viewImages)}>
<Checkbox name={""} className="leading-3" checked={viewImages} />
<Text variant="text-12-bold"> {t("Images")}</Text>
</Button>
</div>
);
};

export default ImageCheck;
63 changes: 63 additions & 0 deletions src/components/elements/Map-mapbox/MapControls/MiniGallery.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
import { useT } from "@transifex/react";
import classNames from "classnames";
import React, { Dispatch, SetStateAction } from "react";
import { Navigation } from "swiper";

import Carousel from "@/components/extensive/Carousel/Carousel";
import Icon from "@/components/extensive/Icon/Icon";
import { IconNames } from "@/components/extensive/Icon/Icon";
import { dataImageGallery } from "@/components/extensive/Modal/ModalContent/MockedData";
import ModalImageGallery from "@/components/extensive/Modal/ModalImageGallery";
import { useModalContext } from "@/context/modal.provider";

import ImageWithPlaceholder from "../../ImageWithPlaceholder/ImageWithPlaceholder";
import Text from "../../Text/Text";

export const MiniGallery = ({
viewImages,
setViewImages
}: {
viewImages: boolean;
setViewImages: Dispatch<SetStateAction<boolean>>;
}) => {
const { openModal, closeModal } = useModalContext();

const openFormModalHandlerImageGallery = () => {
openModal(<ModalImageGallery onClose={closeModal} tabItems={dataImageGallery} title={""} />);
};
const t = useT();
return (
<div
className={classNames("absolute right-1/2 bottom-full h-[250px] w-[200px] rounded-lg bg-white p-2", {
hidden: !viewImages
})}
>
<div className="relative h-[calc(100%_-_48px)]">
<Carousel
className="test mb-2 h-full"
swiperClassName="h-full"
swiperSlideClassName="h-full"
items={dataImageGallery[0].images}
carouselItem={item => (
<ImageWithPlaceholder className="h-full" alt={t("Image not available")} imageUrl={item.src} />
)}
modules={[Navigation]}
slidesPerView={1}
spaceBetween={10}
hidePaginationBullet
smallSwiperButtons
/>
<button
onClick={() => setViewImages(false)}
className="absolute right-1 top-1 z-10 rounded bg-grey-750 p-1 drop-shadow-md"
>
<Icon name={IconNames.CLEAR} className="h-4 w-4 text-darkCustom-100" />
</button>
</div>
<button onClick={openFormModalHandlerImageGallery}>
<Text variant="text-12-bold">TerraMatch Sample</Text>
<Text variant="text-12-light"> December 29, 2023</Text>
</button>
</div>
);
};
Original file line number Diff line number Diff line change
@@ -1,23 +1,14 @@
import { t } from "@transifex/native";
import classNames from "classnames";
import { Dispatch, SetStateAction } from "react";
import { Navigation } from "swiper";

import Carousel from "@/components/extensive/Carousel/Carousel";
import Icon, { IconNames } from "@/components/extensive/Icon/Icon";
import { dataImageGallery } from "@/components/extensive/Modal/ModalContent/MockedData";
import ModalImageGallery from "@/components/extensive/Modal/ModalImageGallery";
import { useModalContext } from "@/context/modal.provider";

import Button from "../../Button/Button";
import Text from "../../Text/Text";

const ViewImageCarousel = ({
viewImages,
setViewImages
}: {
viewImages: boolean;
setViewImages: Dispatch<SetStateAction<boolean>>;
}) => {
const ViewImageCarousel = () => {
const { openModal, closeModal } = useModalContext();

const openFormModalHandlerImageGallery = () => {
Expand All @@ -26,42 +17,10 @@ const ViewImageCarousel = ({

return (
<div className="relative">
<div
className={classNames("absolute right-1/2 bottom-0 h-[250px] w-[200px] rounded-lg bg-white p-2", {
hidden: !viewImages
})}
>
<div className="relative h-[calc(100%_-_48px)]">
<Carousel
className="test mb-2 h-full"
swiperClassName="h-full"
swiperSlideClassName="h-full"
items={dataImageGallery[0].images}
carouselItem={item => <img className="h-full" alt="" src={item.src} />}
modules={[Navigation]}
slidesPerView={1}
spaceBetween={10}
hidePaginationBullet
smallSwiperButtons
/>
<button
onClick={() => setViewImages(false)}
className="absolute right-1 top-1 z-10 rounded bg-grey-750 p-1 drop-shadow-md"
>
<Icon name={IconNames.CLEAR} className="h-4 w-4 text-darkCustom-100" />
</button>
</div>
<button onClick={openFormModalHandlerImageGallery}>
<Text variant="text-12-bold">TerraMatch Sample</Text>
<Text variant="text-12-light"> December 29, 2023</Text>
</button>
</div>
<button
className="text-12-bold h-fit rounded-lg bg-white px-5 py-2 shadow hover:bg-neutral-200"
onClick={() => setViewImages(!viewImages)}
>
{t("View Images")}
</button>
<Button variant="white-button-map" className="flex items-center gap-2" onClick={openFormModalHandlerImageGallery}>
<Icon name={IconNames.IMAGE_ICON} className="h-4 w-4" />
<Text variant="text-12-bold"> {t("View Gallery")}</Text>
</Button>
</div>
);
};
Expand Down
3 changes: 2 additions & 1 deletion src/components/extensive/Icon/Icon.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,8 @@ export enum IconNames {
IC_DRAFT = "ic_draft",
IC_NEEDS_MORE_INFORMATION = "ic_needs-more-information",
IC_SUBMITTED = "ic_submitted",
IC_ARROW_COLLAPSE = "ic-arrow-collapse"
IC_ARROW_COLLAPSE = "ic-arrow-collapse",
IMAGE_ICON = "image-icon"
}

export interface IconProps {
Expand Down
60 changes: 48 additions & 12 deletions src/components/extensive/Modal/ModalContent/MockedData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,27 +23,45 @@ export const dataImageGallery = [
images: [
{
id: "1",
src: "/Images/image-modal-main.png"
src: "/Images/image-modal-main.png",
title: "TerraMatch Sample",
dateCreated: "December 29, 2024",
geoTag: "Not Geo-Referenced"
},
{
id: "2",
src: "/Images/image-modal-1.png"
src: "/Images/image-modal-1.png",
title: "TerraMatch Sample",
dateCreated: "December 29, 2024",
geoTag: "Not Geo-Referenced"
},
{
id: "3",
src: "/Images/image-modal-2.png"
src: "/Images/image-modal-2.png",
title: "TerraMatch Sample",
dateCreated: "December 29, 2024",
geoTag: "Not Geo-Referenced"
},
{
id: "4",
src: "/Images/image-modal-3.png"
src: "/Images/image-modal-3.png",
title: "TerraMatch Sample",
dateCreated: "December 29, 2024",
geoTag: "Not Geo-Referenced"
},
{
id: "5",
src: "/Images/image-modal-4.png"
src: "/Images/image-modal-4.png",
title: "TerraMatch Sample",
dateCreated: "December 29, 2024",
geoTag: "Not Geo-Referenced"
},
{
id: "6",
src: "/Images/image-modal-5.png"
src: "/Images/image-modal-5.png",
title: "TerraMatch Sample",
dateCreated: "December 29, 2024",
geoTag: "Not Geo-Referenced"
}
]
},
Expand All @@ -53,27 +71,45 @@ export const dataImageGallery = [
images: [
{
id: "1",
src: "/Images/image-modal-main.png"
src: "/Images/image-modal-main.png",
title: "TerraMatch Sample",
dateCreated: "December 29, 2024",
geoTag: "Not Geo-Referenced"
},
{
id: "2",
src: "/Images/image-modal-1.png"
src: "/Images/image-modal-1.png",
title: "TerraMatch Sample",
dateCreated: "December 29, 2024",
geoTag: "Not Geo-Referenced"
},
{
id: "3",
src: "/Images/image-modal-2.png"
src: "/Images/image-modal-2.png",
title: "TerraMatch Sample",
dateCreated: "December 29, 2024",
geoTag: "Not Geo-Referenced"
},
{
id: "4",
src: "/Images/image-modal-3.png"
src: "/Images/image-modal-3.png",
title: "TerraMatch Sample",
dateCreated: "December 29, 2024",
geoTag: "Not Geo-Referenced"
},
{
id: "5",
src: "/Images/image-modal-4.png"
src: "/Images/image-modal-4.png",
title: "TerraMatch Sample",
dateCreated: "December 29, 2024",
geoTag: "Not Geo-Referenced"
},
{
id: "6",
src: "/Images/image-modal-5.png"
src: "/Images/image-modal-5.png",
title: "TerraMatch Sample",
dateCreated: "December 29, 2024",
geoTag: "Not Geo-Referenced"
}
]
}
Expand Down
36 changes: 32 additions & 4 deletions src/components/extensive/Modal/ModalImageGallery.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ import { ModalBaseImageGallery } from "./ModalsBases";
export interface ImageItem {
id: string;
src: string;
title: string;
dateCreated: string;
geoTag: string;
}

export interface TabImagesItem {
Expand Down Expand Up @@ -87,16 +90,41 @@ const ModalImageGallery: FC<ModalImageGalleryProps> = ({
setSelectedImage={setSelectedImage}
carouselItem={item => (
<div className="relative h-full px-24">
<div className="absolute left-[calc(50%_-_32px)] bottom-[24px] z-10 flex items-center justify-center rounded-xl bg-darkCustom py-[5px] px-[8px]">
<Text variant="text-13" className="text-white">
{selectedImage + 1} {t("of")} {tabItems.find(tab => tab.id === selectedTab)?.images.length}
<div className="absolute left-[24px] top-[24px] z-10 flex translate-x-[75%] flex-col items-center justify-center gap-[2px] rounded-xl border border-white bg-blueCustom-200 p-3">
<Text variant="text-12-bold" className="text-black">
{
tabItems
.find(tab => tab.id === selectedTab)
?.images.find((_, index: number) => index === selectedImage)?.title
}
</Text>
<Text variant="text-12-light" className="text-black">
{
tabItems
.find(tab => tab.id === selectedTab)
?.images.find((_, index: number) => index === selectedImage)?.dateCreated
}
</Text>
</div>
<div className="absolute right-[24px] top-[24px] z-10 flex translate-x-[-75%] items-center justify-center rounded-xl bg-red-100 py-[2px] px-3">
<Text variant="text-12-semibold" className="text-red-200">
{
tabItems
.find(tab => tab.id === selectedTab)
?.images.find((_, index: number) => index === selectedImage)?.geoTag
}
</Text>
</div>
<ImageWithPlaceholder
className="h-full rounded-xl bg-primary-200"
alt={t("Image not available")}
imageUrl={item.src}
></ImageWithPlaceholder>
/>
<div className="absolute left-[calc(50%_-_32px)] bottom-[24px] z-10 flex items-center justify-center rounded-xl bg-darkCustom py-[5px] px-[8px]">
<Text variant="text-13" className="text-white">
{selectedImage + 1} of {tabItems.find(tab => tab.id === selectedTab)?.images.length}
</Text>
</div>
</div>
)}
items={tabItems.find(tab => tab.id === selectedTab)?.images ?? []}
Expand Down
7 changes: 6 additions & 1 deletion tailwind.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ module.exports = {
700: "#092C3C",
600: "#33525c",
250: "#11093C",
200: "#E6E9EC",
100: "#cfe6f4",
50: "#f1fafd",
10: "#eaf7fc"
Expand Down Expand Up @@ -172,7 +173,11 @@ module.exports = {
DEFAULT: "#FCFBE8",
500: "#F3EFB0"
},
red: "#FF6464"
red: {
DEFAULT: "#FF6464",
100: "#CBC8D2",
200: "#E42222"
}
},
boxShadow: {
DEFAULT: "0px 4px 16px rgba(0, 0, 0, 0.12)",
Expand Down

0 comments on commit 15c0e9f

Please sign in to comment.