mapbox / mapbox/mapbox-gl-js

Discussion: mapbox controls

Open
#8,767 10 comments 5 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

needs discussion :speech_balloon: refactoring :building_construction:
Dominant language
TypeScript
Stars
12.4k
Forks
2.4k
PR merge metrics
No merged PRs in 30d

Description

Hi. I have [some controls](https://github.com/bravecow/mapbox-gl-controls) for personal usage.
What I like about them:
1. [each control have separate directory with js + css + icons](https://github.com/bravecow/mapbox-gl-controls/tree/master/src/ruler)
mapbox now have 600-lines CSS
2. valid CSS / SCSS, mapbox CSS is not: https://github.com/mapbox/mapbox-gl-js/blob/master/src/css/mapbox-gl.css#L154
3. injected icons inside control button: https://github.com/bravecow/mapbox-gl-controls/blob/master/src/ruler/ruler.js#L3:
* ~~no additional GET request for each resource~~
* ease of styling. we can style inline SVG with CSS.
* ease of resizing

As result:
* reduce JS bundle for mapbox
* removing `svg-load` plugin
* ~~remove some GET requests for icons~~
* remove CSS prefixes, use [autoprefixer](https://github.com/postcss/autoprefixer).
* move controls from this repo to reduce package.json deps (if any)
* controls will not use any internal events or methods. it will help to understand real needs and provide better API for users (e.g. no public event for style load #8765 for now)
* move mapbox language, mapbox draw and other controls to this monorepo. they will have same bundling tools, codestyle, docs, etc. I think it will make future support easier
* braking change

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 reading src/css/mapbox-gl.css and comparing the linked mapbox-gl-controls src/ruler structure, including its JavaScript, CSS, and icons. Review the proposed package.json, bundling, and control API implications before attempting work; done would require a settled scope and migration plan for controls, dependencies, styling, and breaking changes.

Written by the indexing model from the issue text.

Assessment

Tech stack
css, javascript, scss, typescript
Domain
frontend, web-dev
Issue type
Refactor
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.