mirror of
https://github.com/revanced/revanced-website.git
synced 2025-04-30 22:54:31 +02:00
parent
da9e8444f2
commit
4a6567ef77
@ -3,6 +3,13 @@
|
|||||||
import { quadInOut } from 'svelte/easing';
|
import { quadInOut } from 'svelte/easing';
|
||||||
export let modalOpen = false;
|
export let modalOpen = false;
|
||||||
export let fullscreen = false;
|
export let fullscreen = false;
|
||||||
|
|
||||||
|
let element: HTMLDivElement;
|
||||||
|
let y = 0;
|
||||||
|
|
||||||
|
function parseScroll() {
|
||||||
|
y = element.scrollTop;
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
{#if modalOpen}
|
{#if modalOpen}
|
||||||
@ -17,13 +24,16 @@
|
|||||||
class="modal"
|
class="modal"
|
||||||
role="dialog"
|
role="dialog"
|
||||||
class:fullscreen
|
class:fullscreen
|
||||||
|
class:scrolled={y > 10}
|
||||||
aria-modal="true"
|
aria-modal="true"
|
||||||
|
bind:this={element}
|
||||||
|
on:scroll={parseScroll}
|
||||||
transition:fade={{ easing: quadInOut, duration: 150 }}
|
transition:fade={{ easing: quadInOut, duration: 150 }}
|
||||||
>
|
>
|
||||||
<div class="top">
|
<div class="top">
|
||||||
<div class="title" class:hasIcon={$$slots.icon}>
|
<div class="title" class:hasIcon={$$slots.icon}>
|
||||||
{#if fullscreen}
|
{#if fullscreen}
|
||||||
<button on:click={() => (modalOpen = !modalOpen)}>
|
<button id="back-button" on:click={() => (modalOpen = !modalOpen)}>
|
||||||
<img src="../icons/back.svg" id="back" alt="back" />
|
<img src="../icons/back.svg" id="back" alt="back" />
|
||||||
</button>
|
</button>
|
||||||
{/if}
|
{/if}
|
||||||
@ -51,7 +61,6 @@
|
|||||||
</div>
|
</div>
|
||||||
{/if}
|
{/if}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
{/if}
|
{/if}
|
||||||
|
|
||||||
@ -74,12 +83,9 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
.title {
|
.title {
|
||||||
position: sticky;
|
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
gap: 1rem;
|
gap: 1rem;
|
||||||
top: 0;
|
|
||||||
left: 0;
|
|
||||||
width: 100%;
|
width: 100%;
|
||||||
background-color: var(--grey-six);
|
background-color: var(--grey-six);
|
||||||
margin-bottom: 8px;
|
margin-bottom: 8px;
|
||||||
@ -93,6 +99,9 @@
|
|||||||
width: 100%;
|
width: 100%;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#back-button {
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
|
||||||
.hasIcon {
|
.hasIcon {
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
@ -135,12 +144,27 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
.fullscreen {
|
.fullscreen {
|
||||||
|
padding: 0;
|
||||||
max-height: 100%;
|
max-height: 100%;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
border-radius: 0;
|
border-radius: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.fullscreen .slot {
|
||||||
|
padding: 0 32px 32px;
|
||||||
|
}
|
||||||
|
|
||||||
.fullscreen .title {
|
.fullscreen .title {
|
||||||
justify-content: flex-start;
|
justify-content: flex-start;
|
||||||
|
position: sticky;
|
||||||
|
padding: 32px;
|
||||||
|
padding-bottom: 0.75rem;
|
||||||
|
top: 0;
|
||||||
|
left: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.fullscreen.scrolled .title {
|
||||||
|
border-bottom: 1px solid var(--grey-three);
|
||||||
}
|
}
|
||||||
|
|
||||||
.slot {
|
.slot {
|
||||||
@ -154,5 +178,3 @@
|
|||||||
display: none;
|
display: none;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
|
|
||||||
|
@ -11,7 +11,10 @@
|
|||||||
function clear() {
|
function clear() {
|
||||||
searchTerm = '';
|
searchTerm = '';
|
||||||
searchTermFiltered = '';
|
searchTermFiltered = '';
|
||||||
goto($page.url.pathname)
|
|
||||||
|
const url = new URL($page.url);
|
||||||
|
url.searchParams.delete('s');
|
||||||
|
goto(url.pathname + url.search);
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
@ -85,6 +88,6 @@
|
|||||||
|
|
||||||
input:focus::placeholder {
|
input:focus::placeholder {
|
||||||
outline: none;
|
outline: none;
|
||||||
color: var(--accent-color)
|
color: var(--accent-color);
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
@ -3,16 +3,15 @@
|
|||||||
import { quintOut } from 'svelte/easing';
|
import { quintOut } from 'svelte/easing';
|
||||||
import { page } from '$app/stores';
|
import { page } from '$app/stores';
|
||||||
|
|
||||||
import type { PageData } from './$types';
|
|
||||||
import type { Patch } from '$lib/types';
|
import type { Patch } from '$lib/types';
|
||||||
|
|
||||||
import { createQuery } from '@tanstack/svelte-query';
|
import { createQuery } from '@tanstack/svelte-query';
|
||||||
import { queries } from '$data/api';
|
import { queries } from '$data/api';
|
||||||
|
|
||||||
import Meta from '$lib/components/Meta.svelte';
|
import Meta from '$lib/components/Meta.svelte';
|
||||||
import PackageMenu from '../PackageMenu.svelte';
|
import PackageMenu from './PackageMenu.svelte';
|
||||||
import Package from '../Package.svelte';
|
import Package from './Package.svelte';
|
||||||
import PatchItem from '../PatchItem.svelte';
|
import PatchItem from './PatchItem.svelte';
|
||||||
import Footer from '$layout/Footer/FooterHost.svelte';
|
import Footer from '$layout/Footer/FooterHost.svelte';
|
||||||
import Search from '$lib/components/Search.svelte';
|
import Search from '$lib/components/Search.svelte';
|
||||||
import FilterChip from '$lib/components/FilterChip.svelte';
|
import FilterChip from '$lib/components/FilterChip.svelte';
|
||||||
@ -21,16 +20,14 @@
|
|||||||
|
|
||||||
const query = createQuery(['patches'], queries.patches);
|
const query = createQuery(['patches'], queries.patches);
|
||||||
|
|
||||||
export let data: PageData;
|
$: selectedPkg = $page.url.searchParams.get('pkg');
|
||||||
$: ({ selectedPkg } = data);
|
|
||||||
|
|
||||||
// Search whatever the s query is from the url
|
|
||||||
let searchTerm = $page.url.searchParams.get('s');
|
let searchTerm = $page.url.searchParams.get('s');
|
||||||
let searchTermFiltered = searchTerm
|
let searchTermFiltered = searchTerm
|
||||||
?.replace(/\./g, '')
|
?.replace(/\./g, '')
|
||||||
.replace(/\s/g, '')
|
.replace(/\s/g, '')
|
||||||
.replace(/-/g, '')
|
.replace(/-/g, '')
|
||||||
.toLowerCase();
|
.toLowerCase();
|
||||||
|
|
||||||
let timeout: ReturnType<typeof setTimeout>;
|
let timeout: ReturnType<typeof setTimeout>;
|
||||||
let mobilePackages = false;
|
let mobilePackages = false;
|
||||||
|
|
||||||
@ -80,11 +77,19 @@
|
|||||||
.toLowerCase();
|
.toLowerCase();
|
||||||
// Update search URL params
|
// Update search URL params
|
||||||
// must use history.pushState instead of goto(), as goto() unselects the search bar
|
// must use history.pushState instead of goto(), as goto() unselects the search bar
|
||||||
window.history.pushState(
|
const url = new URL(window.location.href);
|
||||||
null,
|
url.pathname = '/patches';
|
||||||
'',
|
|
||||||
`${window.location.href.split('?')[0]}${searchTerm ? '?s=' + searchTerm : ''}`
|
const params = new URLSearchParams();
|
||||||
);
|
if (selectedPkg) {
|
||||||
|
params.set('pkg', selectedPkg);
|
||||||
|
}
|
||||||
|
if (searchTerm) {
|
||||||
|
params.set('s', searchTerm);
|
||||||
|
}
|
||||||
|
|
||||||
|
url.search = params.toString();
|
||||||
|
window.history.pushState(null, '', url.toString());
|
||||||
}, 500);
|
}, 500);
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
@ -1,20 +1,25 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { goto } from '$app/navigation';
|
import { goto } from '$app/navigation';
|
||||||
|
|
||||||
export let selectedPkg: string | undefined;
|
export let selectedPkg: string | null;
|
||||||
export let name: string;
|
export let name: string;
|
||||||
export let searchTerm: string | null;
|
export let searchTerm: string | null;
|
||||||
|
|
||||||
function handleClick() {
|
function handleClick() {
|
||||||
// Assign the selected package. If it's already selected, deselect it.
|
// Assign the selected package. If it's already selected, deselect it.
|
||||||
let path = '/patches';
|
const url = new URL(window.location.href);
|
||||||
|
const params = new URLSearchParams();
|
||||||
|
url.pathname = '/patches';
|
||||||
|
|
||||||
if (selectedPkg !== name && name !== 'All packages') {
|
if (selectedPkg !== name && name !== 'All packages') {
|
||||||
path += `/${name}`;
|
params.set('pkg', name);
|
||||||
}
|
}
|
||||||
if (searchTerm) {
|
if (searchTerm) {
|
||||||
path += `?s=${searchTerm}`
|
params.set('s', searchTerm);
|
||||||
};
|
}
|
||||||
goto(path);
|
url.search = params.toString();
|
||||||
|
goto(url.pathname + url.search);
|
||||||
|
|
||||||
window.scrollTo({ top: 0, behavior: 'smooth' });
|
window.scrollTo({ top: 0, behavior: 'smooth' });
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
@ -1,8 +0,0 @@
|
|||||||
import type { PageLoad } from './$types';
|
|
||||||
|
|
||||||
export const prerender = false;
|
|
||||||
|
|
||||||
export const load: PageLoad = async ({ params }) => {
|
|
||||||
const selectedPkg = params.package || undefined;
|
|
||||||
return { selectedPkg };
|
|
||||||
};
|
|
Loading…
x
Reference in New Issue
Block a user