Skip to content

Commit

Permalink
Merge pull request #3 from lowlighter/feat-aside-for-small-screen
Browse files Browse the repository at this point in the history
feat: aside customization for simple layout
  • Loading branch information
lowlighter authored May 22, 2024
2 parents a329e3d + b6356dd commit dd44e3b
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 2 deletions.
2 changes: 1 addition & 1 deletion app/mod.html
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ <h1 class="success">matcha.css</h1>
</menu>
</nav>
</header>
<aside>
<aside data-expandable="☰ Quick navigation">
<nav><!-- Auto-generated by build --></nav>
</aside>
<main>
Expand Down
2 changes: 1 addition & 1 deletion styles/@istanbul-coverage/mod.css
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* Global */
body {
background: var(--bg-default);
background-color: var(--bg-default);
color: var(--default);
}
.quiet {
Expand Down
39 changes: 39 additions & 0 deletions styles/@layouts/mod.css
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ body.layout-simple {
column-gap: 1.5rem;
grid-template-areas:
"header"
"aside1"
"main"
"footer";
grid-template-rows: auto 1fr auto;
Expand Down Expand Up @@ -67,6 +68,33 @@ body.layout-simple > aside > nav:only-child {
margin: 0;
}

body.layout-simple > aside:nth-of-type(1)[data-expandable] {
margin-left: -1.5rem;
margin-right: -1.5rem;
grid-area: aside1;
max-height: var(--ly-aside-size-small);
display: block;
overflow: hidden;
}

body.layout-simple > aside:nth-of-type(1)[data-expandable]::before {
content: attr(data-expandable);
display: flex;
justify-content: center;
align-items: center;
height: var(--ly-aside-size-small);
cursor: pointer;
}

body.layout-simple > aside:nth-of-type(1)[data-expandable]:hover,
body.layout-simple > aside:nth-of-type(1)[data-expandable][data-expand] {
max-height: none;
}

body.layout-simple > aside:nth-of-type(1)[data-expandable]:hover::before {
color: var(--accent);
}

body.layout-simple > aside > nav:only-child > ul {
height: 100%;
}
Expand All @@ -76,6 +104,17 @@ body.layout-simple > aside a {
}

@media (min-width: 960px) {
body.layout-simple > aside:nth-of-type(1)[data-expandable]::before {
display: none;
}

body.layout-simple > aside:nth-of-type(1)[data-expandable] {
margin-left: 0;
margin-right: 0;
max-height: none;
overflow: unset;
}

body.layout-simple:has(> aside:nth-of-type(1)) {
padding-left: 0;
grid-template-areas:
Expand Down
5 changes: 5 additions & 0 deletions styles/@layouts/simple.html
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,11 @@ <h2 id="layouts-simple">
</article>
<template><!-- -brand margins from being trimmed --></template>
</div>
<p class="flash accent">
The <code data-hl="css">@media (default)</code> will hide <code data-hl="css">aside:nth-of-type(1)</code> on small screens, but it can be made visible again by adding a <code data-hl="html">data-expand</code> attribute.
To make it collapsible, use a <code data-hl="html">data-expandable</code> attribute instead.
The latter accepts a value to customize the text (e.g. <code>☰ Menu</code>).
</p>
</section>
<style>
.layout-header, .layout-footer, .layout-main, .layout-aside1, .layout-aside2 {
Expand Down
1 change: 1 addition & 0 deletions styles/@root/mod.css
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
/* Layouts*/
--ct-width: 1024px;
--ly-header-size: 3.5rem;
--ly-aside-size-small: 2.5rem;
--ly-brand: #e6edf3;
--ly-bg-brand: #010409;

Expand Down

0 comments on commit dd44e3b

Please sign in to comment.