Field Studio
An independent publishing studio working in print and digital editions.
Components Overlays
Show a small profile on pointer hover or by activating its disclosure.
An independent publishing studio working in print and digital editions.
Use Label for the trigger and Initials, Title, and Description for the profile. Activate the summary to pin the profile open. Escape dismisses the card. Native disclosure remains available without the module.
Register hover-card with Head and pass its properties to Render. Go setup guide
err := mono.UI.Render(w, "hover-card", mono.Props{
"Description": "An independent publishing studio working in print and digital editions.",
"Initials": "FS",
"Label": "Field Studio",
"Title": "Field Studio",
})<details id="demo-hover-card" data-mono="hover-card">
<summary class="mu-btn">Field Studio</summary>
<article class="mu-card mu-stack">
<span class="mu-badge" aria-hidden="true">FS</span>
<h3 class="mu-title">Field Studio</h3><p class="mu-muted">An independent publishing studio working in print and digital editions.</p>
</article>
</details><details id="{{.ID}}" data-mono="hover-card">
<summary class="mu-btn">{{.Label}}</summary>
<article class="mu-card mu-stack">
<span class="mu-badge" aria-hidden="true">{{.Initials}}</span>
<h3 class="mu-title">{{.Title}}</h3><p class="mu-muted">{{.Description}}</p>
</article>
</details>[data-mono="hover-card"] { position: relative; width: fit-content; }
[data-mono="hover-card"] summary { list-style: none; }
[data-mono="hover-card"] summary::-webkit-details-marker { display: none; }
[data-mono="hover-card"] article { width: min(18rem, 72vw); max-width: 100%; margin-top: .45rem; }
[data-mono="hover-card"][open] { width: min(18rem, 100%); }
[data-mono="hover-card"] .mu-badge { align-self: flex-start; justify-self: start; }export function mount(root) {
const trigger = root.querySelector('summary');
let pinned = root.open;
let inside = false;
function dismiss(event) {
if (event.key === 'Escape' && root.open) {
pinned = false;
root.open = false;
document.removeEventListener('keydown', dismiss);
}
}
root.addEventListener('toggle', () => {
if (root.open) document.addEventListener('keydown', dismiss);
else document.removeEventListener('keydown', dismiss);
});
root.addEventListener('pointerenter', event => {
if (event.pointerType === 'touch') return;
inside = true;
root.open = true;
});
root.addEventListener('pointerleave', () => {
inside = false;
if (!pinned && !root.contains(document.activeElement)) root.open = false;
});
trigger.addEventListener('click', event => {
event.preventDefault();
pinned = !pinned;
root.open = pinned;
});
root.addEventListener('focusout', event => {
if (!inside && !root.contains(event.relatedTarget)) {
pinned = false;
root.open = false;
}
});
}Copy the rendered HTML above. Download these assets into the same folder as your page, then add the tags below to its head.
Shared CSS Component CSS Ready-to-use module
<link rel="stylesheet" href="./base.css">
<link rel="stylesheet" href="./hover-card.css">
<script type="module" src="./hover-card.js"></script>Run this command from the Mono checkout. Set -out to the component directory in your application.
go run ./cmd/mono-ui add -out ./components hover-card{
"Description": "An independent publishing studio working in print and digital editions.",
"Initials": "FS",
"Label": "Field Studio",
"Title": "Field Studio"
}