feat: mobile responsive patches page

This commit is contained in:
afn 2022-11-30 23:20:59 -05:00
parent e54c4fb670
commit 63a36628ea
7 changed files with 129 additions and 36 deletions

View File

@ -48,6 +48,7 @@ body {
--grey-five: hsl(208, 30%, 75%); --grey-five: hsl(208, 30%, 75%);
--grey-six: #202126; --grey-six: #202126;
--grey-seven: #18191d; --grey-seven: #18191d;
--grey-eight: hsla(207, 30%, 75%, 0.577);
--bezier-one: cubic-bezier(0.25, 0.46, 0.45, 0.94); --bezier-one: cubic-bezier(0.25, 0.46, 0.45, 0.94);
} }
@ -97,7 +98,7 @@ h5 {
h6 { h6 {
color: var(--grey-five); color: var(--grey-five);
font-weight: 500; font-weight: 500;
font-size: 0.8rem; font-size: 0.85rem;
} }
/*---------------*/ /*---------------*/

View File

@ -1,25 +1,26 @@
<script lang="ts"> <script lang="ts">
import type { DocumentInfo } from '$lib/documentation.shared'; import type { DocumentInfo } from '$lib/documentation.shared';
export let info: DocumentInfo; export let info: DocumentInfo;
import { page } from '$app/stores';
</script> </script>
<!-- Always part of a list --> <!-- Always part of a list -->
<li> <li>
<div class="doc-section item"> <a href="/docs/{info.slug}">
<a href="/docs/{info.slug}"><h5>{info.title}</h5></a> <div class="doc-section item" class:selected={$page.url.pathname === `/docs/${info.slug}`}>
</div> <h5>{info.title}</h5>
</div>
</a>
</li> </li>
<style> <style>
a {
text-decoration: none;
}
a { li {
text-decoration: none; list-style: none;
} }
li {
list-style: none;
}
.item { .item {
padding: 0.6rem 1rem; padding: 0.6rem 1rem;
border-radius: 8px; border-radius: 8px;

View File

@ -1,7 +1,7 @@
<script lang="ts"> <script lang="ts">
export let title: string; export let title: string;
export let searchTerm: string | null; export let searchTerm: string | null;
export let searchTermFiltered: string | null export let searchTermFiltered: string | null;
import { fade } from 'svelte/transition'; import { fade } from 'svelte/transition';
import { quintOut } from 'svelte/easing'; import { quintOut } from 'svelte/easing';
@ -9,7 +9,6 @@
searchTerm = null; searchTerm = null;
searchTermFiltered = null; searchTermFiltered = null;
} }
</script> </script>
<div> <div>
@ -35,17 +34,21 @@
<style> <style>
#search { #search {
/* umm dont ask */
position: absolute; position: absolute;
height: 20px; z-index: 1;
transform: translate(60%, 60%); left: 23px;
top: 52px;
height: 24px;
} }
#clear { #clear {
position: absolute; position: absolute;
right: 42px;
top: 52px;
z-index: 1; z-index: 1;
height: 20px; height: 24px;
cursor: pointer; cursor: pointer;
transform: translate(1060%, 60%);
} }
.clear { .clear {
@ -55,19 +58,43 @@
input { input {
position: relative; position: relative;
display: flex; display: flex;
padding: 0.75rem 1rem; padding: 1rem 3rem;
border-radius: 12px; border-radius: 12px;
border: 1px solid var(--grey-three); border: 1px solid var(--grey-three);
background-color: transparent; background-color: transparent;
color: var(--accent-color); color: var(--grey-five);
padding-left: 2.5rem;
width: 100%; width: 100%;
} }
input::placeholder { input::placeholder {
color: var(--grey-five); color: var(--grey-eight);
font-size: 0.9rem;
} }
input:focus { input:focus {
outline: 1px solid var(--accent-color); outline: 1px solid var(--accent-color);
} }
@media (max-width: 768px) {
#search {
left: 26px;
top: 38px;
}
#clear {
right: 26px;
top: 38px;
}
input {
background-color: transparent;
border: none;
border-radius: 0;
border-bottom: 1px solid var(--grey-one);
}
input:focus {
border-radius: 8px;
}
}
</style> </style>

View File

