Skip to content

Conversation

timDeHof
Copy link
Owner

@timDeHof timDeHof commented Aug 1, 2025

closes #28

  • Integrate vue-maplibre-gl with new map component
  • Add map store for managing map points and bounds
  • Update CENTER_USA constant to LngLatLike array type
  • Modify dashboard layout to accommodate map component

BREAKING CHANGE: The CENTER_USA constant has been changed from {lng: number, lat: number} to an array [lng, lat] of type LngLatLike. Existing code using the object format must be updated to use the array format.

Summary by CodeRabbit

  • New Features

    • Introduced a dynamic map with markers that update based on location data.
    • Added a new store to manage map state and automatically adjust the map view to fit all markers.
  • Improvements

    • Enhanced dashboard and location card layouts for better usability and horizontal scrolling.
    • Sidebar and main content areas now have improved layout and scrolling behavior.
  • Chores

    • Added a new dependency for advanced map functionality.
    • Updated and added new TypeScript types for improved type safety.

- Integrate vue-maplibre-gl with new map component
- Add map store for managing map points and bounds
- Update CENTER_USA constant to LngLatLike array type
- Modify dashboard layout to accommodate map component

BREAKING CHANGE: The CENTER_USA constant has been changed from {lng: number, lat: number} to an array [lng, lat] of type LngLatLike. Existing code using the object format must be updated to use the array format.
@timDeHof timDeHof linked an issue Aug 1, 2025 that may be closed by this pull request
4 tasks
Copy link

vercel bot commented Aug 1, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
nuxt-travel-log ✅ Ready (Inspect) Visit Preview 💬 Add feedback Aug 1, 2025 3:16am

Copy link

coderabbitai bot commented Aug 1, 2025

Walkthrough

This update introduces a Pinia map store to manage and synchronize map markers with location data. The map component is refactored to render markers dynamically from the store, and the map view automatically fits all markers. Supporting type definitions and constants are updated, and layout changes provide improved scrolling and sizing for dashboard elements. A new map library dependency is added.

Changes

Cohort / File(s) Change Summary
Map Store Implementation
stores/map.ts
Introduces a Pinia store (useMapStore) managing mapPoints, with an async init method that fits the map view to all points using LngLatBounds.
Map Component Refactor
components/app/map.client.vue
Refactored to use mapStore for dynamic marker rendering; initializes store on mount, markers sourced from store state.
Location-to-Map Synchronization
stores/locations.ts
Updates effect to sync location data with mapStore.mapPoints for marker rendering; ensures sidebar and map remain in sync.
Type and Constant Updates
lib/types.ts, lib/constant.ts
Adds LatLongItem and MapPoint types; changes CENTER_USA from object to typed array (LngLatLike).
Dashboard Layout Adjustments
pages/dashboard.vue, pages/dashboard/index.vue
Adjusts sidebar and card container layout for scrollability and sizing; prevents shrinking and enables horizontal scrolling for cards.
Dependency Addition
package.json
Adds @indoorequal/vue-maplibre-gl as a new dependency for map functionality.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant Dashboard
    participant LocationsStore
    participant MapStore
    participant MapComponent

    User->>Dashboard: Loads dashboard page
    Dashboard->>LocationsStore: Fetch locations
    LocationsStore->>MapStore: Update mapPoints with locations
    Dashboard->>MapComponent: Mounts map component
    MapComponent->>MapStore: Calls mapStore.init()
    MapStore->>MapComponent: mapPoints updated (reactive)
    MapComponent->>Map: Render markers for each mapPoint
    MapStore->>Map: Fit map bounds to all mapPoints
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~18 minutes

Assessment against linked issues

