tweak top nav

pull/1921/head
Rich Harris 7 years ago
parent abf570521e
commit 53cee5064f

@ -6,6 +6,7 @@
export let segment; export let segment;
let open = false; let open = false;
let visible = true;
// TODO remove this post-https://github.com/sveltejs/svelte/issues/1914 // TODO remove this post-https://github.com/sveltejs/svelte/issues/1914
let ul; let ul;
@ -28,6 +29,14 @@
}); });
}; };
}); });
let last_scroll = 0;
function handle_scroll() {
const scroll = window.pageYOffset;
visible = (scroll < 50 || scroll < last_scroll);
last_scroll = scroll;
}
</script> </script>
<style> <style>
@ -45,6 +54,12 @@
font-family: var(--font); font-family: var(--font);
z-index: 10; z-index: 10;
user-select: none; user-select: none;
transform: translate(0,calc(-100% - 1rem));
transition: transform 0.2s;
}
header.visible {
transform: none;
} }
nav { nav {
@ -64,15 +79,21 @@
} }
h2 { h2 {
display: block;
text-transform: uppercase; text-transform: uppercase;
letter-spacing: 0.1em;
font-weight: 300; font-weight: 300;
font-size: 2.8rem;
letter-spacing: .12em;
line-height: 1;
margin: 0;
top: .1rem;
} }
.primary { .primary {
list-style: none; list-style: none;
font-family: var(--font); font-family: var(--font);
margin: 0; margin: 0;
line-height: 1;
} }
li { li {
@ -87,7 +108,7 @@
ul { ul {
position: relative; position: relative;
padding: 0 2em 0 0; padding: 0 2em 0 0;
background: url(/icons/chevron.svg) calc(100% - 1em) 70% no-repeat; background: url(/icons/chevron.svg) calc(100% - 1em) 0.05em no-repeat;
background-size: 1em 1em; background-size: 1em 1em;
} }
@ -126,7 +147,7 @@
} }
ul.open li a { ul.open li a {
padding: 2rem .7rem 0 .8rem; padding: 2.3rem .7rem 0 .8rem;
display: block; display: block;
} }
@ -152,14 +173,6 @@
padding: 0.5em 0; padding: 0.5em 0;
} }
.logotype {
display: block;
font-size: 2.8rem;
letter-spacing: .12em;
line-height: 1;
margin: 0;
}
.home { .home {
position: relative; position: relative;
top: 0; top: 0;
@ -215,12 +228,12 @@
} }
</style> </style>
<svelte:window on:click="{() => open = false}"/> <svelte:window on:click="{() => open = false}" on:scroll={handle_scroll}/>
<header> <header class:visible="{visible || open}">
<nav> <nav>
<a rel="prefetch" href='.' class="home" title='Homepage'> <a rel="prefetch" href='.' class="home" title='Homepage'>
<h2 class='logotype'>Svelte</h2> <h2>Svelte</h2>
</a> </a>
<ul <ul

@ -91,20 +91,20 @@
position: absolute; position: absolute;
bottom: 0; bottom: 0;
left: 0; left: 0;
width: 2em; width: 3.4rem;
height: 2em; height: 3.4rem;
} }
aside.open { aside.open {
width: calc(100vw - 1.6rem); width: calc(100vw - 1.6rem);
height: calc(100vh - var(--nav-h) - 1.8rem); height: calc(100vh - var(--nav-h) - 7rem);
} }
aside.open::before { aside.open::before {
content: ''; content: '';
position: absolute; position: absolute;
left: 0; left: 0;
bottom: calc(100vh - var(--nav-h) - 5.6rem); bottom: calc(100vh - var(--nav-h) - 10.8rem);
width: 100%; width: 100%;
height: 2em; height: 2em;
background: linear-gradient(to top, rgba(255,255,255,0) 0%, rgba(255,255,255,0.7) 50%, rgba(255,255,255,1) 100%); background: linear-gradient(to top, rgba(255,255,255,0) 0%, rgba(255,255,255,0.7) 50%, rgba(255,255,255,1) 100%);
@ -116,7 +116,7 @@
content: ''; content: '';
position: absolute; position: absolute;
left: 0; left: 0;
bottom: 2em; bottom: 1.9em;
width: 100%; width: 100%;
height: 2em; height: 2em;
background: linear-gradient(to bottom, rgba(255,255,255,0) 0%, rgba(255,255,255,0.7) 50%, rgba(255,255,255,1) 100%); background: linear-gradient(to bottom, rgba(255,255,255,0) 0%, rgba(255,255,255,0.7) 50%, rgba(255,255,255,1) 100%);
@ -128,7 +128,7 @@
font-family: var(--font); font-family: var(--font);
overflow-y: auto; overflow-y: auto;
width: calc(100vw - 4.8rem); width: calc(100vw - 4.8rem);
height: calc(100vh - var(--nav-h) - 5.6rem); height: calc(100vh - var(--nav-h) - 10.8rem);
padding: 2em 0; padding: 2em 0;
bottom: 2em; bottom: 2em;
} }

Loading…
Cancel
Save