@ -1,15 +1,18 @@
<script lang="ts"> <script lang="ts">
export let selectedPkg: string | boolean; export let selectedPkg: string | boolean;
export let name: string; export let name: string;
function handleClick() {
selectedPkg = selectedPkg === name ? false : name
window.scrollTo({ top: 0, behavior: 'smooth' })
}
</script> </script>
<!-- svelte-ignore a11y-click-events-have-key-events --> <!-- svelte-ignore a11y-click-events-have-key-events -->
<div <div
class="package" class="package"
class:selected={selectedPkg === name} class:selected={selectedPkg === name}
on:click={() => on:click={handleClick}
(selectedPkg = selectedPkg === name ? false : name) &&
window.scrollTo({ top: 0, behavior: 'smooth' })}
> >
<h5>{name}</h5> <h5>{name}</h5>
</div> </div>
@ -47,4 +50,25 @@
.package:not(.selected):hover h5 { .package:not(.selected):hover h5 {
color: var(--white); color: var(--white);
} }
@media (max-width: 768px) {
.package {
border-radius: 12px;
width: max-content;
background-color: transparent;
border: 1px solid var(--grey-three);
}
.package h5 {
overflow: hidden;
text-overflow: ellipsis;
}
.selected {
background-color: var(--accent-color);
}
.package:not(.selected):hover h5 {
color: var(--grey-five);
}
}
</style> </style>

View File

@ -86,6 +86,7 @@
background-color: var(--grey-two); background-color: var(--grey-two);
padding: 0.2rem 0.4rem; padding: 0.2rem 0.4rem;
display: flex; display: flex;
word-break: break-all;
} }
#option-title { #option-title {
@ -156,4 +157,10 @@
display: flex; display: flex;
flex-direction: column; flex-direction: column;
} }
@media (max-width: 768px) {
.patch-container {
border-radius: 16px;
}
}
</style> </style>

View File

@ -1,5 +1,5 @@
<div class="menu"> <div class="menu">
<div class="package-list"> <div class="slot">
<slot /> <slot />
</div> </div>
</div> </div>
@ -24,7 +24,7 @@
background-color: var(--accent-color); background-color: var(--accent-color);
} }
.package-list { .slot {
margin-top: 0.75rem; margin-top: 0.75rem;
display: flex; display: flex;
gap: 1rem; gap: 1rem;
@ -32,4 +32,12 @@
white-space: normal; white-space: normal;
word-break: break-all; word-break: break-all;
} }
@media (max-width: 768px) {
.menu {
padding: 0.75rem;
height: unset;
}
}
</style> </style>

View File

@ -68,8 +68,8 @@
<TreeMenu> <TreeMenu>
<!-- Must bind both variables: we get searchTerm from the text input, --> <!-- Must bind both variables: we get searchTerm from the text input, -->
<!-- and searchTermFiltered gets cleared with the clear button --> <!-- and searchTermFiltered gets cleared with the clear button -->
<Search bind:searchTerm bind:searchTermFiltered title="Search patches" on:keyup={debounce} /> <Search bind:searchTerm bind:searchTermFiltered title="Search patches" sticky={true} on:keyup={debounce} />
<span> <span class="packages">
{#each packages as pkg} {#each packages as pkg}
<TreeMenuButton bind:selectedPkg name={pkg} /> <TreeMenuButton bind:selectedPkg name={pkg} />
{/each} {/each}
@ -85,7 +85,7 @@
{#if filterByPackage(selectedPkg, patch.compatiblePackages) || !selectedPkg} {#if filterByPackage(selectedPkg, patch.compatiblePackages) || !selectedPkg}
<!-- ...same with search --> <!-- ...same with search -->
{#if search(patch) || !searchTermFiltered} {#if search(patch) || !searchTermFiltered}
<div in:fly={{ x: 10, easing: quintOut, duration: 750, delay: 100 }}> <div in:fly={{ y: 10, easing: quintOut, duration: 750, delay: 100 }}>
<PatchCell {patch} /> <PatchCell {patch} />
</div> </div>
{/if} {/if}
@ -105,10 +105,6 @@
gap: 1.5rem; gap: 1.5rem;
} }
aside {
padding-left: 0.75rem;
}
.patches-container { .patches-container {
margin-top: 6.7rem; margin-top: 6.7rem;
display: flex; display: flex;
@ -121,4 +117,33 @@
padding-bottom: 3rem; padding-bottom: 3rem;
padding-right: 0.75rem; padding-right: 0.75rem;
} }
@media (max-width: 768px) {
main {
grid-template-columns: none;
flex-direction: column;
margin-top: 4rem;
gap: 0;
}
.patches-container {
padding-left: 0.75rem;
padding-bottom: 1.25rem;
margin-top: 0;
gap: 0.75rem;
}
.packages {
display: flex;
flex-direction: column;
flex-wrap: wrap;
height: 2.75rem;
gap: 0.5rem;
overflow-x: scroll;
}
.packages::-webkit-scrollbar {
display: none;
}
}
</style> </style>