Objective (Issue #) Addressed Explanation
Loading spinner/skeleton shows while fetching data (#28) No explicit loading spinner or skeleton logic for the map is shown; only sidebar loading is mentioned.
Map displays with appropriate zoom level (#28)
Location markers are correctly positioned (#28)
Map controls show appropriate icons (#28) No changes or references to map controls or their icons are present.

Assessment against linked issues: Out-of-scope changes

No out-of-scope changes found.

Possibly related PRs

Poem

A rabbit hops from place to place,
Now maps update with bounding grace.
Markers dance where journeys go,
Cards scroll sideways in a row.
With stores and types, the code’s a breeze—
Exploring the world is now a tease!
🗺️🐇✨

Note

⚡️ Unit Test Generation is now available in beta!

Learn more here, or try it out under "Finishing Touches" below.

✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch ntl-28

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai generate unit tests to generate unit tests for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (1)
components/app/map.client.vue (1)

14-16: Consider adding error handling for map initialization.

While the mapStore.init() call is appropriate, consider adding error handling to gracefully handle initialization failures.

 onMounted(() => {
-  mapStore.init();
+  try {
+    mapStore.init();
+  } catch (error) {
+    console.error('Failed to initialize map store:', error);
+  }
 });
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 75dd331 and 652b453.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (8)
  • components/app/map.client.vue (2 hunks)
  • lib/constant.ts (1 hunks)
  • lib/types.ts (1 hunks)
  • package.json (1 hunks)
  • pages/dashboard.vue (2 hunks)
  • pages/dashboard/index.vue (1 hunks)
  • stores/locations.ts (1 hunks)
  • stores/map.ts (1 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (2)
stores/locations.ts (3)
stores/sidebar.ts (1)
  • useSidebarStore (8-15)
stores/map.ts (1)
  • useMapStore (3-24)
lib/db/schema/location.ts (1)
  • location (8-18)
stores/map.ts (1)
lib/types.ts (1)
  • MapPoint (14-17)
🔇 Additional comments (15)
package.json (1)

18-18: No conflicts detected between map libraries

The added @indoorequal/vue-maplibre-gl@^8.4.1 dependency aligns with and satisfies the nuxt-maplibre module’s own @indoorequal/vue-maplibre-gl@^8.3.0 requirement. Both packages:

  • Support Vue 3 (including Vue 3.5.13)
  • Are actively maintained (recent releases 4 days and 4 months ago)
  • Carry permissive licenses (MIT and Apache-2.0)

The direct dependency is intentional for dynamic imports in stores/map.ts and introduces no redundancy or version conflicts. No further changes are needed.

lib/constant.ts (1)

1-3: All CENTER_USA references updated – no object‐style usage found

I searched across .js, .ts, and .vue files and confirmed:

• No remaining CENTER_USA.lng or CENTER_USA.lat patterns.
• The only import in components/app/map.client.vue uses :center="CENTER_USA" with the new array format.

No further changes are needed.

pages/dashboard.vue (2)

25-25: Good responsive design improvement.

Adding shrink-0 prevents the sidebar from collapsing unexpectedly in flex layouts, ensuring consistent sidebar width regardless of content changes.


78-82: Well-structured layout for map integration.

The nested container structure with overflow-auto and size-full properly handles scrolling and sizing. The AppMap component with flex-1 will appropriately fill the remaining space, creating a good user experience with the map persistently visible across dashboard routes.

pages/dashboard/index.vue (2)

18-18: Effective layout adaptation for map integration.

The change from flex-wrap to flex-nowrap with overflow-auto creates a horizontal scrolling layout that works well with the constrained vertical space now that the map component shares the dashboard area.


22-22: Good use of shrink-0 for consistent card sizing.

Adding shrink-0 prevents location cards from being compressed in the horizontal flex layout, maintaining consistent card dimensions and readability.

components/app/map.client.vue (2)

3-5: Good store integration pattern.

The mapStore import and initialization follows proper Pinia patterns for component-store integration.


26-40: Excellent dynamic marker implementation – coordinate properties verified

I’ve confirmed that point.long and point.lat align with the MapPoint (via LatLongItem) definitions in lib/types.ts. No further changes are required.

lib/types.ts (1)

10-17: LGTM! Well-structured type definitions for map functionality.

The new LatLongItem and MapPoint types are correctly defined and follow TypeScript best practices. The use of intersection type for MapPoint appropriately combines location coordinates with display metadata.

stores/locations.ts (3)

1-1: LGTM! Proper import of the new map store.

The import statement correctly brings in the map store for integration with location data.


8-8: LGTM! Proper store instantiation.

The map store is correctly instantiated alongside the existing sidebar store.


10-26: Effect replacement confirmed

I searched the entire codebase—there are no remaining watchEffect calls, and effect() is only used in:

  • stores/locations.ts (syncs fetched locations to sidebar & map stores)
  • stores/map.ts (updates map bounds when mapPoints changes)

effect is auto-imported in your setup and behaves as intended for immediate, synchronous reactivity. No further action is needed.

stores/map.ts (3)

1-4: LGTM! Proper store structure and type safety.

The store is correctly structured with proper type imports and reactive mapPoints array using the MapPoint type.


20-24: LGTM! Appropriate store exports.

The store correctly exports both the init function and mapPoints array for external consumption.


5-5: Verified: mapStore.init() Is Invoked on Component Mount

I confirmed that the init function is called in the application:

  • In components/app/map.client.vue, mapStore.init() is invoked inside the onMounted hook.

No further changes required.

Comment on lines +5 to +19
async function init() {
const { useMap } = await import("@indoorequal/vue-maplibre-gl");
const { LngLatBounds } = await import("maplibre-gl");

const map = useMap();
effect(() => {
const firstPoint = mapPoints.value[0];
if (!firstPoint)
return;
const bounds = mapPoints.value.reduce((bounds, point) => {
return bounds.extend([point.long, point.lat]);
}, new LngLatBounds([firstPoint.long, firstPoint.lat], [firstPoint.long, firstPoint.lat]));
map.map?.fitBounds(bounds, { padding: 60 });
});
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Add error handling for dynamic imports and map operations.

The async init function correctly uses dynamic imports for code splitting and implements bounds fitting logic. However, consider adding error handling for potential failures.

 async function init() {
+  try {
     const { useMap } = await import("@indoorequal/vue-maplibre-gl");
     const { LngLatBounds } = await import("maplibre-gl");

     const map = useMap();
     effect(() => {
       const firstPoint = mapPoints.value[0];
       if (!firstPoint)
         return;
       const bounds = mapPoints.value.reduce((bounds, point) => {
         return bounds.extend([point.long, point.lat]);
       }, new LngLatBounds([firstPoint.long, firstPoint.lat], [firstPoint.long, firstPoint.lat]));
-      map.map?.fitBounds(bounds, { padding: 60 });
+      try {
+        map.map?.fitBounds(bounds, { padding: 60 });
+      } catch (error) {
+        console.warn('Failed to fit map bounds:', error);
+      }
     });
+  } catch (error) {
+    console.error('Failed to initialize map store:', error);
+  }
 }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
async function init() {
const { useMap } = await import("@indoorequal/vue-maplibre-gl");
const { LngLatBounds } = await import("maplibre-gl");
const map = useMap();
effect(() => {
const firstPoint = mapPoints.value[0];
if (!firstPoint)
return;
const bounds = mapPoints.value.reduce((bounds, point) => {
return bounds.extend([point.long, point.lat]);
}, new LngLatBounds([firstPoint.long, firstPoint.lat], [firstPoint.long, firstPoint.lat]));
map.map?.fitBounds(bounds, { padding: 60 });
});
}
async function init() {
try {
const { useMap } = await import("@indoorequal/vue-maplibre-gl");
const { LngLatBounds } = await import("maplibre-gl");
const map = useMap();
effect(() => {
const firstPoint = mapPoints.value[0];
if (!firstPoint)
return;
const bounds = mapPoints.value.reduce((bounds, point) => {
return bounds.extend([point.long, point.lat]);
}, new LngLatBounds(
[firstPoint.long, firstPoint.lat],
[firstPoint.long, firstPoint.lat]
));
try {
map.map?.fitBounds(bounds, { padding: 60 });
} catch (error) {
console.warn('Failed to fit map bounds:', error);
}
});
} catch (error) {
console.error('Failed to initialize map store:', error);
}
}
🤖 Prompt for AI Agents
In stores/map.ts around lines 5 to 19, the async init function uses dynamic
imports and map operations without error handling. Wrap the dynamic imports and
map operations in try-catch blocks to catch and handle any errors that may occur
during import or map manipulation. Log or handle errors appropriately to prevent
silent failures and improve robustness.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

As a traveler, I want to view all my locations on an interactive map
1 participant