Skip to content

Commit

Permalink
fix: issue for patternhub included inside iframe (#2673)
Browse files Browse the repository at this point in the history
  • Loading branch information
nmerget authored May 23, 2024
1 parent ffa8196 commit f93624b
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 2 deletions.
11 changes: 9 additions & 2 deletions packages/components/src/components/page/page.lite.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import {
onInit,
onMount,
onUnMount,
Slot,
useMetadata,
useRef,
Expand Down Expand Up @@ -29,8 +30,7 @@ export default function DBPage(props: DBPageProps) {
) {
// We need to set this to `html` element that the flex-box solution works
// See https://stackoverflow.com/a/43710216 - Approach 1 - flexbox
document.documentElement.style.blockSize = '100%';
document.documentElement.style.overflow = 'hidden';
document.documentElement.classList.add('db-page-document');
}
});

Expand All @@ -46,6 +46,13 @@ export default function DBPage(props: DBPageProps) {
}
});

onUnMount(() => {
if (document.documentElement.classList.contains('db-page-document')) {
// remove document styles set by this
document.documentElement.classList.remove('db-page-document');
}
});

// jscpd:ignore-end

return (
Expand Down
5 changes: 5 additions & 0 deletions packages/components/src/components/page/page.scss
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
@use "@db-ui/foundations/build/scss/variables";

.db-page-document {
block-size: 100%;
overflow: hidden;
}

@mixin header-footer-style {
> :is(.db-header, .db-footer, header, footer) {
display: flex;
Expand Down
1 change: 1 addition & 0 deletions showcases/patternhub/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ pages/components/**/docs
pages/components/**/how-to-use.mdx
pages/components/**/migration.mdx
pages/components/**/properties.mdx
pages/components/**/properties.tsx
pages/components/**/overview.tsx
pages/components/**/index.tsx
!components/src/tsconfig.json
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ const OldRoutingFallback = () => {
const path: string[] = [];
if (subDirectory && type) {
path.push(subDirectory, type);
} else if (subDirectory) {
path.push(subDirectory);
} else {
path.push('overview');
}
Expand Down
7 changes: 7 additions & 0 deletions showcases/patternhub/scripts/generate-docs-mdx.js
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,13 @@ const generateDocsMdx = async () => {
getRedirectOldFiles('../../../')
);
}

if (!FS.existsSync(`${componentOldPath}/properties.tsx`)) {
FS.writeFileSync(
`${componentOldPath}/properties.tsx`,
getRedirectOldFiles('../../../')
);
}
}
}
};
Expand Down
4 changes: 4 additions & 0 deletions showcases/patternhub/styles/globals.scss
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@
@forward "@db-ui/foundations/build/css/colors/classes/all";
@forward "@db-ui/foundations/build/css/fonts/classes/all";

body:not(:has(.db-page)) {
padding-block-end: variables.$db-spacing-fixed-lg;
}

.db-main {
scroll-behavior: smooth;
}
Expand Down

0 comments on commit f93624b

Please sign in to comment.