Skip to content

✨ feat: A2UI map components (MapView, LocationCard, PlaceList, RouteMap) and StockTicker - #42

Merged
lobehub-coder merged 6 commits into
masterfrom
feat/a2ui-maps
Nov 27, 2026
Merged

lobehub-coder merged 6 commits into
masterfrom
feat/a2ui-maps

Conversation

@lobehub-coder

Copy link
Copy Markdown
Contributor

Adds the official A2UI playground's four map components and its StockTicker. Each takes variant?: 'default' | 'a2ui' (default 'default'), with colours from LobeHub tokens and dark mode from the theme. Layout follows CopilotKit a2ui-playground (MIT); the source files say so.

Components

Component What it draws
StockTicker Symbol / name header, price, change and % change, sparkline (SparkAreaChart) with a dashed line at the first price, key stats, sample badge
MapView Numbered markers fitted in view, header with place count, chip row linked to the markers both ways, popup on the active marker
LocationCard Static mini map with one pin, name, address, category, rating, hours, Directions (Google Maps) / Open map (openstreetmap.org) links
PlaceList Ranked list next to a map. Hovering a row pans to its marker, clicking a row flies in, clicking a marker selects and scrolls to its row. Stacks below 540 px
RouteMap Route through [[lon, lat], ...] as glow + casing + gradient line, start / end pins, from → to header, distance / duration chips, legend

The props follow the official schemas (catalog.json). The maps draw only the coordinates they are given: no geocoding, no routing calls, no API keys.

The default look is an outlined LobeHub block with LobeHub type. a2ui is the official card. In both, markers and the route use color, or the first colour of the theme colour range; the route start uses colorSuccess. StockTicker uses colorSuccess / colorError, and its sample badge uses the warning tokens.

MapLibre is an optional peer

  • maplibre-gl (^5 || ^6) is in peerDependencies and marked optional in peerDependenciesMeta. src/common/map/loader.ts is the only place that imports it, with a dynamic import() of the module and its CSS the first time a map mounts.
  • While it loads, the map shows a placeholder. If it is missing, the map shows "Map unavailable: install maplibre-gl to show it" and the rest of the card still renders. If MapLibre 6's worker can't start, the map says so too. unavailableText overrides the message.
  • MapLibre 6 loads its worker from a separate file that bundlers move, so it needs setMapLibreWorkerUrl(url): Vite ?url, webpack/Next new URL(..., import.meta.url). MapLibre 5 needs nothing. The docs site sets it in docs/maps.ts.
  • Bundle check (scratch Vite app on the built es/):
    • An app importing only AreaChart has no MapLibre code.
    • An app with MapView gets MapLibre as its own lazy chunk (1.1 MB JS + 71 kB CSS), not in index.
    • Vite turns a missing optional peer into a runtime error, which shows the empty state. webpack fails the build only if a map is actually used without maplibre-gl; unused map modules are skipped because the package is side-effect free.

Basemaps

  • The basemaps are OpenFreeMap: keyless, free for commercial use, OSM data. basemap="auto" shows Dark in dark mode. In light mode it shows Positron for the default look and Liberty for a2ui, since Liberty is closest to the official Voyager.
  • The auto styles are tuned in place for a card:
    • Liberty gets paler water and roads, smaller slate labels, flat buildings, and no POIs or shields.
    • Dark gets lighter roads, water and labels, close to Dark Matter.
    • Named basemaps (liberty, bright, positron, dark, fiord) are left as they are.
  • mapStyle takes any MapLibre style URL or object, or { light, dark }. CARTO_STYLES is exported as the documented fallback.
  • Attribution is MapLibre's compact (i) control.

New exports

MapView, LocationCard, PlaceList, RouteMap, StockTicker, their props types, MapMarker, Place, StockTickerStat, MapPoint, LngLat, MapBasemap, MapStyleInput, ThemedMapStyle, OPENFREEMAP_STYLES, CARTO_STYLES, setMapLibreWorkerUrl.

Not matched

  • Colours: the accent and primary button are ours (geekblue, LobeHub primary) instead of the official violet.
  • Basemap: the tiles are OpenFreeMap, not CARTO Voyager / Dark Matter, so streets and labels differ in detail.
  • Pin numbers: these use the page font. The official pins fall back to Helvetica inside MapLibre.
  • Popup: MapView adds a small popup on the active marker (name + description). The official only uses a native title. It appears only on interaction.

