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

feat: SSR rendering for breakpoint dependent code #2339

Closed
jeripeierSBB opened this issue Jan 16, 2024 · 0 comments · Fixed by #2480
Closed

feat: SSR rendering for breakpoint dependent code #2339

jeripeierSBB opened this issue Jan 16, 2024 · 0 comments · Fixed by #2480
Assignees
Labels
complexity: M Can be done in a few days proposal: accepted
Milestone

Comments

@jeripeierSBB
Copy link
Contributor

jeripeierSBB commented Jan 16, 2024

Using breakpoint dependent code causes problems in SSR environments as there is no breakpoint available. E.g. on server, isBreakpoint() returns currently always false but on client side it depends on screen sizes. This causes errors during hydration.

Wherever calling isBreakpoint() has influence on initial rendering output, we want to replace its usages by a different solution. Most of the cases could be replaced by using just css.

To be discussed in refinement:
To provide a reusable help of using triggers, we have the idea of creating some global vars which could be used.
--sbb-display-none-from-{breakpoint}
--sbb-display-none-to-{breakpoint}
--sbb-breakpoint-multiplier-from-{breakpoint}
--sbb-breakpoint-multiplier-to-{breakpoint}

--sbb-breakpoint-multiplier-to-{breakpoint} could be use together with calc like padding:inline: calc(var(--sbb-spacing-fixed-5x) * var(--sbb-breakpoint-multiplier-from-{breakpoint}))

display: var(--sbb-display-none-to-small, var(--sbb-display-none-from-large, 'flex'));

padding: calc(var(--base-padding) + (12px * var(--sbb-breakpoint-multiplier-from-small)));

This should not replace media queries entirely, but just an extension to it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
complexity: M Can be done in a few days proposal: accepted
Projects
None yet
3 participants