Skip to content

Commit a32602f

Browse files
Mpdreamzreakaleek
andauthored
Dynamic max-width based on 90ch width for the content (#1197)
* Full width layout PoC * Also set max width for other elements * Fixes and fine-tuning * Cleanup * Fix isolated build header position * Formatting * Prettier * Limited max width PoC * Use common resolution width * Dynamic spacing for max-width layout * ensure margins are dynamic again * fix css lint * Slight on this page margin adjustments (#1198) * feature/limited width layout 4 (#1201) * fixate max-width around max content-width * npm fix lint * Update src/Elastic.Markdown/Slices/_Layout.cshtml Co-authored-by: Jan Calanog <[email protected]> --------- Co-authored-by: Jan Calanog <[email protected]> --------- Co-authored-by: Jan Calanog <[email protected]>
1 parent 2a54478 commit a32602f

File tree

7 files changed

+63
-41
lines changed

7 files changed

+63
-41
lines changed

src/Elastic.Markdown/Assets/styles.css

+12-2
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,13 @@
2424
--banner-height: calc(var(--spacing) * 9);
2525
/*--offset-top: calc(var(--header-height) + var(--banner-height));*/
2626
--offset-top: 72px;
27-
--max-layout-width: 1920px;
27+
--max-text-width: clamp(40ch, 90ch, 100%);
28+
--max-sidebar-width: calc(var(--spacing) * 65);
29+
--content-spacing: calc(var(--spacing) * 8);
30+
--max-layout-width: calc(
31+
var(--max-text-width) + (var(--max-sidebar-width) * 2) +
32+
calc(var(--content-spacing) * 2)
33+
);
2834
}
2935

3036
@media screen and (min-width: 767px) {
@@ -230,7 +236,11 @@
230236

231237
.container {
232238
@apply lg:px-3;
233-
max-width: 1250px !important;
239+
max-width: var(--max-layout-width) !important;
240+
241+
* {
242+
@apply font-body;
243+
}
234244
}
235245

236246
#elastic-nav {

src/Elastic.Markdown/Slices/Layout/_Footer.cshtml

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
@inherits RazorSlice<LayoutViewModel>
22

33

4-
<footer class="text-grey-20 text-[12px] bg-ink-dark py-12 px-6">
4+
<footer class="py-12 px-6 w-full mx-auto bg-ink-dark">
55
<div class="max-w-(--max-layout-width) w-full mx-auto">
6+
<div class="text-grey-20 text-[12px]">
67
<a href="https://www.elastic.co/">
78
<img class="block" alt="Elastic logo" src="@Model.Static("logo-elastic-horizontal-white.svg")" width="120"/>
89
</a>
910
</div>
10-
<div class="max-w-(--max-layout-width) w-full mx-auto grid grid-cols-1 md:grid-cols-2 gap-2 rounded-tl-4xl rounded-tr-4xl items-center">
11+
<div class="text-grey-20 text-[12px] bg-ink-dark grid grid-cols-1 md:grid-cols-2 gap-2 items-center">
1112
<div>
1213
<ul class="mt-4 flex gap-3">
1314
<li>
@@ -31,6 +32,7 @@
3132
Elasticsearch is a trademark of Elasticsearch B.V., registered in the U.S. and in other countries. Apache, Apache Lucene, Apache Hadoop, Hadoop, HDFS and the yellow elephant logo are trademarks of the Apache Software Foundation in the United States and/or other countries.
3233
</p>
3334
</div>
35+
</div>
3436
</footer>
3537

3638
<script src="@Model.Static("main.js")"></script>

src/Elastic.Markdown/Slices/Layout/_Header.cshtml

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,15 @@
77
}
88
else
99
{
10-
<header class="sticky top-0 z-50 bg-blue-developer text-white text-lg font-semibold h-(--offset-top) flex items-center px-6">
10+
<header class="sticky top-0 z-50 bg-blue-developer text-white h-(--offset-top) flex items-center">
1111
<div class="max-w-(--max-layout-width) w-full mx-auto flex justify-between items-center">
1212
@* ReSharper disable once Html.IdNotResolved *@
1313
<label role="button" class="md:hidden cursor-pointer" for="pages-nav-hamburger">
1414
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="size-8">
1515
<path stroke-linecap="round" stroke-linejoin="round" d="M3.75 6.75h16.5M3.75 12h16.5m-16.5 5.25H12"/>
1616
</svg>
1717
</label>
18-
<a href="@Model.Link("/")" class="flex items-center gap-2">
18+
<a href="@Model.Link("/")" class="flex items-center gap-2 text-lg font-semibold px-4">
1919
<img src="@Model.Static("logo-elastic-glyph-color.svg")" alt="" width="32" height="32">
2020
@Model.DocSetName
2121
</a>

src/Elastic.Markdown/Slices/Layout/_LandingPage.cshtml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
@inherits RazorSlice<LayoutViewModel>
2-
<div class="w-full font-body text-ink relative text-pretty">
2+
<div class="w-full text-ink relative text-pretty">
33
<div class="w-full absolute top-0 left-0 right-0 htmx-indicator" id="htmx-indicator" role="status">
44
<div class="h-[2px] w-full overflow-hidden">
55
<div class="progress w-full h-full bg-pink-70 left-right"></div>

src/Elastic.Markdown/Slices/Layout/_PagesNav.cshtml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
@inherits RazorSlice<LayoutViewModel>
2-
<aside class="sidebar bg-white fixed md:sticky shadow-2xl md:shadow-none left-[100%] group-has-[#pages-nav-hamburger:checked]/body:left-0 bottom-0 md:left-auto pl-6 md:pl-0 top-[calc(var(--offset-top)+1px)] order-1 w-[80%] md:w-auto shrink-0 border-r-1 border-r-grey-20 z-40 md:z-auto">
2+
<aside class="sidebar bg-white fixed md:sticky shadow-2xl md:shadow-none left-[100%] group-has-[#pages-nav-hamburger:checked]/body:left-0 bottom-0 md:left-auto pl-6 md:pl-2 top-[calc(var(--offset-top)+1px)] w-[80%] md:w-auto shrink-0 border-r-1 border-r-grey-20 z-40 md:z-auto">
33
<nav
44
id="pages-nav"
55
class="sidebar-nav h-full"

src/Elastic.Markdown/Slices/Layout/_TableOfContents.cshtml

+29-29
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
@using Elastic.Markdown.Helpers;
22
@inherits RazorSlice<LayoutViewModel>
3-
<aside class="sidebar hidden lg:block order-2 max-w-65">
3+
<aside class="sidebar hidden lg:block max-w-65 md:hidden">
44
<nav id="toc-nav" class="sidebar-nav">
55
<div id="page-version-dropdown" tabindex="1"
66
class="mt-6 block group font-sans text-sm relative z-50">
@@ -57,17 +57,42 @@
5757
</ul>
5858
</div>
5959
</div>
60-
<div class="pt-6 pb-20 pl-4">
60+
<ul class="mt-6">
61+
62+
@if (Model.GithubEditUrl is not null)
63+
{
64+
<li class="edit-this-page not-first:mt-1">
65+
<a href="@Model.GithubEditUrl" class="link text-sm" target="_blank">
66+
67+
68+
<svg class="link-icon" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor">
69+
<path stroke-linecap="round" stroke-linejoin="round" d="m16.862 4.487 1.687-1.688a1.875 1.875 0 1 1 2.652 2.652L6.832 19.82a4.5 4.5 0 0 1-1.897 1.13l-2.685.8.8-2.685a4.5 4.5 0 0 1 1.13-1.897L16.863 4.487Zm0 0L19.5 7.125"/>
70+
</svg>
71+
72+
Edit this page
73+
</a>
74+
</li>
75+
<li class="report-an-issue not-first:mt-1">
76+
<a href="@Model.ReportIssueUrl" class="link text-sm" target="_blank">
77+
<svg class="link-icon" viewBox="0 0 98 96" xmlns="http://www.w3.org/2000/svg">
78+
<path fill-rule="evenodd" clip-rule="evenodd" d="M48.854 0C21.839 0 0 22 0 49.217c0 21.756 13.993 40.172 33.405 46.69 2.427.49 3.316-1.059 3.316-2.362 0-1.141-.08-5.052-.08-9.127-13.59 2.934-16.42-5.867-16.42-5.867-2.184-5.704-5.42-7.17-5.42-7.17-4.448-3.015.324-3.015.324-3.015 4.934.326 7.523 5.052 7.523 5.052 4.367 7.496 11.404 5.378 14.235 4.074.404-3.178 1.699-5.378 3.074-6.6-10.839-1.141-22.243-5.378-22.243-24.283 0-5.378 1.94-9.778 5.014-13.2-.485-1.222-2.184-6.275.486-13.038 0 0 4.125-1.304 13.426 5.052a46.97 46.97 0 0 1 12.214-1.63c4.125 0 8.33.571 12.213 1.63 9.302-6.356 13.427-5.052 13.427-5.052 2.67 6.763.97 11.816.485 13.038 3.155 3.422 5.015 7.822 5.015 13.2 0 18.905-11.404 23.06-22.324 24.283 1.78 1.548 3.316 4.481 3.316 9.126 0 6.6-.08 11.897-.08 13.526 0 1.304.89 2.853 3.316 2.364 19.412-6.52 33.405-24.935 33.405-46.691C97.707 22 75.788 0 48.854 0z" fill="currentColor"/>
79+
</svg>
80+
Report an issue
81+
</a>
82+
</li>
83+
}
84+
</ul>
85+
<div class="pt-6">
6186
@if (Model.PageTocItems.Count > 0)
6287
{
6388
<div>
6489
<div class="font-bold mb-2">On this page</div>
6590
<div class="relative toc-progress-container font-body">
66-
<div class="toc-progress-indicator absolute top-0 h-0 left-2 w-[1px] bg-blue-elastic transition-all duration-200 ease-out "></div>
91+
<div class="toc-progress-indicator absolute top-0 h-0 w-[1px] bg-blue-elastic transition-all duration-200 ease-out "></div>
6792
<ul class="block w-full">
6893
@foreach (var item in Model.PageTocItems)
6994
{
70-
<li class="has-[:hover]:border-l-grey-80 items-center ml-2 px-4 border-l-1 border-l-grey-20 has-[.current]:border-l-blue-elastic!">
95+
<li class="has-[:hover]:border-l-grey-80 items-center px-4 border-l-1 border-l-grey-20 has-[.current]:border-l-blue-elastic!">
7196
<a
7297
class="sidebar-link inline-block my-1.5 @(item.Level == 3 ? "ml-4" : string.Empty)"
7398
href="#@item.Slug">
@@ -80,31 +105,6 @@
80105
</div>
81106
}
82107

83-
<ul class="mt-6">
84-
85-
@if (Model.GithubEditUrl is not null)
86-
{
87-
<li class="edit-this-page not-first:mt-1">
88-
<a href="@Model.GithubEditUrl" class="link text-sm" target="_blank">
89-
90-
91-
<svg class="link-icon" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor">
92-
<path stroke-linecap="round" stroke-linejoin="round" d="m16.862 4.487 1.687-1.688a1.875 1.875 0 1 1 2.652 2.652L6.832 19.82a4.5 4.5 0 0 1-1.897 1.13l-2.685.8.8-2.685a4.5 4.5 0 0 1 1.13-1.897L16.863 4.487Zm0 0L19.5 7.125"/>
93-
</svg>
94-
95-
Edit this page
96-
</a>
97-
</li>
98-
<li class="report-an-issue not-first:mt-1">
99-
<a href="@Model.ReportIssueUrl" class="link text-sm" target="_blank">
100-
<svg class="link-icon" viewBox="0 0 98 96" xmlns="http://www.w3.org/2000/svg">
101-
<path fill-rule="evenodd" clip-rule="evenodd" d="M48.854 0C21.839 0 0 22 0 49.217c0 21.756 13.993 40.172 33.405 46.69 2.427.49 3.316-1.059 3.316-2.362 0-1.141-.08-5.052-.08-9.127-13.59 2.934-16.42-5.867-16.42-5.867-2.184-5.704-5.42-7.17-5.42-7.17-4.448-3.015.324-3.015.324-3.015 4.934.326 7.523 5.052 7.523 5.052 4.367 7.496 11.404 5.378 14.235 4.074.404-3.178 1.699-5.378 3.074-6.6-10.839-1.141-22.243-5.378-22.243-24.283 0-5.378 1.94-9.778 5.014-13.2-.485-1.222-2.184-6.275.486-13.038 0 0 4.125-1.304 13.426 5.052a46.97 46.97 0 0 1 12.214-1.63c4.125 0 8.33.571 12.213 1.63 9.302-6.356 13.427-5.052 13.427-5.052 2.67 6.763.97 11.816.485 13.038 3.155 3.422 5.015 7.822 5.015 13.2 0 18.905-11.404 23.06-22.324 24.283 1.78 1.548 3.316 4.481 3.316 9.126 0 6.6-.08 11.897-.08 13.526 0 1.304.89 2.853 3.316 2.364 19.412-6.52 33.405-24.935 33.405-46.691C97.707 22 75.788 0 48.854 0z" fill="currentColor"/>
102-
</svg>
103-
Report an issue
104-
</a>
105-
</li>
106-
}
107-
</ul>
108108
</div>
109109

110110
</nav>

src/Elastic.Markdown/Slices/_Layout.cshtml

+14-4
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,19 @@
2323

2424
private async Task DefaultLayout()
2525
{
26-
<div class="max-w-(--max-layout-width) w-full h-full grid grid-cols-1 md:grid-cols-[calc(var(--spacing)*65)_1fr] px-6">
26+
<div class="max-w-(--max-layout-width) w-full h-full grid
27+
grid-cols-1
28+
md:grid-cols-[var(--max-sidebar-width)_1fr]
29+
lg:grid-cols-[var(--max-sidebar-width)_1fr_var(--max-sidebar-width)]
30+
">
2731
@await RenderPartialAsync(_PagesNav.Create(Model))
28-
<div class="order-2 grid grid-cols-1 md:grid-cols-[clamp(40ch,80ch,100%)] lg:grid-cols-[80ch_1fr] xl:grid-cols-[90ch_calc(var(--spacing)*65)] justify-center">
29-
@await RenderPartialAsync(_TableOfContents.Create(Model))
30-
<main id="content-container" class="w-full flex flex-col order-1 relative pb-30 overflow-x-hidden">
32+
<div class="justify-center grid
33+
grid-cols-1
34+
px-6 lg:px-0
35+
lg:grid-cols-[1fr_var(--max-text-width)_1fr]
36+
">
37+
<div class="spacer"></div>
38+
<main id="content-container" class="w-full flex flex-col relative pb-30 overflow-x-hidden">
3139
<div class="w-full absolute top-0 left-0 right-0 htmx-indicator" id="htmx-indicator" role="status">
3240
<div class="h-[2px] w-full overflow-hidden">
3341
<div class="progress w-full h-full bg-pink-70 left-right"></div>
@@ -43,7 +51,9 @@
4351
</article>
4452
@await RenderPartialAsync(_PrevNextNav.Create(Model))
4553
</main>
54+
<div class="spacer"></div>
4655
</div>
56+
@await RenderPartialAsync(_TableOfContents.Create(Model))
4757
</div>
4858
}
4959

0 commit comments

Comments
 (0)