mapbox / mapbox/mapbox-gl-js

Default popup styling is poor - emulate Leaflet.js

Open
#8,368 2 comments 7 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

mapbox.js → GL JS needs discussion :speech_balloon:
Dominant language
TypeScript
Stars
12.4k
Forks
2.4k
PR merge metrics
No merged PRs in 30d

Description

Motivation

The default design of popups is quite poor, and requires extra work to make look nice.

  • The close button is very small
  • Padding is non-optimal, so it looks cramped
  • The hard, non-rounded corners of the box make it look unsubtle
  • Compared also to Leaflet.js, there is also no fade in, which adds a touch of class
  • There is no shadow, so it doesn't stand out well.

https://docs.mapbox.com/mapbox-gl-js/example/popup-on-click/

Design alternatives / mock-up

The following overrides to the CSS essentially emulate the Leaflet.js style, which is more pleasing. It would be good to merge these into the core styles.

/* Popups (adjustments to emulate Leaflet.js) - see https://github.com/mapbox/mapbox-gl-js/issues/8368 */
@keyframes fadein {from {opacity: 0;} to {opacity: 1;}}
.mapboxgl-popup {animation: fadein 0.2s;}
.mapboxgl-popup-content {max-width: 300px; min-width: 50px; border-radius: 12px; padding: 13px 19px; box-shadow: 0 3px 14px rgba(0,0,0,0.4); min-width: 300px;}
.mapboxgl-popup-close-button {font-size: 16px; font-family: Tahoma, Verdana, sans-serif; color: #c3c3c3; font-weight: bold;}
.mapboxgl-popup-close-button:hover {color: #999; background-color: white; border-top-right-radius: 12px;}
body .mapboxgl-map {line-height: 1.4;}

(I release this into the public domain, with no attribution requirement.)

Screen Shot 2019-06-19 at 18 42 18

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by comparing the popup styling in mapbox-gl-js with the linked popup example and the CSS overrides in the issue. Update the default popup presentation to cover the requested close-button sizing, spacing, rounded corners, fade-in, and shadow, then verify the popup matches the stated design.

Written by the indexing model from the issue text.

Assessment

Tech stack
css
Domain
design, frontend
Issue type
Feature
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.