Your text here
Insert your text here…
Insert your text here…
Insert your text here…
Insert your text here…
Insert your text here…
A reusable Etch popover with a native HTML trigger and panel, three content slots, and class controls for each part. It can hold filters, menus, help text, or other content. The component handles the popover itself; actions inside its slots belong to the page where it is used.
Overview
Popover San Marino uses the HTML Popover API. Its trigger opens the panel through popovertarget, and its close button uses popovertargetaction="hide". In Light dismiss mode, the browser also closes it when someone clicks outside or presses Escape. A small script measures the available height when the panel opens and on viewport changes. CSS handles placement, flipping, scrolling, and the mobile layout.
The component includes these slots:
| Slot | Use it for |
|---|---|
| Header | A heading, short introduction, or other context. The component supplies the close button. |
| Content | The main content, such as a form, list, or menu. |
| Footer | Actions, status text, or secondary information. |
1. Add the component
- Add Popover San Marino from Etch’s Components panel. If moving it to another site, copy or import the component definition and its Etch classes, rather than copying a page instance with site-specific content.
- Set a Popover ID unique on that page. Every instance needs a different ID; otherwise a trigger can open the wrong panel.
- Set the trigger, panel, and close labels. Add blocks to the Header, Content, and Footer slots.
- Set Show in builder to Show while editing slot content. Switch it to Hide when the open preview is in the way. This setting only affects the Etch canvas.
- Save, then test the popover on the published page. The builder preview shows the panel for editing; it does not simulate native focus, dismissal, or viewport placement.
No separate popover library is required. The component’s script and Etch classes travel with the component when those resources are included in the import.
2. Core behavior
Native opening and closing
The trigger and close button use native HTML popover attributes. Light dismiss (auto) allows outside-click and Escape dismissal. Close button only (manual) keeps the panel open until an explicit control hides it. The close button works in either mode.
Space-aware placement
Adaptive starts below the trigger and lets CSS try other positions when space is tight. Above and Below request a fixed side. On viewports at or below 640px, the default panel class presents the popover as a bottom sheet. The panel scrolls internally when its content exceeds its available height.
The script writes --san-marino-available-height to the panel. This is an internal sizing value, not a required customization setting. The default panel class uses it to cap the panel height.
Slot content is yours
The component does not fetch posts, filter stories, search, submit forms, or generate source choices. Put that markup and any related behavior in the instance or page. The WP Wire’s topic and source filter is one use of the slots, not a built-in feature of Popover San Marino.
3. Component properties
| Property | What it controls | Values / default |
|---|---|---|
| Popover ID | The panel’s HTML id and the target for both buttons. Must be unique per page. | Text; default psm-popover |
| Trigger label | Visible button text and its accessible label. | Text; default Open popover |
| Panel label | The accessible name on the panel’s role="dialog". | Text; default Popover |
| Close label | The close button’s accessible label. | Text; default Close popover |
| Placement | Preferred panel direction. | Adaptive, Above, or Below |
| Dismissal | Native popover mode. | Light dismiss (auto) or Close button only (manual) |
| Show in builder | Reveals the panel in the Etch canvas so slots can be edited. | Hide or Show; has no effect on the published page |
| Part classes | Etch class controls for the seven component parts. | Root, Trigger, Panel, Header, Content, Footer, Close |
The three select controls list Adaptive, Light dismiss, and Hide first. Set them explicitly on an instance when that choice matters to your design.
4. Customize the appearance
Open Part classes in the component properties. Each field points to an Etch class. Edit the existing class in Etch’s CSS panel, or add another class for a particular instance. Keep the base class when adding an instance class so the component retains its layout and behavior.
| Part | Default class | Typical changes |
|---|---|---|
| Root | .san-marino | Overall width and any shared part styling |
| Trigger | .san-marino__trigger | Button color, typography, padding, and icons |
| Panel | .san-marino__panel | Width, maximum height, border, radius, background, shadow, and placement |
| Header | .san-marino__header | Header padding, alignment, and background |
| Content | .san-marino__content | Content spacing and overflow |
| Footer | .san-marino__footer | Action layout, padding, and sticky background |
| Close | .san-marino__close | Close button size, border, and hover state |
The default desktop panel width is min(640px, calc(100vw - 2rem)); its maximum height is capped by the viewport and the available space measured at open time. The mobile panel is full width and anchored to the bottom. Change those rules in the Panel class for a different size or layout.
The default classes reference ACSS variables, with literal fallbacks in many rules. These are the main tokens to inspect when adapting the component to a site’s design system:
| Token | Used for |
|---|---|
--text-color, --bg-ultra-light | Text, trigger, and panel colors |
--white, --neutral | Root class’s nested header, panel, and footer treatments |
--border, --radius-m | Panel border and corner radius |
--space-xs, --space-s, --space-m | Gaps and section padding |
--text-s, --sans | Trigger and panel typography |
The root class’s --white and --neutral references do not currently include literal fallbacks. If the destination site does not provide those tokens, edit that Etch class to use available colors or add fallbacks there.
For a wider instance, add a class such as .psm-panel--wide through Part classes → Panel, alongside .san-marino__panel:
.psm-panel--wide {
width: min(52rem, calc(100vw - 2rem));
}CSSAdd the rule as an Etch class so it can be selected and edited in the builder. Slot content can use its own classes without changing the reusable component.
5. Forms and other interactive content
If a form sits in the Content slot and its submit button sits in the Footer slot, give the form a unique id and set the footer button’s form attribute to that ID:
<form id="resource-filters">
<!-- Fields in the Content slot -->
</form>
<button type="submit" form="resource-filters">Apply filters</button>CSSAdd the form’s submission, filtering, and reset behavior on the page or in the instance. The component only opens and closes the panel. Give every field a label, keep visible focus styles, and make the Panel label describe what the panel contains.
6. Native JavaScript hooks
There is no custom PopoverSanMarino JavaScript object to call. Use the browser’s Popover API on the rendered panel when another control needs to manage it:
const panel = document.getElementById('resource-popover');
panel.showPopover();
panel.hidePopover();
panel.addEventListener('beforetoggle', (event) => {
if (event.newState === 'open') {
// Prepare instance-specific content before it opens.
}
});JavaScriptUse the same ID in the Popover ID property. The component’s own script looks for data-psm-popover-root, data-psm-popover-trigger, and data-psm-popover-panel; it measures space on open, resize, and scroll. Keep those attributes if you edit the component’s underlying markup.
7. Troubleshooting
| Symptom | Check |
|---|---|
| A trigger opens another panel | Two popovers may share the same Popover ID. Give each instance a unique ID. |
| The panel is hard to edit in Etch | Set Show in builder to Show, then edit its slots. |
| The builder preview differs from the live page | Test on the published page. The preview deliberately displays the panel in the canvas rather than the browser’s popover top layer. |
| A footer submit button does nothing | Set its form attribute to the id of the form in the Content slot, and provide a submit handler if the form needs custom behavior. |
| Choices appear but do not filter anything | The component does not include filter logic. Connect the instance’s fields to the page’s query or filtering script. |
| Styling looks incomplete on another site | Confirm the Etch classes were imported and that the destination provides the ACSS tokens used by those classes. |
This guide follows the setup, behavior, properties, customization, and API organization of Nick Arce’s Read More documentation. Its details describe Popover San Marino’s current Etch component, not the Read More component.