Skip to content

Commit 6bc4fe4

Browse files
committed
feat(Map): add top-level autoExpandOnCarouselClick prop for better DX
Promotes autoExpandOnCarouselClick to a top-level Map prop for improved discoverability and cleaner API. Better Developer Experience: Before (nested): <Map compactMapProps={{ autoExpandOnCarouselClick: true }} /> After (top-level): <Map autoExpandOnCarouselClick={true} /> Benefits: - More discoverable (shows in autocomplete immediately) - Simpler API (no nested objects for common features) - Intuitive (primary interactions should be top-level) - Consistent (matches other boolean flags like showPopup, loading, error) Implementation: - Added autoExpandOnCarouselClick to MapProps interface with JSDoc - Default: false (backward compatible) - Passes directly to CompactMap (not via compactMapProps) - Excluded from compactMapProps type to prevent duplication Documentation: - Updated Maps story Advanced Features section - Added code example showing top-level usage - Clarified this is a Map component feature (requires orchestrator)
1 parent f6959f0 commit 6bc4fe4

File tree

2 files changed

+36
-6
lines changed

2 files changed

+36
-6
lines changed

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

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,18 @@ export interface MapProps extends Omit<MapViewProps, 'className' | 'style'> {
1414
*/
1515
onToggleFullscreen?: (isFullscreen: boolean) => void;
1616

17+
/**
18+
* Auto-expand to fullscreen when user clicks a carousel card.
19+
* When true, selecting a location from the carousel automatically triggers fullscreen
20+
* mode with the Inspector panel open.
21+
* @default false
22+
*/
23+
autoExpandOnCarouselClick?: boolean;
24+
1725
/**
1826
* Props passed to CompactMap when not in fullscreen
1927
*/
20-
compactMapProps?: Omit<CompactMapProps, keyof MapViewProps | 'onExpand'>;
28+
compactMapProps?: Omit<CompactMapProps, keyof MapViewProps | 'onExpand' | 'autoExpandOnCarouselClick'>;
2129

2230
/**
2331
* Props passed to FullscreenMap when in fullscreen
@@ -62,6 +70,7 @@ export const Map: React.FC<MapProps> = ({
6270
isInspectorOpen,
6371
scrollWheelZoom,
6472
showPopup,
73+
autoExpandOnCarouselClick = false,
6574
loading = false,
6675
error = false,
6776
isFullscreen: controlledIsFullscreen,
@@ -129,7 +138,12 @@ export const Map: React.FC<MapProps> = ({
129138
<>
130139
{/* Compact Map */}
131140
{!isFullscreen && (
132-
<CompactMap {...commonMapProps} onExpand={handleExpand} {...compactMapProps} />
141+
<CompactMap
142+
{...commonMapProps}
143+
onExpand={handleExpand}
144+
autoExpandOnCarouselClick={autoExpandOnCarouselClick}
145+
{...compactMapProps}
146+
/>
133147
)}
134148

135149
{/* Fullscreen Map */}

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

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -985,13 +985,29 @@ const handleMapToggle = (fullscreen: boolean) => {
985985
Auto-Expand on Carousel Click
986986
</h3>
987987
<p style={{ margin: '0 0 12px', fontSize: '14px', color: 'var(--ai-color-text-secondary)' }}>
988-
Set <code>autoExpandOnCarouselClick={'{true}'}</code> on <code>CompactMap</code> to
989-
automatically expand to fullscreen when users click a carousel card. This provides faster
990-
access to detailed location information (one click instead of two).
988+
Set <code>autoExpandOnCarouselClick={'{true}'}</code> on the <code>Map</code> component
989+
(top-level prop) to automatically expand to fullscreen when users click a carousel card.
990+
This provides faster access to detailed location information (one click instead of two).
991991
</p>
992-
<div style={{ fontSize: '13px', color: 'var(--ai-color-text-secondary)' }}>
992+
<div style={{ fontSize: '13px', color: 'var(--ai-color-text-secondary)', marginBottom: '12px' }}>
993993
<strong>Default:</strong> <code>false</code> (users must click expand button manually)
994994
</div>
995+
<pre
996+
style={{
997+
margin: 0,
998+
padding: '12px',
999+
background: 'var(--ai-color-bg-tertiary)',
1000+
borderRadius: '6px',
1001+
fontSize: '12px',
1002+
lineHeight: '1.5',
1003+
fontFamily: 'Monaco, Menlo, monospace',
1004+
}}
1005+
>
1006+
<code>{`<Map
1007+
locations={locations}
1008+
autoExpandOnCarouselClick={true}
1009+
/>`}</code>
1010+
</pre>
9951011
</div>
9961012
</div>
9971013
</section>

0 commit comments

Comments
 (0)