agentleFS
s-frantzs-frantz/sleek-geospatial-skills/.claude/skills/map-popups/SKILL.md

map-popups

Skill0 starsChanged 2 months agoMITView on GitHub

Decide where a map popup opens - CLEAN column versus ADJACENT to the feature, refusing to cover the app's own furniture, and covering the anchor as the last resort rather than fleeing to a corner. Use when building popups, tooltips, or anything that opens at a point on a map.

The file

We split this skill into the rules it gives an agent

2 rules. About 0 are common, 1 is distinctive, and 1 is very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈1

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 1

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    When nothing fits, the popup goes over the anchor, not wherever there is room.

    line 59
  2. Very specific:

    Call it bare at runtime and it reads the live document through obstacles()/safeArea().

    line 75

≈ “Common” is an estimate: at least 1 in 5 of the 372,429 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Popup placement

app/js/ui/popup-placement.js decides; app/js/ui/popup.js applies.

Two strategies, one word each

CLEAN - popups stack in a tidy column down one side, out of the map's way. The centre of the map stays readable and you look to the SIDE for what you clicked.

ADJACENT - the popup opens beside the feature: right if it fits, else left, else below, else above. You look AT what you clicked.

Neither is more correct. They trade "keep the map legible" against "keep the answer near the question", and which one a person wants depends on what they are doing. So it is a setting, not an opinion baked into the code.

What counts as "fits"

A candidate is rejected if it would leave the visible area, or land on anything marked data-sgs-furniture WHILE it occludes an edge (see the map-camera skill and app/js/utils/furniture.js), plus any popup already on screen. This file names no ids — the control stack, the panel, an open table all qualify because they carry the attribute, not because popup-placement.js knows they exist.

Everything else is fair game, including the map and the feature itself.

Note what is deliberately NOT furniture: the basemap attribution. It is small and fixed, and avoiding it would push popups around for no benefit.

The clean column clears the LEFT edge; it does not currently watch the top

cleanBaseLeft() starts the column just right of whatever furniture hugs the left edge (the panel, in this demo) — recomputed per open, from live geometry, never cached. The column's top is a fixed constant (CLEAN_TOP in popup.js), not obstacle-checked. This is a real, known gap rather than a design decision: obstacles()/edgeFurniture() currently only feed ADJACENT mode's placement search (below). If your app puts furniture near the top of the clean column's path — a tall top-right control stack a long cascade could reach, say — that's the first place to look before assuming the bug is somewhere cleverer. Fixing it would mean folding the same edgeFurniture() check CLEAN already uses for its left edge into a top clearance too.

Slide on the CROSS axis only

Each adjacent candidate names the axis its side is DEFINED by. A right placement is defined by x, so it may be nudged vertically to make room and never horizontally. Slide it on x and it drifts back over the anchor, reports that it fits, and the popup never tries the left side at all.

That is not hypothetical. It is what the first version of this function did, and a unit test is what found it.

The last resort is over the anchor

When nothing fits, the popup goes over the anchor, not wherever there is room. A popup jammed into a far corner is worse than one sitting on its own feature: at least the second is obviously about the thing underneath it.

What is protected is the anchor POINT the leader line comes from, not the geometry. A large polygon can be covered without much being lost.

Keep the decision pure — as a DEFAULT, not a second function

adjacentPlacement(anchor, size, blocked, safe) is the one function, and the DOM boundary is its two trailing parameters' DEFAULT VALUES rather than a separate wrapper:

export function adjacentPlacement(anchor, size, blocked = obstacles(), safe = safeArea()) {

Call it bare at runtime and it reads the live document through obstacles()/safeArea(). Call it from a test with explicit arrays and it never touches a browser — the arithmetic is identical either way, because it's the same function, not a pure core plus a thin caller.

That is what makes tests/unit/placement.spec.js possible: the decision is arithmetic, and arithmetic can be tested without a browser or a fixture. A function that reads the document directly can only be tested by building a document, and then the test is mostly about the fixture.

Take the leader line with it

In CLEAN mode a popup deliberately sits far from its feature. Without a line drawn back to the anchor, a reader cannot tell which of three open popups belongs to which of thirty features. If you take the placement strategy, take the leader line too.

Checklist

  • New furniture carries data-sgs-furniture, or popups will sit on it. Nothing to add here — obstacles() asks the DOM via furniture.js, it holds no list of its own.
  • The placement decision takes its inputs as arguments; only their DEFAULT values touch the DOM, so a test can override them without building a fixture.
  • Placement re-runs on move, resize, and any furniture change.
  • Changing the setting re-places what is ALREADY open. A setting that only applies to the next click cannot be evaluated by the person changing it.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.