feat: nicer patches + filtering, use stores again

This commit is contained in:
afn
2022-10-23 00:27:41 -04:00
parent 30d9f076ff
commit 831c4d9d47
18 changed files with 484 additions and 296 deletions

View File

@ -1,5 +1,5 @@
<script lang="ts">
import NavHost from "$lib/components/molecules/Navigation.svelte";
import NavHost from "$lib/components/molecules/NavHost.svelte";
import '../app.css';
</script>

View File

@ -1,10 +0,0 @@
import type { Repository } from '$lib/types';
export type APIOutput = { repositories: Repository[] };
export async function load({
fetch
}): APIOutput {
const response = await fetch('https://releases.rvcd.win/contributors');
return await response.json();
}

View File

@ -1,20 +1,33 @@
<script lang="ts">
import type { APIOutput } from '../+layout';
import ContributorHost from '$lib/components/molecules/ContributorHost.svelte';
import Footer from '$lib/components/molecules/Footer.svelte';
import { onMount } from 'svelte';
import { fly } from 'svelte/transition';
import { quintOut } from 'svelte/easing';
// From the layout hydration. See +layout.ts
export let data: APIOutput;
import type { ContribData } from '../../data/ContributorsStore';
import { ContributorsStore } from '../../data/ContributorsStore';
import ContributorHost from '$lib/components/molecules/ContributorHost.svelte';
import Footer from '$lib/components/molecules/Footer.svelte';
let data: ContribData;
onMount(() => {
ContributorsStore.subscribe(async (e: Promise<ContribData>) => {
data = await e;
});
});
</script>
<div class="wrapper contrib-grid">
{#if data}
{#each data.repositories as { contributors, name }}
<div in:fly={{ y: 10, easing: quintOut, duration: 750 }}>
<ContributorHost contribs={contributors} repo={name} />
</div>
{/each}
{/if}
</div>
<style>

View File

@ -1,159 +1,109 @@
<script lang="ts">
import type { Output } from "./+page";
import Patch from "$lib/components/atoms/Patch.svelte";
import Footer from "$lib/components/molecules/Footer.svelte";
import { fly } from 'svelte/transition';
import { quintOut } from 'svelte/easing';
import { onMount } from 'svelte';
import { fly } from 'svelte/transition';
import { quintOut } from 'svelte/easing';
export let data: Output;
import type { Patch } from '$lib/types';
import type { PatchesData } from '../../data/PatchesStore';
import { PatchesStore } from '../../data/PatchesStore';
let { patches, packages } = data;
import TreeMenu from '$lib/components/molecules/TreeMenu.svelte';
import TreeMenuButton from '$lib/components/atoms/TreeMenuButton.svelte';
import PatchCell from '$lib/components/atoms/PatchCell.svelte';
import Footer from '$lib/components/molecules/Footer.svelte';
let current: boolean | Object = false;
let patches: Patch[]
let packages: string[];
let current: boolean = false;
onMount(() => {
PatchesStore.subscribe(async (e: Promise<PatchesData>) => {
({ patches, packages } = await e);
});
});
function search(findTerm, array){
for (let i = 0; i < array.length; i++) {
if (array[i].name === findTerm) {
return true;
};
};
return false;
};
</script>
<svelte:head>
<title>Revanced - Patches</title>
<meta content="Revanced - Patches" name="og:title" />
<meta content="Revanced - Patches" name="twitter:title" />
</svelte:head>
<section>
<aside class="menu">
<div in:fly="{{ y: 10, easing: quintOut, duration: 750 }}">
<h5>PACKAGES</h5>
<hr/>
<div class="package-list">
{#each packages as pkg}
<div
class="package"
class:selected={ current === pkg }
on:click={ () => current = (current === pkg) ? false : pkg }
>
<h3>{pkg}</h3>
<aside in:fly={{ y: 10, easing: quintOut, duration: 750 }}>
<TreeMenu title="packages">
{#if packages}
{#each packages as pkg}
<TreeMenuButton bind:current name={pkg} />
{/each}
{/if}
</TreeMenu>
</aside>
<div class="patches-container">
{#if patches}
{#each patches as { name, description, version, options, compatiblePackages }, i}
{#if search(current, compatiblePackages) || !current}
<div in:fly={{ x: 10, easing: quintOut, duration: 750, delay: -(300 * 0.85 ** i) + 300 }}>
<PatchCell
bind:current
{name}
{description}
{version}
{options}
{compatiblePackages}
hasPatchOptions={!!options.length}
/>
</div>
{/each}
</div>
</div>
</aside>
<div class="patches-list patches-container">
{#each patches as patch, i}
<div in:fly="{{ x: 10, easing: quintOut, duration: 750, delay: -(300*(0.85**i))+300}}">
<Patch
name={patch.name
// im sorry
.replace(/-/g, ' ')
.replace(/(?:^|\s)\S/g, x => x.toUpperCase())
.replace(/Microg/g, 'MicroG')
.replace(/Hdr/g, 'HDR')
.replace(/Sponsorblock/g, 'SponsorBlock')
.replace(/Tiktok/g, 'TikTok')
}
desc={patch.description}
ver={patch.version}
hasPatchOptions={!!patch.options.length}
/>
</div>
{/each}
</div>
{/if}
{/each}
{/if}
</div>
</section>
<Footer />
<Footer/>
<style>
section {
padding-top: 4.25rem;
margin-inline: auto;
width: min(95%, 100rem);
display:grid;
grid-template-columns: 300px 3fr;
gap: 1.5rem;
padding-bottom: 3rem;
}
section {
margin-inline: auto;
width: min(95%, 100rem);
display: grid;
grid-template-columns: 300px 3fr;
gap: 1.5rem;
padding-bottom: 3rem;
}
h5 {
font-weight: 500;
}
h3 {
font-size: 0.9rem;
}
.patches-container {
display: flex;
flex-direction: column;
gap: 0.75rem;
width:100%;
padding-top: 3rem;
position: sticky;
z-index:1;
.patches-container {
margin-top: 7.5rem;
display: flex;
flex-direction: column;
gap: 0.5rem;
width: 100%;
position: sticky;
z-index: 1;
min-height: calc(100vh - 7.5rem);
}
/*
pulsing todo:
@keyframes pulse {
0% {
background-position: right;
}
}
aside {
height: calc(100vh - 7.5rem);
width:100%;
padding: 0px 10px 30px 10px;
display: flex;
flex-direction: column;
gap: 1rem;
position: sticky;
top: 7.5rem;
overflow-y: scroll;
}
hr {
display: block;
height: 1px;
border: 0;
border-top: 1px solid var(--grey-three);
margin-top: 1rem;
}
.package-list {
margin-top: 1rem;
display: flex;
flex-direction: column;
white-space: normal;
word-break: break-all;
}
.package {
padding: 0.6rem;
border-radius: 8px;
cursor: pointer;
display: flex;
align-items: center;
gap: 0.6rem;
width: 100%;
user-select: none;
transition: all 0.4s var(--bezier-one);
}
.package::before {
content: '';
height: 5px;
inline-size: 4px;
border-radius: 200px;
background-color: var(--accent-color);
transition: all 0.2s var(--bezier-one);
opacity: 0;
}
.selected::before{
height: 20px;
transition: all 0.3s var(--bezier-one);
opacity: 1;
}
.package > h3 {
color: var(--grey-five);
transition: all 0.3s var(--bezier-one);
}
.selected > h3 {
color: var(--accent-color);
transition: all 0.3s var(--bezier-one);
}
.package:hover, .selected {
background-color: var(--grey-six);
}
.package:not(.selected):hover > h3 {
color: var(--white);
}
.loading {
height: 50px;
background: linear-gradient(90deg, var(--grey-six) 33%, var(--grey-one) 50%, var(--grey-six) 66%) var(--grey-six);
background-size: 300% 100%;
animation: pulse 2s infinite;
margin-bottom: 0.5rem;
} */
</style>

View File

@ -1,24 +0,0 @@
import type { Patch } from '$lib/types';
export type Output = { patches: Patch[], packages: string[] };
export async function load({
fetch
}): Output {
const response = await fetch('https://releases.rvcd.win/patches');
const json = await response.json();
let pkg_list = [];
// yes
for (let i = 0; i < json.length; i++) {
json[i].compatiblePackages.forEach(pkg => {
let index = pkg_list.findIndex(x => x == pkg.name);
if (index === -1) {
pkg_list.push(pkg.name);
};
});
};
return { patches: json, packages: pkg_list };
}