Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 43 additions & 0 deletions __tests__/browser/markdown.test.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
/* global page */

const path = require('path');

const sass = require('sass');

const tabsStyles = sass.compile(path.resolve(__dirname, '../../components/Tabs/style.scss')).css;

// eslint-disable-next-line no-promise-executor-return
const sleep = ms => new Promise(resolve => setTimeout(resolve, ms));

Expand Down Expand Up @@ -64,4 +70,41 @@ describe('visual regression tests', () => {
expect(image).toMatchImageSnapshot();
}, 10000);
});

it('preserves component-owned top margins between adjacent TabContent children', async () => {
await page.setContent(`
<style>
${tabsStyles}
.configured-spacing { --markdown-spacing: 20px; }
.markdown-body pre { margin-top: 7px; }
.markdown-body blockquote { margin-top: 11px; }
</style>
<div class="markdown-body configured-spacing">
<div class="TabGroup">
<div class="TabContent">
<div>first</div>
<pre>code</pre>
<blockquote>quote</blockquote>
</div>
</div>
</div>
`);

const margins = await page.$$eval('.TabContent > *', ([, pre, blockquote]) => ({
blockquoteTop: getComputedStyle(blockquote).marginTop,
preBottom: getComputedStyle(pre).marginBottom,
preTop: getComputedStyle(pre).marginTop,
}));

expect(margins.blockquoteTop).toBe('11px');
expect(margins.preBottom).toBe('20px');
expect(margins.preTop).toBe('7px');

const fallbackSpacing = await page.$eval('.configured-spacing', element => {
element.classList.remove('configured-spacing');
return getComputedStyle(element.querySelector('pre')).marginBottom;
});

expect(fallbackSpacing).toBe('15px');
});
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Resolved
});
4 changes: 4 additions & 0 deletions components/Tabs/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -42,3 +42,7 @@
color: var(--color-text-muted, #4f5a66);
}
}

:where(.TabGroup .TabContent > *:not(:last-child)) {
margin-bottom: var(--markdown-spacing, 15px);
}