Skip to content

Commit d834190

Browse files
committed
refactor(Map): rename LocationCard to MapPlaceCard with variant system
Major refactoring to rename LocationCard to MapPlaceCard and introduce a variant system for different visual contexts. This is a breaking change that improves component flexibility and naming consistency. Breaking Changes: - LocationCard → MapPlaceCard (component, props, exports) - LocationCardProps → MapPlaceCardProps - New: MapPlaceCardVariant type ('carousel' | 'list') Component Changes: - Added variant prop: 'carousel' (subtle) or 'list' (prominent) - Simplified component structure (~700 lines removed) - Updated all internal usage (LocationCarousel, MapSidebar) Files Renamed: - LocationCard.tsx → MapPlaceCard.tsx - LocationCard.module.css → MapPlaceCard.module.css - LocationCard.stories.tsx → MapPlaceCard.stories.tsx - LocationCard.test.tsx → MapPlaceCard.test.tsx Documentation Updates: - Maps.stories.tsx: Updated cross-references - useErrorState.ts: Updated comment - All exports updated in index.ts files Test Results: - ✅ All 697 tests passing (48 MapPlaceCard tests) - ✅ Linter passing - ✅ Build successful (bundle 1.4KB smaller) Migration Guide: // Before import { LocationCard } from '@ainativekit/ui'; // After import { MapPlaceCard } from '@ainativekit/ui'; <MapPlaceCard variant="carousel" {...props} />
1 parent ed01de8 commit d834190

File tree

12 files changed

+155
-216
lines changed

12 files changed

