Skip to content

Commit e3c1cab

Browse files
committed
Added support for taller component previews
1 parent 82eb36d commit e3c1cab

6 files changed

Lines changed: 19 additions & 8 deletions

File tree

11tyconfig/previewMarkdownDirective.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ export default function previewMarkdownDirective(md) {
1717
return;
1818
}
1919

20-
const { file, title, id } = attrs;
20+
const { file, title, id, tall } = attrs;
2121

2222
let htmlContent;
2323
try {
@@ -43,6 +43,7 @@ export default function previewMarkdownDirective(md) {
4343
const previewTitle = escape(title || "Preview");
4444
const previewId = id || `preview_${directiveStartLine}`;
4545
const pathPrefix = process.env.SITE_ENV === "production" ? "/roux" : "";
46+
const isTall = tall === "true";
4647

4748
// create a markdown HTML block
4849
const token = state.push("html_block", "", 0);
@@ -52,6 +53,7 @@ export default function previewMarkdownDirective(md) {
5253
previewTitle,
5354
htmlContent,
5455
pathPrefix,
56+
isTall,
5557
);
5658
} catch (error) {
5759
console.error("Error rendering preview", error);
@@ -83,9 +85,9 @@ function generatePreviewIframeContent(title, htmlContent, pathPrefix) {
8385
`;
8486
}
8587

86-
function generatePreviewHtml(id, title, htmlContent, pathPrefix) {
88+
function generatePreviewHtml(id, title, htmlContent, pathPrefix, isTall) {
8789
return `
88-
<div class="component-example">
90+
<div class="component-example${isTall ? " component-example--tall" : ""}">
8991
<div role="tablist" aria-labelledby="${id}" class="automatic">
9092
<button
9193
id="tab-preview-${id}"

site/assets/css/_component-example.css

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,17 @@
1+
.component-example {
2+
/* expand beyond parent width for readability */
3+
width: calc(100vw - var(--space--x-large) * 2);
4+
max-width: 70rem;
5+
}
6+
17
.component-example [role="tabpanel"] {
28
resize: both;
39
overflow: auto;
410
height: 340px;
511
}
12+
.component-example--tall [role="tabpanel"] {
13+
height: 540px;
14+
}
615

716
.component-example__preview-frame {
817
border: var(--border--dark);

site/component-library/dialog.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ Remember to set autofocus to a close button or the first interaction. [According
2020

2121
### Basic Modal
2222

23-
::preview{file="dialogs/basic.html" title="Basic Modal" id="example_basic_modal"}::
23+
::preview{file="dialogs/basic.html" title="Basic Modal" id="example_basic_modal" tall="true"}::
2424

2525
### Slide-in Drawer Modal
2626

27-
::preview{file="dialogs/slide-in.html" title="Slide-in Drawer Modal" id="example_slide_in_modal"}::
27+
::preview{file="dialogs/slide-in.html" title="Slide-in Drawer Modal" id="example_slide_in_modal" tall="true"}::

site/component-library/form.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,4 @@ This approach keeps the form **accessible, extensible, and user-friendly** while
2121

2222
### Basic Form
2323

24-
::preview{file="forms/basic.html" title="Basic Form" id="example_form"}::
24+
::preview{file="forms/basic.html" title="Basic Form" id="example_form" tall="true"}::

site/component-library/table.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,4 +32,4 @@ Using these variations keeps tables readable, accessible, and responsive across
3232

3333
### Overflow Scroll
3434

35-
::preview{file="tables/overflow.html" title="Overflow Scroll" id="example_overflow"}::
35+
::preview{file="tables/overflow.html" title="Overflow Scroll" id="example_overflow" tall="true"}::

site/component-library/typography.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,4 @@ Be sure to use headline levels in order (H1 followed by H2, etc) so that assisti
1212

1313
### Basic Typography
1414

15-
::preview{file="typography/basic.html" title="Basic Typography" id="example_basic"}::
15+
::preview{file="typography/basic.html" title="Basic Typography" id="example_basic" tall="true"}::

0 commit comments

Comments
 (0)