Skip to content

feat(map): let map mode be contained by an element, not only the viewport #169

Closed

Description

@Ardnived

Summary

Let a map-mode embed be contained by an element on the host's page, instead of always taking the
whole viewport.

Today FullInterface renders the map as <div style={{ position: 'fixed', inset: 0 }}> with no
z-index, and docs/embedding.md states that map mode requires a full-page slot. That is a real
constraint and it was the right call at the time — but it now blocks a case we need.

Why now

The WordPress plugin (stage C5, sydevs/SahajAtlasWordpress) gives each site one plugin-owned Atlas
page. That page should show the site's own header, then the atlas below it. It cannot:

Host header What a visitor sees today
Static The map paints over it. The header still occupies layout space, but is invisible.
Sticky with z-index — Elementor Pro's default, and most modern themes The header floats above the map and above the widget's own drawers, covering the widget's top-left settings control.

Neither is "header, then atlas". The plugin will ship without a header until this lands, which is a
worse page than the one we want on all 13 WordPress sites.

More generally: an embed that does not own the whole page is a shape we want to support, and
right now the only two options are "takes the viewport" or "no map at all".

⚠ The comment saying this is intractable is now stale

FullInterface.tsx:122-137 argues containment is not a fixed → absolute swap, because:

  • vaul computes a snap-point sheet's translate from the window height, so a contained sheet is
    pushed off-screen by the library's own arithmetic; and
  • --sy-sheet-top, which pins the sticky Register bar, is a viewport-relative
    getBoundingClientRect().top.

Both of those were solved in #161, and the whole interface is already contained in one place.
The compact card's expanded dialog is fixed inset-2 … [contain:layout]
(CompactEmbedView.tsx:93), and contain: layout makes it the containing block for every fixed
descendant — the map canvas, the drawers, the peek strips. FullInterface renders inside it as
children. It works.

The two obstacles were retired by:

  • --sy-frame-h — 100dvh on .sy-atlas, 100% on [data-sy-expanded] (globals.css:112,
    :427). One token that is correct in both places, because 100% on a fixed child resolves
    against its containing block.
  • vaul's own container prop — DrawerStack passes measureAgainst={expandedDialog()}
    (DrawerStack.tsx:745), so vaul measures the box it renders in rather than the window. Note the
    distinction the code makes: the portal target and the measurement box are different props,
    because the portal target can be a display: contents element that measures 0×0.
  • --sy-sheet-top already subtracts the dialog's own top, and is zero everywhere else.

So the mechanism exists and is tested. This ticket is to generalize it from "a modal dialog we
own" to "an element on the host's page", not to build it.

What to work out

  1. How does the widget learn its container? Today [data-sy-expanded] is the signal, set by our
    own dialog. An embed on a host page has no such marker. Options worth weighing: measure the
    custom element's own box; let the host mark an ancestor; or make the element itself the
    containing block. Each interacts with §"Responsive: which signal answers which question" in
    .claude/rules/components.md, which is the existing decision table for exactly this question.
  2. contain: layout on the scope root is currently forbidden, and for a good reason —
    .claude/rules/components.md says so explicitly, and the measured table there shows contain
    and transform re-parent fixed descendants while container-type does not. Whatever this does
    must not resurrect that hazard for map-less embeds.
  3. The slot decision interacts. lib/slot-decision.ts currently renders the compact card when a
    map embed does not own the viewport — that rule exists because containment was impossible. If
    it becomes possible, the rule needs revisiting rather than leaving both behaviours to fight.
  4. z-index. The canvas has none. A contained map beside a host's sticky header needs a defined
    stacking relationship rather than whatever the host's CSS happens to produce.
  5. Does the host size it, or do we? map=false is container-relative and the host gives it a
    height. The natural answer is the same for a contained map — but note the trap recorded in the
    plugin plan: the widget degrades to the compact card when its slot is under 0.8× the viewport, so
    "contained map mode" and "compact card" must not both trigger.

Not in scope

  • Changing map=false, which already works this way.
  • A script parameter for it. The plugin plan is explicit that configuration is a cost, and this
    should follow from what the host's layout already says.

Consumers

  • sydevs/SahajAtlasWordpress — the atlas page wants the site header above the map. Blocked on
    this for that feature only; the plugin ships without a header meanwhile.
  • Any future host embedding the map inside a page rather than dedicating one to it.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    Hold Until

    None yet

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions