feat: create the barebone following header

This commit is contained in:
Adrien Marquès 2022-10-04 19:08:36 +02:00
parent 0b3c4654ba
commit d154d27c37
Signed by: xdrm-brackets
GPG Key ID: D75243CA236D825E
2 changed files with 58 additions and 5 deletions

View File

@ -25,7 +25,7 @@
</div> </div>
<button v-show='this.sel != null'>Browse projects</button> <input type='button' v-show='this.sel != null' value='Browse projects' @click='browse()'/>
</div> </div>
</template> </template>
@ -135,6 +135,10 @@
this.sel = null; this.sel = null;
} }
} }
protected browse(){
document.querySelector("#timeline")!.scrollIntoView();
}
} }
</script> </script>
@ -143,6 +147,7 @@
<style scoped lang="scss"> <style scoped lang="scss">
$page-margin: 3rem; $page-margin: 3rem;
$bottom-space: 10vh;
#skill-picker { #skill-picker {
display: block; display: block;
@ -150,7 +155,7 @@
top: 0; top: 0;
left: 0; left: 0;
width: 100vw; width: 100vw;
height: 100vh; height: #{100vh + $bottom-space};
background: linear-gradient(0, #564ba4, #745cfc); background: linear-gradient(0, #564ba4, #745cfc);
@ -205,10 +210,10 @@
} }
} }
button { input {
display: block; display: block;
position: absolute; position: absolute;
top: calc( 100% - #{$page-margin} ); top: calc( 100% - #{$bottom-space} - #{$page-margin} );
left: 50%; left: 50%;
padding: .6em 2em; padding: .6em 2em;

View File

@ -1,6 +1,9 @@
<template> <template>
<div id='timeline'> <div id='timeline'>
<div id='search-header' ref='header'>
</div>
<template class='project' v-for='(proj) of projects'> <template class='project' v-for='(proj) of projects'>
<div :key="'start-'+proj.name" class='start'> <div :key="'start-'+proj.name" class='start'>
{{ proj.started_at | short_date }} {{ proj.started_at | short_date }}
@ -112,6 +115,32 @@
export default class Timeline extends Vue { export default class Timeline extends Vue {
private projects: Project[] = Projects; private projects: Project[] = Projects;
private skills: tSkills = Skills; private skills: tSkills = Skills;
private mounted() {
document.body.addEventListener('scroll', this.onScroll, { passive: true });
}
private onScroll(e: Event) {
const target = e.target as HTMLElement;
const header = this.$refs.header as HTMLElement;
if( target == undefined || header == undefined ){
return;
}
const el = this.$el as HTMLElement;
if( el == null ){
return;
}
// when scrolling after this limit, make the header fixed
const limit = el.offsetTop;
if( target.scrollTop >= limit ){
header.classList.add('fixed');
} else {
header.classList.remove('fixed');
}
}
} }
</script> </script>
@ -122,6 +151,25 @@
$icon-width: 2.3rem; $icon-width: 2.3rem;
$space-width: 1rem; $space-width: 1rem;
$bg-color: #202228; $bg-color: #202228;
$header-height: 6rem;
#search-header {
display: block;
position: absolute;
top: 0;
left: 0;
width: 100%;
height: $header-height;
background: #564ba4;
background: #fff;
z-index: 500;
&.fixed {
position: fixed;
}
}
#timeline { #timeline {
display: grid; display: grid;
@ -139,7 +187,7 @@
padding: 0 5rem; padding: 0 5rem;
padding-top: 2em; padding-top: #{$header-height + 2rem};
.start { grid-column: 1 / 2; } .start { grid-column: 1 / 2; }
.name { grid-column: 3 / 6; } .name { grid-column: 3 / 6; }