Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(styles): setting initial height for the post-header and its components #4633

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft
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
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

z-index: 1020;
position: relative;
height: var(--header-height);

@include media.min(lg) {
--global-header-reduced-height: 24px;
Expand Down Expand Up @@ -108,21 +109,20 @@
.local-header {
display: flex;
position: sticky;
box-sizing: border-box;
flex-wrap: wrap;
align-items: center;
justify-content: space-between;
gap: var(--post-core-dimension-8);
gap: var(--post-core-dimension-4);
min-height: var(--local-header-min-height);
background: var(--post-core-color-brand-white);
transition: box-shadow 0.2s ease-in-out;

@include media.min(lg) {
z-index: 3;
inset-block-start: calc(
-1 * (var(--local-header-height) - var(--main-navigation-height)) + var(--global-header-reduced-height)
);
padding-block-start: var(--post-core-dimension-18);
box-shadow: var(--post-core-elevation-3);
}

@include media.max(lg) {
Expand Down Expand Up @@ -165,6 +165,7 @@
}

@include media.min(lg) {
line-height: 34px !important;
font-size: var(--post-core-font-size-28) !important;
}

Expand All @@ -184,6 +185,7 @@
width: 100%;

@include media.min(lg) {
height: var(--main-navigation-height);
inset-block-start: var(--global-header-minimal-height);

&::before {
Expand Down
14 changes: 8 additions & 6 deletions packages/components/src/components/post-header/post-header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,14 @@ export class PostHeader {
private throttledResize = throttle(50, () => this.handleResize());

componentWillRender() {
this.scrollParent = this.getScrollParent(this.host);
this.scrollParent.addEventListener('scroll', this.throttledScroll, { passive: true });
window.addEventListener('resize', this.throttledResize, { passive: true });
this.handleResize();
this.handleScrollEvent();
this.getFocusableElements();
setTimeout(() => {
this.scrollParent = this.getScrollParent(this.host);
this.scrollParent.addEventListener('scroll', this.throttledScroll, { passive: true });
window.addEventListener('resize', this.throttledResize, { passive: true });
this.handleResize();
this.handleScrollEvent();
this.getFocusableElements();
}, 2000); // delay
}

componentDidLoad() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

post-mainnavigation {
flex: 0 0 auto;
box-shadow: var(--post-core-elevation-3);

// reset links and buttons
post-list-item {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,24 @@ const meta: MetaComponent = {
},
},
},

decorators: [
story => html` <div class="header-story-wrapper">${story()} ${fakeContent()}</div> `,
],
story => html`
<script>
document.addEventListener('DOMContentLoaded', () => {
const scrollPosition = sessionStorage.getItem('scrollPosition');
if (scrollPosition !== null) {
window.scrollTo(0, parseInt(scrollPosition, 10));
}
});

window.addEventListener('beforeunload', () => {
sessionStorage.setItem('scrollPosition', window.scrollY);
});
</script>
<div class="header-story-wrapper">${story()} ${fakeContent()}</div>
`,
],
};

export default meta;
Expand Down
Loading