Skip to content

Commit c9ba7e4

Browse files
committed
fix(PhotoCarousel): use Button component for nav arrows and add dark mode support
- Replace custom arrow buttons with Button component using iconOnly prop - Update nav button styling to match Carousel component (hover/active states) - Add dark mode support to dots using design tokens instead of hardcoded white - Improve Carousel nav button hover/active states for consistency - Add images array example and documentation to FullscreenMap stories
1 parent abf88f4 commit c9ba7e4

File tree

5 files changed

+62
-56
lines changed

5 files changed

+62
-56
lines changed

packages/ui/src/components/Carousel/Carousel.module.css

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -155,16 +155,17 @@
155155
border-radius: 50%;
156156
box-shadow: var(--ai-elevation-1-shadow);
157157
transition:
158-
background-color 0.2s ease,
159-
box-shadow 0.2s ease;
158+
background-color 0.15s ease,
159+
box-shadow 0.15s ease;
160160
}
161161

162162
.navButton:hover {
163-
opacity: 0.9;
163+
background-color: var(--ai-color-bg-secondary);
164164
}
165165

166166
.navButton:active {
167-
opacity: 1;
167+
background-color: var(--ai-color-bg-tertiary);
168+
box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.15);
168169
}
169170

170171
.navButtonPrev {

packages/ui/src/components/Map/FullscreenMap.stories.tsx

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,12 @@ const sampleLocations: LocationData[] = [
1919
description:
2020
'Award-winning Neapolitan pies in North Beach.<br/><br/>A San Francisco institution serving authentic Italian pizza with locally-sourced ingredients.',
2121
thumbnail: 'https://persistent.oaistatic.com/pizzaz/pizzaz-1.png',
22+
images: [
23+
'https://persistent.oaistatic.com/pizzaz/pizzaz-1.png',
24+
'https://persistent.oaistatic.com/pizzaz/pizzaz-2.png',
25+
'https://persistent.oaistatic.com/pizzaz/pizzaz-3.png',
26+
'https://persistent.oaistatic.com/pizzaz/pizzaz-4.png',
27+
],
2228
features: [{ icon: 'star', label: '4.8' }, { label: '$$$' }],
2329
actions: [
2430
{ label: 'Add to favorites', variant: 'primary' },
@@ -262,6 +268,11 @@ const FullscreenMapDoc: FC = () => {
262268
Fullscreen maps use native scroll wheel zoom by default (`scrollWheelZoom=true`) for the
263269
best desktop experience, while compact maps use custom pinch-to-zoom handlers.
264270
</li>
271+
<li>
272+
Add an `images` array to LocationData for multi-photo locations—the inspector
273+
automatically renders a PhotoCarousel with dots and arrows when multiple images are
274+
present, falling back to a single thumbnail otherwise.
275+
</li>
265276
</ul>
266277
</section>
267278

packages/ui/src/components/PhotoCarousel/PhotoCarousel.module.css

Lines changed: 25 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -46,42 +46,38 @@
4646
pointer-events: auto;
4747
}
4848

49-
/* Navigation Arrows */
50-
.arrowButton {
49+
/* Navigation Buttons */
50+
.navButton {
5151
position: absolute;
5252
top: 50%;
53-
transform: translateY(-50%);
5453
z-index: 3;
55-
width: 40px;
56-
height: 40px;
54+
width: 32px;
55+
height: 32px;
56+
min-width: 32px;
57+
min-height: 32px;
58+
background-color: var(--ai-color-bg-primary);
5759
border-radius: 50%;
58-
border: none;
59-
background-color: rgba(255, 255, 255, 0.9);
60-
color: var(--ai-color-text-primary);
61-
cursor: pointer;
62-
display: flex;
63-
align-items: center;
64-
justify-content: center;
65-
transition: all 0.2s ease;
66-
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
60+
box-shadow: var(--ai-elevation-1-shadow);
61+
transition:
62+
background-color 0.15s ease,
63+
box-shadow 0.15s ease;
6764
}
6865

69-
.arrowButton:hover:not(:disabled) {
70-
background-color: rgba(255, 255, 255, 1);
71-
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
66+
.navButton:hover {
67+
background-color: var(--ai-color-bg-secondary);
7268
}
7369

74-
.arrowButton:disabled {
75-
opacity: 0.4;
76-
cursor: not-allowed;
70+
.navButton:active {
71+
background-color: var(--ai-color-bg-tertiary);
72+
box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.15);
7773
}
7874

79-
.arrowPrev {
80-
left: 16px;
75+
.navButtonPrev {
76+
left: var(--ai-spacing-4);
8177
}
8278

83-
.arrowNext {
84-
right: 16px;
79+
.navButtonNext {
80+
right: var(--ai-spacing-4);
8581
}
8682

8783
/* Navigation Dots */
@@ -102,19 +98,21 @@
10298
height: 8px;
10399
border-radius: 50%;
104100
border: none;
105-
background-color: rgba(255, 255, 255, 0.5);
101+
background-color: var(--ai-color-bg-primary);
102+
opacity: 0.6;
106103
cursor: pointer;
107104
padding: 0;
108105
transition: all 0.2s ease;
106+
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
109107
}
110108

111109
.dot:hover {
112-
background-color: rgba(255, 255, 255, 0.8);
110+
opacity: 0.85;
113111
transform: scale(1.2);
114112
}
115113

116114
.dotActive {
117-
background-color: rgba(255, 255, 255, 1);
115+
opacity: 1;
118116
width: 10px;
119117
height: 10px;
120118
}

packages/ui/src/components/PhotoCarousel/PhotoCarousel.module.css.d.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@ declare const styles: {
55
readonly emblaSlide: string;
66
readonly photo: string;
77
readonly overlayContainer: string;
8-
readonly arrowButton: string;
9-
readonly arrowPrev: string;
10-
readonly arrowNext: string;
8+
readonly navButton: string;
9+
readonly navButtonPrev: string;
10+
readonly navButtonNext: string;
1111
readonly dotsContainer: string;
1212
readonly dot: string;
1313
readonly dotActive: string;

packages/ui/src/components/PhotoCarousel/PhotoCarousel.tsx

Lines changed: 18 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import React, { useState, useCallback, useEffect } from 'react';
22
import useEmblaCarousel from 'embla-carousel-react';
33
import { Overlay } from '../Overlay';
4-
import { Icon } from '../Icon';
4+
import { Button } from '../Button';
55
import { cn } from '../../utils/cn';
66
import styles from './PhotoCarousel.module.css';
77

@@ -171,27 +171,23 @@ export const PhotoCarousel: React.FC<PhotoCarouselProps> = ({
171171
{topOverlay && <div className={styles.overlayContainer}>{topOverlay}</div>}
172172

173173
{/* Navigation Arrows */}
174-
{showArrows && images.length > 1 && (
175-
<>
176-
<button
177-
className={cn(styles.arrowButton, styles.arrowPrev)}
178-
onClick={scrollPrev}
179-
disabled={!hasPrev}
180-
aria-label="Previous photo"
181-
type="button"
182-
>
183-
<Icon name="chevron-left-lg" size={24} />
184-
</button>
185-
<button
186-
className={cn(styles.arrowButton, styles.arrowNext)}
187-
onClick={scrollNext}
188-
disabled={!hasNext}
189-
aria-label="Next photo"
190-
type="button"
191-
>
192-
<Icon name="chevron-right-lg" size={24} />
193-
</button>
194-
</>
174+
{showArrows && images.length > 1 && hasPrev && (
175+
<Button
176+
variant="ghost"
177+
iconOnly="chevron-left-md"
178+
onClick={scrollPrev}
179+
aria-label="Previous photo"
180+
className={cn(styles.navButton, styles.navButtonPrev)}
181+
/>
182+
)}
183+
{showArrows && images.length > 1 && hasNext && (
184+
<Button
185+
variant="ghost"
186+
iconOnly="chevron-right-md"
187+
onClick={scrollNext}
188+
aria-label="Next photo"
189+
className={cn(styles.navButton, styles.navButtonNext)}
190+
/>
195191
)}
196192

197193
{/* Navigation Dots */}

0 commit comments

Comments
 (0)