basic responsive navbar

This commit is contained in:
Ilion Beyst 2022-11-03 20:19:57 +01:00
parent 1afd5b5404
commit b1f8062b85
3 changed files with 82 additions and 28 deletions

View file

@ -52,6 +52,7 @@
font-size: 18px; font-size: 18px;
font-family: Helvetica, sans-serif; font-family: Helvetica, sans-serif;
padding: 4px 8px; padding: 4px 8px;
font-weight: 400;
} }
.account-href { .account-href {
@ -76,4 +77,12 @@
display: flex; display: flex;
align-items: center; align-items: center;
} }
// TODO: pretty hacky
@media screen and (max-width: 600px) {
.user-controls {
flex-direction: column;
align-items: flex-start;
}
}
</style> </style>

View file

@ -1,11 +1,22 @@
<script lang="ts"> <script lang="ts">
import { afterNavigate, beforeNavigate } from "$app/navigation";
import UserControls from "$lib/components/navbar/UserControls.svelte"; import UserControls from "$lib/components/navbar/UserControls.svelte";
import "./style.css"; import "./style.css";
let isExpanded = false;
function toggleExpanded() {
isExpanded = !isExpanded;
}
afterNavigate(() => {
isExpanded = false;
});
</script> </script>
<div class="outer-container"> <div class="outer-container">
<div class="navbar"> <div class="navbar" class:expanded={isExpanded}>
<div class="navbar-left"> <div class="navbar-left">
<div class="navbar-header"> <div class="navbar-header">
<a href="/">PlanetWars</a> <a href="/">PlanetWars</a>
@ -19,10 +30,17 @@
<div class="navbar-item"> <div class="navbar-item">
<a href="/docs/rules">How to play</a> <a href="/docs/rules">How to play</a>
</div> </div>
</div> <div class="navbar-divider"></div>
<div class="navbar-right"> <div class="navbar-item">
<UserControls /> <UserControls />
</div> </div>
</div>
<!-- <div class="navbar-right">
</div> -->
<div class="navbar-expand" on:click={toggleExpanded}>
expand
</div>
</div> </div>
<slot /> <slot />
</div> </div>
@ -30,6 +48,8 @@
<style lang="scss" global> <style lang="scss" global>
@import "src/styles/global.scss"; @import "src/styles/global.scss";
$navbarHeight: 48px;
.outer-container { .outer-container {
width: 100vw; width: 100vw;
height: 100vh; height: 100vh;
@ -38,7 +58,7 @@
} }
.navbar { .navbar {
height: 48px; height: $navbarHeight;
background-color: $bg-color; background-color: $bg-color;
border-bottom: 1px solid; border-bottom: 1px solid;
flex-shrink: 0; flex-shrink: 0;
@ -49,14 +69,20 @@
.navbar-left { .navbar-left {
display: flex; display: flex;
width: 100%;
} }
.navbar-right { .navbar-right {
display: flex; display: flex;
} }
.navbar-divider {
flex-grow: 1;
}
.navbar-header { .navbar-header {
margin: auto 0; height: $navbarHeight;
padding-top: 12px;
padding-right: 24px; padding-right: 24px;
} }
@ -69,11 +95,52 @@
margin: auto 0; margin: auto 0;
padding: 0 8px; padding: 0 8px;
} }
.navbar-item a { .navbar-item a {
font-size: 14px; font-size: 14px;
color: #fff; color: #fff;
text-decoration: none; text-decoration: none;
font-weight: 600; font-weight: 600;
} }
.navbar-expand {
color: white;
// margin: auto 0px;
display: none;
font-size: 16px;
padding-top: 14px;
}
@media screen and (max-width: 600px) {
.navbar-item {
display: none;
}
.navbar-divider {
display: none;
}
.navbar.expanded {
height: auto;
}
.navbar.expanded .navbar-left {
flex-direction: column;
}
.navbar.expanded .navbar-item {
display: block;
padding: 8px;
}
.navbar-right {
display: none;
}
.navbar.expanded .navbar-right {
display: flex;
}
.navbar-expand {
display: block;
}
}
</style> </style>

View file

@ -116,28 +116,6 @@
margin: 50px auto; margin: 50px auto;
} }
.header {
display: flex;
justify-content: space-between;
align-items: flex-end;
margin-bottom: 60px;
border-bottom: 1px solid black;
}
$header-space-above-line: 12px;
.bot-name {
font-size: 24pt;
margin-bottom: $header-space-above-line;
}
.owner-name {
font-size: 14pt;
text-decoration: none;
color: #333;
margin-bottom: $header-space-above-line;
}
.leaderboard { .leaderboard {
margin: 18px 10px; margin: 18px 10px;
text-align: center; text-align: center;