Checks

  • type-check, eslint (0 errors), lint:circular, vitest run (92 tests; MapLibre mocked), tsdown build and lobedocs build all pass.
  • Card sizes match the official ones exactly in both themes, with official sample data: MapView 662×442, PlaceList 662×427, LocationCard 560×293, RouteMap 560×418, StockTicker 560×259.

Quote header with symbol, name, price, change and percent change, a
sparkline (SparkAreaChart) with a dashed baseline at the first price, key
stats and a sample-data badge. Layout follows the CopilotKit a2ui-playground
StockTicker (MIT); colours are LobeHub tokens.
…ariants)

- Shared map layer (src/common/map): MapCanvas draws numbered markers or a
  route with plain MapLibre GL, fits every coordinate, follows the active
  marker and restyles in place when the theme changes. No geocoding, no
  routing calls, no API keys.
- maplibre-gl is an optional peer dependency, loaded with a dynamic import
  (and its stylesheet) when the first map mounts; placeholder while it
  loads, a clear 'Map unavailable' state when it is missing or its worker
  cannot start. setMapLibreWorkerUrl points MapLibre 6 at its bundled worker.
- Basemaps: OpenFreeMap (positron for the default look, a softened liberty
  for a2ui, a lifted dark in dark mode); CARTO_STYLES kept as a documented
  fallback through mapStyle.
- MapView: header with place count, numbered pins, chip row linked to the
  markers both ways, popup on the active marker. Layout follows the CopilotKit
  a2ui-playground MapView (MIT); colours are LobeHub tokens.
Single place with a static mini map, name, address, category, rating,
hours and Directions / Open map links (token-styled links, so no
ConfigProvider is needed). Liberty tuning for the a2ui look now also hides
points of interest and one-way arrows and flattens 3D buildings. Layout
follows the CopilotKit a2ui-playground LocationCard (MIT).
Ranked list of places next to a map: hovering a row pans to its marker,
clicking a row flies to it, clicking a marker selects and scrolls to its
row; a preselected row keeps every place in view. Stacks with the map on
top below 540 px (container query). Liberty labels in the a2ui look are
smaller and slate. Layout follows the CopilotKit a2ui-playground PlaceList
(MIT).
Draws a route through given [lon, lat] coordinates (no routing calls) as a
glow, casing and gradient line from the start colour to the accent, with
start / end pins, from -> to header, distance / duration chips over the map
and a legend with the waypoint count. Layout follows the CopilotKit
a2ui-playground RouteMap (MIT); colours are LobeHub tokens.
@lobe-tsukumo

lobe-tsukumo Bot commented Nov 27, 2026

Copy link
Copy Markdown

👍 @lobehub-coder

Thank you for raising your pull request and contributing to our Community.
Please make sure you have followed our contributing guidelines. We will review it as soon as possible.
If you encounter any problems, please feel free to connect with us.

非常感谢您提出拉取请求并为我们的社区做出贡献,请确保您已经遵循了我们的贡献指南,我们会尽快审查它。
如果您遇到任何问题,请随时与我们联系。

@pkg-pr-new

pkg-pr-new Bot commented Nov 27, 2026

Copy link
Copy Markdown

Open in StackBlitz

npm i https://pkg.pr.new/@lobehub/charts@42

commit: 203f849

@lobehub-coder
lobehub-coder merged commit cafdd80 into master Nov 27, 2026
5 checks passed
@lobe-tsukumo

lobe-tsukumo Bot commented Nov 27, 2026

Copy link
Copy Markdown

❤️ Great PR @lobehub-coder ❤️

The growth of project is inseparable from user feedback and contribution, thanks for your contribution!

项目的成长离不开用户反馈和贡献,感谢您的贡献!

lobe-tsukumo Bot pushed a commit that referenced this pull request Nov 27, 2026
## [Version 6.3.0](v6.2.0...v6.3.0)
<sup>Released on **2026-11-27**</sup>

#### ✨ Features

- **misc**: A2UI map components (MapView, LocationCard, PlaceList, RouteMap) and StockTicker.

<br/>

<details>
<summary><kbd>Improvements and Fixes</kbd></summary>

#### What's improved

* **misc**: A2UI map components (MapView, LocationCard, PlaceList, RouteMap) and StockTicker, closes [#42](#42) ([cafdd80](cafdd80))

</details>

<div align="right">

[![](https://img.shields.io/badge/-BACK_TO_TOP-151515?style=flat-square)](#readme-top)

</div>
@lobe-tsukumo

lobe-tsukumo Bot commented Nov 27, 2026

Copy link
Copy Markdown

🎉 This PR is included in version 6.3.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

This branch was successfully deployed

1 active deployment
Preview — 203f849f Deployed Nov 27, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant