diff --git a/ui/src/design-system/components/image-carousel/image-carousel.tsx b/ui/src/design-system/components/image-carousel/image-carousel.tsx index 56552ed89..15d751047 100644 --- a/ui/src/design-system/components/image-carousel/image-carousel.tsx +++ b/ui/src/design-system/components/image-carousel/image-carousel.tsx @@ -5,58 +5,66 @@ import { IconButtonTheme, } from 'design-system/components/icon-button/icon-button' import { Icon, IconTheme, IconType } from 'design-system/components/icon/icon' -import { useEffect, useRef, useState } from 'react' +import { ReactNode, useEffect, useRef, useState } from 'react' import styles from './image-carousel.module.scss' import { CarouselTheme } from './types' import { getImageBoxStyles, getPlaceholderStyles } from './utils' +import { Link } from 'react-router-dom' interface ImageCarouselProps { + autoPlay?: boolean images: { src: string alt?: string }[] - theme?: CarouselTheme - autoPlay?: boolean size?: { width: string | number ratio: number } + theme?: CarouselTheme + to?: string } export const ImageCarousel = ({ - images, - theme = CarouselTheme.Default, autoPlay, + images, size, + theme = CarouselTheme.Default, + to, }: ImageCarouselProps) => { if (images.length <= 1) { - return + return ( + + ) } return ( ) } const BasicImageCarousel = ({ image, - theme, size, + theme, + to, }: { image?: { src: string alt?: string } - theme: CarouselTheme size?: { width: string | number ratio: number } + theme: CarouselTheme + to?: string }) => (
-
- {image ? ( - {image.alt} - ) : ( - - )} -
+ +
+ {image ? ( + {image.alt} + ) : ( + + )} +
+
) @@ -84,10 +94,11 @@ const BasicImageCarousel = ({ const DURATION = 10000 // Change image every 10 second const MultiImageCarousel = ({ - images, - theme, autoPlay, + images, size, + theme, + to, }: ImageCarouselProps) => { const [paused, setPaused] = useState(false) const [slideIndex, setSlideIndex] = useState(0) @@ -154,35 +165,41 @@ const MultiImageCarousel = ({ onClick={() => showPrev(slideIndex)} />
-
-
- {images.map((image, index) => { - const render = - index === 0 || // Always render first slide - index === images.length - 1 || // Always render last image - Math.abs(index - slideIndex) <= 1 // Render nearby slides - - if (!render) { - return - } - - return ( -
- {image.alt} -
- ) - })} -
+ +
+
+ {images.map((image, index) => { + const render = + index === 0 || // Always render first slide + index === images.length - 1 || // Always render last image + Math.abs(index - slideIndex) <= 1 // Render nearby slides + + if (!render) { + return + } + + return ( +
+ {image.alt} +
+ ) + })} +
+
) } + +const ConditionalLink = ({ + to, + children, +}: { + to?: string + children: ReactNode +}) => { + if (!to) { + return <>{children} + } + + return {children} +} diff --git a/ui/src/design-system/components/table/image-table-cell/image-table-cell.tsx b/ui/src/design-system/components/table/image-table-cell/image-table-cell.tsx index d7929fd6e..3f9fdd87c 100644 --- a/ui/src/design-system/components/table/image-table-cell/image-table-cell.tsx +++ b/ui/src/design-system/components/table/image-table-cell/image-table-cell.tsx @@ -3,12 +3,13 @@ import { ImageCellTheme } from '../types' import styles from './image-table-cell.module.scss' interface ImageTableCellProps { + autoPlay?: boolean images: { src: string alt?: string }[] theme?: ImageCellTheme - autoPlay?: boolean + to?: string } export const ImageTableCell = (props: ImageTableCellProps) => ( diff --git a/ui/src/pages/collection-details/capture-columns.tsx b/ui/src/pages/collection-details/capture-columns.tsx index be5bb6157..923645d14 100644 --- a/ui/src/pages/collection-details/capture-columns.tsx +++ b/ui/src/pages/collection-details/capture-columns.tsx @@ -20,24 +20,22 @@ export const columns: (projectId: string) => TableColumn[] = ( name: translate(STRING.FIELD_LABEL_THUMBNAIL), renderCell: (item: Capture, rowIndex: number) => { const isOddRow = rowIndex % 2 == 0 + const detailsRoute = getAppRoute({ + to: APP_ROUTES.SESSION_DETAILS({ + projectId: projectId, + sessionId: item.sessionId, + }), + filters: { + capture: item.id, + }, + }) return ( - - - + ) }, }, diff --git a/ui/src/pages/occurrences/occurrence-columns.tsx b/ui/src/pages/occurrences/occurrence-columns.tsx index 4c0ba9963..cd344bdca 100644 --- a/ui/src/pages/occurrences/occurrence-columns.tsx +++ b/ui/src/pages/occurrences/occurrence-columns.tsx @@ -33,11 +33,19 @@ export const columns: (projectId: string) => TableColumn[] = ( }, renderCell: (item: Occurrence, rowIndex: number) => { const isOddRow = rowIndex % 2 == 0 + const detailsRoute = getAppRoute({ + to: APP_ROUTES.OCCURRENCE_DETAILS({ + projectId, + occurrenceId: item.id, + }), + keepSearchParams: true, + }) return ( ) }, diff --git a/ui/src/pages/sessions/session-columns.tsx b/ui/src/pages/sessions/session-columns.tsx index 0a5f40aaf..94e8f4f35 100644 --- a/ui/src/pages/sessions/session-columns.tsx +++ b/ui/src/pages/sessions/session-columns.tsx @@ -24,10 +24,12 @@ export const columns: (projectId: string) => TableColumn[] = ( }, renderCell: (item: Session, rowIndex: number) => { const isOddRow = rowIndex % 2 == 0 + const detailsRoute = APP_ROUTES.SESSION_DETAILS({ projectId, sessionId: item.id }) return ( ) diff --git a/ui/src/pages/species/species-columns.tsx b/ui/src/pages/species/species-columns.tsx index fe6e103ca..ca781513a 100644 --- a/ui/src/pages/species/species-columns.tsx +++ b/ui/src/pages/species/species-columns.tsx @@ -24,11 +24,16 @@ export const columns: (projectId: string) => TableColumn[] = ( }, renderCell: (item: Species, rowIndex: number) => { const isOddRow = rowIndex % 2 == 0 + const detailsRoute = getAppRoute({ + to: APP_ROUTES.SPECIES_DETAILS({ projectId, speciesId: item.id }), + keepSearchParams: true, + }) return ( ) },