docs: make header fixed instead of sticky (#3228)

This is a followup to https://github.com/tldraw/tldraw/pull/3209 
@SomeHats noticed that links within the same doc were not scrolling to
the correct position, so we couldn't really get rid of the
scroll-padding-height after all :-/

Nothing for it! We just can't use `sticky` — have to switch to `fixed`
which I was hoping to avoid, but oh well.

### Change Type

<!--  Please select a 'Scope' label ️ -->

- [ ] `sdk` — Changes the tldraw SDK
- [ ] `dotcom` — Changes the tldraw.com web app
- [x] `docs` — Changes to the documentation, examples, or templates.
- [ ] `vs code` — Changes to the vscode plugin
- [ ] `internal` — Does not affect user-facing stuff

<!--  Please select a 'Type' label ️ -->

- [x] `bugfix` — Bug fix
- [ ] `feature` — New feature
- [ ] `improvement` — Improving existing features
- [ ] `chore` — Updating dependencies, other boring stuff
- [ ] `galaxy brain` — Architectural changes
- [ ] `tests` — Changes to any test code
- [ ] `tools` — Changes to infrastructure, CI, internal scripts,
debugging tools, etc.
- [ ] `dunno` — I don't know
This commit is contained in:
Mime Čuvalo 2024-03-22 10:39:04 +00:00 committed by GitHub
parent cd02d03d06
commit 5e7848aa01
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -51,6 +51,8 @@
/* Sizes */ /* Sizes */
--header-height: 80px; --header-height: 80px;
--header-padding: 24px; --header-padding: 24px;
--headings-width: 278px;
--layout-max-width: 1440px;
} }
[data-theme='dark'] { [data-theme='dark'] {
@ -98,12 +100,7 @@
html { html {
background-color: #000; background-color: #000;
border-bottom: none; border-bottom: none;
/* scroll-padding-top: calc(var(--header-height) + var(--header-padding));
* XXX: this was hitting a browser bug on Blink: https://issues.chromium.org/issues/40749247
* Typing into the search bar was causing the page to scroll as you typed.
* We don't need this for now anyway since we don't have subheader navigation anymore.
*/
/* scroll-padding-top: calc(var(--header-height) + var(--header-padding)); */
} }
body { body {
@ -125,12 +122,12 @@ body {
.layout { .layout {
display: grid; display: grid;
width: 100%; width: 100%;
max-width: 1440px; max-width: var(--layout-max-width);
grid-template-columns: 250px 1fr; grid-template-columns: 250px 1fr var(--headings-width);
grid-template-rows: var(--header-height) 1fr; grid-template-rows: 1fr;
column-gap: 48px; column-gap: 48px;
row-gap: 0px; row-gap: 0px;
padding: 0px; padding: var(--header-height) 0 0 0;
margin: 0px auto; margin: 0px auto;
} }
@ -142,12 +139,15 @@ body {
grid-row: 1; grid-row: 1;
grid-column: 1 / span 3; grid-column: 1 / span 3;
width: 100%; width: 100%;
position: sticky; height: var(--header-height);
max-width: var(--layout-max-width);
position: fixed;
background-color: var(--color-background); background-color: var(--color-background);
z-index: 900; z-index: 900;
top: 0px; top: 0px;
display: grid; display: grid;
padding: 0px 16px; padding: 13px 16px;
margin: 0 auto;
grid-template-columns: 250px 1fr auto; grid-template-columns: 250px 1fr auto;
gap: 16px; gap: 16px;
justify-content: center; justify-content: center;
@ -800,7 +800,7 @@ body {
margin-left: -12px; margin-left: -12px;
padding: var(--header-padding) 28px 120px 12px; padding: var(--header-padding) 28px 120px 12px;
max-height: calc(100vh); max-height: calc(100vh);
width: 290px; width: var(--headings-width);
z-index: 800; z-index: 800;
overflow-y: auto; overflow-y: auto;
overflow-x: hidden; overflow-x: hidden;
@ -1172,9 +1172,14 @@ body {
background-color: var(--color-background); background-color: var(--color-background);
} }
body.sidebar-open {
overflow-y: hidden;
}
body.sidebar-open .sidebar { body.sidebar-open .sidebar {
display: initial; display: initial;
position: fixed; position: fixed;
height: 100%;
inset: 0px; inset: 0px;
z-index: 10000; z-index: 10000;
} }
@ -1297,6 +1302,10 @@ body {
border-radius: 0px; border-radius: 0px;
} }
.layout {
padding: 0;
}
.layout__header { .layout__header {
position: unset; position: unset;
} }