Skip to content

Commit 40115a8

Browse files
Merge pull request #290 from DomoApps/users/jon.tiritilli/embed-component
feat: add DomoEmbed snippet component
2 parents deb0262 + cae44a9 commit 40115a8

3 files changed

Lines changed: 125 additions & 0 deletions

File tree

Domo-KB-Style-Guide.mdx

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -357,6 +357,38 @@ Wrap a YouTube (or other host) embed `<iframe>` in a `<Frame>`. Use the host's s
357357

358358
Always include a descriptive `title` attribute — screen readers announce it, and it's what appears if the embed fails to load.
359359

360+
## Embedded Domo Content
361+
362+
Use the `DomoEmbed` snippet to embed live Domo content—dashboards, pages, or cards—directly inside a documentation article. Unlike a screenshot or video, an embedded view reflects current data and lets readers interact with it in context.
363+
364+
The component handles sizing automatically: Domo's embed runtime sends a `postMessage` with the rendered page height, and `DomoEmbed` updates the iframe height accordingly, preventing scroll traps and double scrollbars.
365+
366+
**When to use:** Reserve `DomoEmbed` for situations where live, interactive Domo content adds genuine value—a product overview, a walkthrough that references a live dashboard, or a reference page that benefits from real data context. For static illustration, a screenshot is simpler and more reliable.
367+
368+
### Import and Use
369+
370+
Add the import directly below the frontmatter (alongside any other imports):
371+
372+
```mdx
373+
import { DomoEmbed } from '/snippets/DomoEmbed.mdx';
374+
```
375+
376+
Then place the component wherever the embed should appear:
377+
378+
```mdx
379+
<DomoEmbed src="https://embed.domo.com/embed/pages/XXXXX" />
380+
```
381+
382+
Three props are available:
383+
384+
| Prop | Required | Default | Description |
385+
| --------------- | -------- | -------- | --------------------------------------------------- |
386+
| `src` | Yes || The Domo embed URL (cards or pages endpoint). |
387+
| `width` | No | `"100%"` | CSS width of the iframe. |
388+
| `initialHeight` | No | `"600"` | Starting height in pixels before auto-resize fires. |
389+
390+
<Note>**Note:** The Domo instance that hosts the embed must allow your documentation domain in its embed allowlist. If the iframe appears blank, check the source instance's CSP / embed allowlist settings.</Note>
391+
360392
## Callouts
361393

362394
Use React callout elements for notes, warnings, and tips — not plain text or HTML. Always bold the label and its colon, for example `**Note:**`.

New-Article-Template.mdx

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,30 @@ article). Do not repeat it under additional beta sections.
2929
3030
Do not append `(Beta)` or `(BETA)` to titles or headings — the tag and Badge
3131
carry that signal. See Domo-KB-Style-Guide.mdx › Beta Features for details.
32+
33+
---
34+
35+
EMBEDDED DOMO CONTENT
36+
37+
---
38+
39+
To embed live Domo content (a dashboard or card) in an article, add this import
40+
on its own line directly below the frontmatter above:
41+
42+
import { DomoEmbed } from '/snippets/DomoEmbed.mdx';
43+
44+
Then place the component wherever the embed should appear:
45+
46+
<DomoEmbed
47+
src="https://embed.domo.com/embed/pages/XXXXX"
48+
width="100%"
49+
initialHeight="600"
50+
/>
51+
52+
The src prop (required) is the Domo embed URL. width and initialHeight are
53+
optional and default to "100%" and "600" respectively. See
54+
Domo-KB-Style-Guide.mdx › Embedded Domo Content for the full prop reference
55+
and usage guidelines.
3256
*/}
3357

3458
## Intro

snippets/DomoEmbed.mdx

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
{/*
2+
DomoEmbed — reusable component for embedding Domo-hosted content in MDX pages.
3+
4+
USAGE
5+
-----
6+
Import and drop into any MDX page:
7+
8+
import { DomoEmbed } from "/snippets/DomoEmbed.mdx";
9+
10+
<DomoEmbed
11+
src="https://embed.domo.com/embed/pages/XXXXX"
12+
width="100%"
13+
initialHeight="600"
14+
/>
15+
16+
PROPS
17+
-----
18+
src (required) — The Domo embed URL (cards or pages endpoint).
19+
width (optional) — CSS width of the iframe. Defaults to "100%".
20+
initialHeight (optional) — Starting height in pixels before auto-resize fires. Defaults to "600".
21+
22+
AUTO-RESIZE
23+
-----------
24+
Domo's embed runtime sends a postMessage event containing the rendered page height.
25+
This component listens for that message and updates the iframe height automatically,
26+
eliminating scroll traps and double scrollbars. A 15px buffer is added to account
27+
for sub-pixel rounding and scrollbar gutter width.
28+
29+
For the underlying mechanism and plain-HTML equivalents, see:
30+
/portal/embed/embed-in-sites-and-apps/dynamic-iframe-height
31+
32+
NOTE: The embed URL must come from a Domo instance that allows embedding on this domain.
33+
If the iframe appears blank, check the source instance's CSP / embed allowlist settings.
34+
*/}
35+
36+
import { useEffect, useRef } from "react";
37+
38+
export const DomoEmbed = ({ src, width = "100%", initialHeight = "600" }) => {
39+
const iframeRef = useRef(null);
40+
41+
useEffect(() => {
42+
function handleMessage(event) {
43+
if (
44+
iframeRef.current &&
45+
iframeRef.current.contentWindow === event.source &&
46+
event.data &&
47+
event.data.params &&
48+
event.data.params.height
49+
) {
50+
iframeRef.current.style.height = event.data.params.height + 15 + "px";
51+
}
52+
}
53+
window.addEventListener("message", handleMessage);
54+
return () => window.removeEventListener("message", handleMessage);
55+
}, []);
56+
57+
return (
58+
<iframe
59+
ref={iframeRef}
60+
src={src}
61+
width={width}
62+
height={initialHeight}
63+
marginHeight="0"
64+
marginWidth="0"
65+
frameBorder="0"
66+
style={{ display: "block" }}
67+
/>
68+
);
69+
};

0 commit comments

Comments
 (0)