Skip to content

Commit

Permalink
Update site header/navigation
Browse files Browse the repository at this point in the history
  • Loading branch information
colepeters committed Sep 3, 2024
1 parent 37b266b commit 880e0a6
Show file tree
Hide file tree
Showing 14 changed files with 142 additions and 33 deletions.
11 changes: 9 additions & 2 deletions app/elements/aws-lite-logo.mjs
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
export default function AwsLiteLogo ({ html }) {
export default function AwsLiteLogo({ html }) {
return html`
<svg width="287" height="55" viewBox="0 0 287 55" fill="none" xmlns="http://www.w3.org/2000/svg">
<style>
svg {
display: block;
aspect-ratio: 287 / 55;
max-inline-size: min(75vw, 12em);
}
</style>
<svg viewBox="0 0 287 55" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M286.892 34.6576V35.7992L286.816 36.408C286.816 36.7632 286.638 36.9408 286.283 36.9408H261.168C260.306 36.9408 259.671 37.1944 259.265 37.7018C258.859 38.2092 258.859 38.8688 259.265 39.6806C259.874 40.7461 260.686 41.7101 261.701 42.5726C263.375 44.0947 265.43 44.8558 267.865 44.8558C269.946 44.8558 271.975 44.5006 273.954 43.7903C275.273 43.3337 276.389 42.598 277.303 41.5832C278.216 40.67 279.256 40.467 280.423 40.9744L284.304 42.9531C284.964 43.3083 285.37 43.7903 285.522 44.3992C285.674 44.9573 285.522 45.5154 285.065 46.0735C283.34 48.3567 281.159 50.1325 278.52 51.4009C275.324 53.0245 271.772 53.8363 267.865 53.8363C265.126 53.8363 262.589 53.3036 260.255 52.2381C257.972 51.2741 255.967 49.8534 254.242 47.9762C252.619 46.2003 251.3 44.0694 250.285 41.5832C249.321 39.1986 248.839 36.5856 248.839 33.7443C248.839 30.903 249.321 28.29 250.285 25.9054C251.3 23.4192 252.619 21.2883 254.242 19.5125C255.917 17.6859 257.921 16.2399 260.255 15.1744C262.589 14.1089 265.126 13.5762 267.865 13.5762C270.554 13.5762 273.091 14.1089 275.476 15.1744C277.708 16.2399 279.713 17.6859 281.488 19.5125C283.112 21.2883 284.431 23.4192 285.446 25.9054C286.41 28.29 286.892 30.903 286.892 33.7443V34.6576ZM275.704 26.6664C275.045 25.7532 274.334 25.0175 273.573 24.4594C271.95 23.2417 270.047 22.6328 267.865 22.6328C265.684 22.6328 263.806 23.2417 262.234 24.4594C261.371 25.0682 260.635 25.8039 260.026 26.6664C259.519 27.3768 259.443 27.9856 259.798 28.493C260.153 29.0004 260.788 29.254 261.701 29.254H274.106C275.019 29.254 275.654 29.0004 276.009 28.493C276.364 27.9856 276.262 27.3768 275.704 26.6664Z" fill="currentColor"/>
<path d="M234.808 38.3105C234.808 40.7967 235.087 42.4456 235.645 43.2574C236.152 44.0185 237.015 44.399 238.232 44.399H239.602L241.124 44.3229L242.342 44.1707H242.951C243.408 44.0692 243.636 44.2468 243.636 44.7034L244.701 50.4114C244.803 51.0203 244.701 51.5276 244.397 51.9335C244.093 52.3394 243.611 52.5677 242.951 52.6185L240.896 52.8468L237.623 52.999C235.898 52.999 234.275 52.7961 232.753 52.3902C231.281 52.035 230.064 51.2739 229.1 50.107C228.085 49.0415 227.324 47.5194 226.816 45.5406C226.258 43.5619 225.979 41.0504 225.979 38.0061V25.9813C225.979 25.271 225.776 24.7129 225.37 24.307C224.964 23.9011 224.406 23.6982 223.696 23.6982H222.326C221.616 23.6982 221.058 23.4952 220.652 23.0893C220.246 22.6834 220.043 22.1253 220.043 21.415V17.0769C220.043 16.3666 220.246 15.8085 220.652 15.4026C221.058 14.9967 221.616 14.7937 222.326 14.7937H223.696C224.406 14.7937 224.964 14.5908 225.37 14.1849C225.776 13.779 225.979 13.2209 225.979 12.5105V6.65037C225.979 5.94005 226.182 5.38194 226.588 4.97604C226.994 4.57014 227.552 4.36719 228.262 4.36719H232.524C233.235 4.36719 233.793 4.57014 234.199 4.97604C234.605 5.38194 234.808 5.94005 234.808 6.65037V12.5105C234.808 13.2209 235.011 13.779 235.416 14.1849C235.822 14.5908 236.38 14.7937 237.091 14.7937H241.581C242.291 14.7937 242.849 14.9967 243.255 15.4026C243.661 15.8085 243.864 16.3666 243.864 17.0769V21.415C243.864 22.1253 243.661 22.6834 243.255 23.0893C242.849 23.4952 242.291 23.6982 241.581 23.6982H237.091C236.38 23.6982 235.822 23.9011 235.416 24.307C235.011 24.7129 234.808 25.271 234.808 25.9813V38.3105Z" fill="currentColor"/>
<path d="M207.946 12.1304C206.322 12.1304 204.927 11.5469 203.76 10.3799C202.593 9.21297 202.01 7.81769 202.01 6.19409C202.01 4.5705 202.593 3.17522 203.76 2.00826C204.927 0.841294 206.322 0.257812 207.946 0.257812C208.758 0.257812 209.544 0.410025 210.305 0.714449C210.661 0.917399 210.99 1.12035 211.295 1.3233C211.65 1.52625 211.954 1.75457 212.208 2.00826C212.665 2.46489 213.071 3.09911 213.426 3.91091C213.73 4.62123 213.882 5.38229 213.882 6.19409C213.882 7.81769 213.299 9.21297 212.132 10.3799C210.965 11.5469 209.57 12.1304 207.946 12.1304ZM205.739 14.7941H210.077C210.787 14.7941 211.345 14.997 211.751 15.4029C212.157 15.8088 212.36 16.3669 212.36 17.0773V50.7162C212.36 51.4265 212.157 51.9846 211.751 52.3905C211.345 52.7964 210.787 52.9994 210.077 52.9994H205.739C205.029 52.9994 204.471 52.7964 204.065 52.3905C203.659 51.9846 203.456 51.4265 203.456 50.7162V17.0773C203.456 16.3669 203.659 15.8088 204.065 15.4029C204.471 14.997 205.029 14.7941 205.739 14.7941Z" fill="currentColor"/>
Expand Down
2 changes: 0 additions & 2 deletions app/elements/begin-masthead.mjs

This file was deleted.

1 change: 0 additions & 1 deletion app/elements/masthead/begin-logo.mjs

This file was deleted.

1 change: 0 additions & 1 deletion app/elements/masthead/deploy-button.mjs

This file was deleted.

1 change: 0 additions & 1 deletion app/elements/masthead/product-link.mjs

This file was deleted.

1 change: 0 additions & 1 deletion app/elements/masthead/section-dropdown.mjs

This file was deleted.

1 change: 0 additions & 1 deletion app/elements/masthead/section-link.mjs

This file was deleted.

1 change: 0 additions & 1 deletion app/elements/masthead/slice.mjs

This file was deleted.

1 change: 0 additions & 1 deletion app/elements/masthead/symbols.mjs

This file was deleted.

133 changes: 122 additions & 11 deletions app/elements/site-header.mjs
Original file line number Diff line number Diff line change
@@ -1,17 +1,128 @@
export default function SiteMasthead ({ html }) {
export default function SiteHeader({ html, state }) {
const { store } = state
const { path } = store

const checkActive = route => path.split('/')[1] === route ? 'active' : ''

Check failure on line 5 in app/elements/site-header.mjs

View workflow job for this annotation

GitHub Actions / build

'checkActive' is assigned a value but never used

Check failure on line 5 in app/elements/site-header.mjs

View workflow job for this annotation

GitHub Actions / build

'checkActive' is assigned a value but never used

return html`
<style scope="global">
:root {
--nav-height: 4em;
}
@media (width < 52em) {
body:has(#mobile-menu-toggle:checked) main {
filter: blur(10px) contrast(0.66);
backdrop-filter: brightness(1.5);
}
}
</style>
<style>
begin-masthead {
--inline-padding: var(--space-0);
--max-inline-size: var(--site-max-width);
:host {
background-color: var(--accent);
display: block;
position: fixed;
inset-block-start: 0;
inset-inline: 0;
z-index: 4;
}
header {
max-inline-size: var(--site-max-width);
block-size: var(--nav-height);
}
aws-lite-logo svg {
color: white;
block-size: 1.5em;
}
@media screen and (min-width: 52em){
/* On larger screens, use a semitransparent, tinted, blurred background */
/* We don't do this on smaller screens because the stacked mobile menu inheriting
* the background/backdrop filter is broken in Chrome (their bug) and glitchy on Safari + FF */
:host {
background-color: color-mix(in srgb, var(--accent) 80%, transparent);
backdrop-filter: blur(10px);
}
}
/* Mobile menu + toggle UI */
@media (width < 56em) {
label[for="mobile-menu-toggle"] figure:after {
content: url("data:image/svg+xml;utf8,<svg width='24px' height='24px' stroke-width='2' viewBox='0 0 24 24' fill='none' xmlns='http://www.w3.org/2000/svg' color='white'><path d='M3 5H21' stroke='white' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'></path><path d='M3 12H21' stroke='white' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'></path><path d='M3 19H21' stroke='white' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'></path></svg> "); /* burger icon */
cursor: pointer;
display: flex;
align-items: center;
justify-content: end;
inline-size: 2.75em;
aspect-ratio: 22 / 21;
}
#mobile-menu-toggle:checked ~ label[for="mobile-menu-toggle"] figure:after {
content: url("data:image/svg+xml;utf8,<svg width='24px' height='24px' stroke-width='2' viewBox='0 0 24 24' fill='none' xmlns='http://www.w3.org/2000/svg' color='white'><path d='M6.75827 17.2426L12.0009 12M17.2435 6.75736L12.0009 12M12.0009 12L6.75827 6.75736M12.0009 12L17.2435 17.2426' stroke='white' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'></path></svg>"); /* close icon */
}
#mobile-menu-toggle:checked ~ label .expanded { display: inline; }
#mobile-menu-toggle:checked ~ label .collapsed { display: none; }
#mobile-menu-toggle:not(:checked) ~ label .expanded { display: none; }
#mobile-menu-toggle:not(:checked) ~ label .collapsed { display: inline; }
#mobile-menu-toggle ~ site-nav {
display: none;
}
#mobile-menu-toggle:checked ~ site-nav {
display: block;
}
site-nav {
background-color: var(--back);
border-block-end: 1px solid var(--muted-accent);
inset-block-start: var(--nav-height);
max-block-size: 75dvh;
}
}
</style>
<begin-masthead product="aws-lite" breakpoint="52em" active="products">
<span slot="product-page">Docs</span>
<site-nav slot="product-nav"></site-nav>
<div slot="product-nav-lg" class="flex align-items-center">
<masthead-product-link active href="/">Docs</masthead-product-link>
</div>
</begin-masthead>
<header class="
flex
align-items-center
gap0
pi0
mi-auto
leading0
">
<a href="/">
<h1>
<span class="screenreader-only">aws-lite</span>
<aws-lite-logo></aws-lite-logo>
</h1>
</a>
<!-- Mobile menu toggle -->
<input
type="checkbox"
role="button"
aria-haspopup="true"
id="mobile-menu-toggle"
name="mobile menu toggle"
class="clip absolute opacity-0 hidden-lg"
autocomplete="off"
/>
<label
for="mobile-menu-toggle"
class="mis-auto hidden-lg"
>
<figure aria-hidden="true"></figure>
<span class="clip">Site navigation</span>
<span class="clip expanded">expanded</span>
<span class="clip collapsed">collapsed</span>
</label>
<site-nav class="fixed inset-i-0 overflow-y-scroll leading4 hidden-lg"></site-nav>
</header>
`
}

8 changes: 4 additions & 4 deletions app/elements/site-nav.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import url from 'url'
const __dirname = url.fileURLToPath(new URL('.', import.meta.url))
let services

export default function SiteNav ({ html, state }) {
export default function SiteNav({ html, state }) {
const { store } = state
const { page } = store

Expand Down Expand Up @@ -54,8 +54,8 @@ export default function SiteNav ({ html, state }) {
<style>
:host {
display: block;
color: var(--fore-dark);
padding: var(--space-0);
color: var(--fore);
padding: var(--space-0) var(--space--2);
}
li a {
Expand Down Expand Up @@ -85,7 +85,7 @@ export default function SiteNav ({ html, state }) {
@media screen and (min-width: 52em) {
:host {
color: var(--fore);
padding: var(--space-0);
}
li {
Expand Down
8 changes: 4 additions & 4 deletions app/head.mjs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { getStyles } from '@enhance/arc-plugin-styles'
import { getStyles } from '@enhance/arc-plugin-styles'
import SyntaxTheme from './lib/syntax-theme.mjs'

const { linkTag } = getStyles
const ogImage = '/_public/img/aws-lite-open-graph.png'

export default function Head (state) {
export default function Head(state) {
let title = state.store.doc?.frontmatter?.title
title = `${title ? title + ' - ' : ''}aws-lite`
const description = state.store.doc?.frontmatter?.description || ''
Expand Down Expand Up @@ -71,7 +71,7 @@ export default function Head (state) {
}
html {
scroll-padding: calc(var(--masthead-max-height) + var(--space-1));
scroll-padding: calc(var(--nav-height) + var(--space-1));
}
@media (prefers-reduced-motion: no-preference) {
Expand All @@ -83,7 +83,7 @@ export default function Head (state) {
body {
background-color: var(--back);
color: var(--fore);
margin-block-start: var(--masthead-max-height);
margin-block-start: var(--nav-height);
}
:root {
Expand Down
4 changes: 2 additions & 2 deletions app/pages/$$.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
site-nav,
table-of-contents {
position: sticky;
inset-block-start: var(--masthead-max-height);
block-size: calc(100dvh - var(--masthead-max-height));
inset-block-start: var(--nav-height);
block-size: calc(100dvh - var(--nav-height));
overflow-y: scroll;
}
}
Expand Down
2 changes: 1 addition & 1 deletion styleguide.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"scaleMax": "minor-third"
},
"spaceScale": {
"steps": 6,
"steps": 9,
"viewportMin": 320,
"viewportMax": 1500,
"baseMin": 16,
Expand Down

0 comments on commit 880e0a6

Please sign in to comment.