+155
-216
lines changed

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import React, { useRef, useEffect, useState } from 'react';
22
import type { EmblaCarouselType } from 'embla-carousel';
33
import { Carousel } from '../Carousel';
4-
import { LocationCard } from './LocationCard';
4+
import { MapPlaceCard } from './MapPlaceCard';
55
import { cn } from '../../utils/cn';
66
import type { LocationData } from './types';
77
import styles from './LocationCarousel.module.css';
@@ -131,7 +131,7 @@ export const LocationCarousel: React.FC<LocationCarouselProps> = ({
131131
>
132132
{Array.from({ length: loadingCardCount }).map((_, i) => (
133133
<div key={i} className={styles.cardWrapper}>
134-
<LocationCard loading />
134+
<MapPlaceCard loading />
135135
</div>
136136
))}
137137
</Carousel>
@@ -196,7 +196,7 @@ export const LocationCarousel: React.FC<LocationCarouselProps> = ({
196196
>
197197
{locations.map((location) => (
198198
<div key={location.id} className={styles.cardWrapper} data-location-id={location.id}>
199-
<LocationCard
199+
<MapPlaceCard
200200
image={location.thumbnail}
201201
title={location.name}
202202
subtitle={location.subtitle}

packages/ui/src/components/Map/LocationCard.module.css renamed to packages/ui/src/components/Map/MapPlaceCard.module.css

Lines changed: 31 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
/* LocationCard Container */
2-
.locationCard {
1+
/* MapPlaceCard Container */
2+
.mapPlaceCard {
33
position: relative;
44
display: flex;
55
align-items: center;
@@ -12,28 +12,52 @@
1212
user-select: none;
1313
transition:
1414
background-color 0.2s ease,
15-
box-shadow 0.2s ease;
15+
box-shadow 0.2s ease,
16+
border-radius 0.2s ease;
1617
min-width: 280px;
1718
max-width: 330px;
1819
}
1920

20-
.locationCard:hover {
21+
.mapPlaceCard:hover {
2122
background-color: var(--ai-color-bg-tertiary);
2223
}
2324

24-
.locationCard:focus-visible {
25+
.mapPlaceCard:focus-visible {
2526
outline: 2px solid var(--ai-color-brand-primary);
2627
outline-offset: 2px;
2728
}
2829

29-
/* Selected State */
30+
/* Selected State - Carousel variant */
3031
.selected,
31-
.locationCard.selected {
32+
.mapPlaceCard.selected {
3233
background-color: var(--ai-color-bg-tertiary);
3334
border-color: var(--ai-color-brand-primary);
3435
border-width: 2px;
3536
}
3637

38+
/* List Variant */
39+
.variantList {
40+
/* Base class for variant detection - actual styling in compound selectors */
41+
position: relative;
42+
}
43+
44+
/* List Variant - Remove border, rectangle by default, rounded on hover/selected */
45+
.mapPlaceCard.variantList {
46+
border: none;
47+
border-radius: 0;
48+
}
49+
50+
.mapPlaceCard.variantList.selected {
51+
background-color: var(--ai-color-bg-secondary);
52+
border: none;
53+
border-radius: var(--ai-radius-xl);
54+
}
55+
56+
.mapPlaceCard.variantList:hover {
57+
background-color: var(--ai-color-bg-tertiary);
58+
border-radius: var(--ai-radius-xl);
59+
}
60+
3761
/* Loading State */
3862
.loadingCard {
3963
cursor: default;

packages/ui/src/components/Map/LocationCard.module.css.d.ts renamed to packages/ui/src/components/Map/MapPlaceCard.module.css.d.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
declare const styles: {
2-
readonly locationCard: string;
2+
readonly mapPlaceCard: string;
33
readonly selected: string;
4+
readonly variantList: string;
45
readonly loadingCard: string;
56
readonly errorCard: string;
67
readonly errorContainer: string;

packages/ui/src/components/Map/LocationCard.stories.tsx renamed to packages/ui/src/components/Map/MapPlaceCard.stories.tsx

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import React, { useState } from 'react';
22
import type { Meta, StoryObj } from '@storybook/react';
3-
import { LocationCard } from './LocationCard';
3+
import { MapPlaceCard } from './MapPlaceCard';
44

5-
const meta: Meta<typeof LocationCard> = {
5+
const meta: Meta<typeof MapPlaceCard> = {
66
title: 'Composed Components/Cards/Location Cards',
7-
component: LocationCard,
7+
component: MapPlaceCard,
88
parameters: {
99
layout: 'padded',
1010
},
@@ -39,13 +39,13 @@ const SAMPLE_LOCATIONS = [
3939
];
4040

4141
// Main unified showcase component
42-
const LocationCardShowcase: React.FC = () => {
42+
const MapPlaceCardShowcase: React.FC = () => {
4343
const [selectedId, setSelectedId] = useState<string>('1');
4444
const [retryCount, setRetryCount] = useState(0);
4545

4646
return (
4747
<div style={{ padding: '24px' }}>
48-
<h1 style={{ marginBottom: '32px' }}>LocationCard System</h1>
48+
<h1 style={{ marginBottom: '32px' }}>MapPlaceCard System</h1>
4949

5050
{/* Overview */}
5151
<section style={{ marginBottom: '64px' }}>
@@ -65,7 +65,7 @@ const LocationCardShowcase: React.FC = () => {
6565
{/* Variants Gallery */}
6666
<section style={{ marginBottom: '64px' }}>
6767
<header style={{ marginBottom: '24px' }}>
68-
<h2 style={{ marginBottom: '8px' }}>LocationCard Variants</h2>
68+
<h2 style={{ marginBottom: '8px' }}>MapPlaceCard Variants</h2>
6969
<p style={{ color: 'var(--ai-color-text-secondary)', margin: 0, fontSize: '14px' }}>
7070
Different content configurations and states
7171
</p>
@@ -76,17 +76,17 @@ const LocationCardShowcase: React.FC = () => {
7676
Standard Locations
7777
</h3>
7878
<div style={{ display: 'flex', flexDirection: 'column', gap: '16px', maxWidth: '600px' }}>
79-
<LocationCard
79+
<MapPlaceCard
8080
{...SAMPLE_LOCATIONS[0]}
8181
selected={selectedId === '1'}
8282
onClick={() => setSelectedId('1')}
8383
/>
84-
<LocationCard
84+
<MapPlaceCard
8585
{...SAMPLE_LOCATIONS[1]}
8686
selected={selectedId === '2'}
8787
onClick={() => setSelectedId('2')}
8888
/>
89-
<LocationCard
89+
<MapPlaceCard
9090
{...SAMPLE_LOCATIONS[2]}
9191
selected={selectedId === '3'}
9292
onClick={() => setSelectedId('3')}
@@ -99,12 +99,12 @@ const LocationCardShowcase: React.FC = () => {
9999
Minimal Content
100100
</h3>
101101
<div style={{ display: 'flex', flexDirection: 'column', gap: '16px', maxWidth: '600px' }}>
102-
<LocationCard
102+
<MapPlaceCard
103103
image={SAMPLE_LOCATIONS[0].image}
104104
title="Simple Location"
105105
onClick={() => console.log('Clicked')}
106106
/>
107-
<LocationCard
107+
<MapPlaceCard
108108
image={SAMPLE_LOCATIONS[1].image}
109109
title="With Subtitle Only"
110110
subtitle="Description text"
@@ -118,9 +118,9 @@ const LocationCardShowcase: React.FC = () => {
118118
With Badges & Chips
119119
</h3>
120120
<div style={{ display: 'flex', flexDirection: 'column', gap: '16px', maxWidth: '600px' }}>
121-
<LocationCard {...SAMPLE_LOCATIONS[0]} badge="New" badgeVariant="success" />
122-
<LocationCard {...SAMPLE_LOCATIONS[1]} badge="Popular" badgeVariant="filled" />
123-
<LocationCard {...SAMPLE_LOCATIONS[2]} badge={5} badgeVariant="default" />
121+
<MapPlaceCard {...SAMPLE_LOCATIONS[0]} badge="New" badgeVariant="success" />
122+
<MapPlaceCard {...SAMPLE_LOCATIONS[1]} badge="Popular" badgeVariant="filled" />
123+
<MapPlaceCard {...SAMPLE_LOCATIONS[2]} badge={5} badgeVariant="default" />
124124
</div>
125125
</div>
126126
</section>
@@ -146,7 +146,7 @@ const LocationCardShowcase: React.FC = () => {
146146
>
147147
Loading
148148
</h3>
149-
<LocationCard
149+
<MapPlaceCard
150150
image={SAMPLE_LOCATIONS[0].image}
151151
title="Loading Location"
152152
loading={true}
@@ -164,7 +164,7 @@ const LocationCardShowcase: React.FC = () => {
164164
>
165165
Error (with retry)
166166
</h3>
167-
<LocationCard
167+
<MapPlaceCard
168168
image={SAMPLE_LOCATIONS[0].image}
169169
title="Error Location"
170170
error={true}
@@ -188,7 +188,7 @@ const LocationCardShowcase: React.FC = () => {
188188
>
189189
Empty
190190
</h3>
191-
<LocationCard
191+
<MapPlaceCard
192192
image=""
193193
title=""
194194
emptyTitle="No location selected"
@@ -218,7 +218,7 @@ const LocationCardShowcase: React.FC = () => {
218218
<h3 style={{ fontSize: '18px', marginBottom: '16px' }}>Nearby Locations</h3>
219219
<div style={{ display: 'flex', flexDirection: 'column', gap: '12px' }}>
220220
{SAMPLE_LOCATIONS.map((location, index) => (
221-
<LocationCard
221+
<MapPlaceCard
222222
key={index}
223223
{...location}
224224
selected={selectedId === `real-${index}`}
@@ -307,7 +307,7 @@ const LocationCardShowcase: React.FC = () => {
307307
<header style={{ marginBottom: '24px' }}>
308308
<h2 style={{ marginBottom: '8px' }}>Props Reference</h2>
309309
<p style={{ color: 'var(--ai-color-text-secondary)', margin: 0, fontSize: '14px' }}>
310-
Complete API documentation for LocationCard
310+
Complete API documentation for MapPlaceCard
311311
</p>
312312
</header>
313313

@@ -528,6 +528,6 @@ const LocationCardShowcase: React.FC = () => {
528528
);
529529
};
530530

531-
export const LocationCards: StoryObj = {
532-
render: () => <LocationCardShowcase />,
531+
export const MapPlaceCards: StoryObj = {
532+
render: () => <MapPlaceCardShowcase />,
533533
};

0 commit comments

Comments
 (0)