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

@ -37,13 +37,14 @@ body {
:root {
--white: #fff;
--accent-color: #8bc3f4;
--accent-color-two: hsl(207, 65%, 90%);
--bg-color: #1a1c1e;
--grey-one: #252b31;
--grey-two: #28313b;
--grey-three: #3c4759c3;
--grey-three: #373E4D;
--grey-four: #1b1e29;
--grey-five: hsl(208, 30%, 75%);
--grey-six: #23282da7;
--grey-six: hsla(223, 17%, 16%, 0.655);
--grey-seven: #535563;
--bezier-one: cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

View File

@ -0,0 +1,14 @@
import { readable } from 'svelte/store';
import type { Repository } from '$lib/types';
export type ContribData = { repositories: Repository[] };
const fetchContributors = async (): Promise<ContribData> => {
const response = await fetch('https://releases.rvcd.win/contributors');
const data = await response.json();
return data;
};
export const ContributorsStore = readable(fetchContributors());

23
src/data/PatchesStore.ts Normal file
View File

@ -0,0 +1,23 @@
import { readable } from 'svelte/store';
import type { Patch } from '$lib/types';
export type PatchesData = { patches: Patch[]; packages: string[] };
const fetchPatches = async (): Promise<PatchesData> => {
const response = await fetch('https://releases.rvcd.win/patches');
const patches = await response.json();
let packages: string[] = [];
// gets packages
for (let i = 0; i < patches.length; i++) {
patches[i].compatiblePackages.forEach((pkg: Patch) => {
let index = packages.findIndex((x) => x == pkg.name);
if (index === -1) {
packages.push(pkg.name);
}
});
}
return { patches, packages };
};
export const PatchesStore = readable(fetchPatches());

View File

@ -5,7 +5,7 @@
let alt = `${name}'s profile picture`;
</script>
<a href={url} target="_blank">
<a href={url} rel="noreferrer" target="_blank">
<button tabindex="-1">
<img src={pfp} {alt} />
</button>

View File

@ -41,7 +41,7 @@
}
li.selected {
background-color: var(--grey-three);
background-color: var(--grey-two);
color: var(--accent-color);
}
</style>

View File

@ -1,79 +0,0 @@
<script lang="ts">
import { onMount } from 'svelte';
import { fly } from 'svelte/transition';
import { quintOut } from 'svelte/easing';
export let name: string;
export let desc: string;
export let ver: string;
// export let pkgName: string;
export let hasPatchOptions: boolean;
function handleClick() {
const el = document.getElementById('arrow');
if (!el) return;
el!.style.transform = 'rotate(180deg)';
}
</script>
<div
class="patch-container {hasPatchOptions ? 'expanded' : ''}"
on:click={hasPatchOptions ? handleClick : null}
>
<div class="things">
<div class="title">
<h1>{name}</h1>
<h3>{ver}</h3>
</div>
{#if hasPatchOptions}
<img id="arrow" src="/icons/arrow.svg" alt="dropdown" />
{/if}
</div>
<!-- <h3>{pkgName}</h3> -->
<h4>{desc}</h4>
</div>
<style>
h1 {
font-weight: 600;
margin-bottom: 0.5rem;
margin-right: 0.5rem;
font-size: 1.25rem;
}
h3 {
color: var(--grey-five);
font-size: 0.8rem;
margin-bottom: 0.1rem;
}
h4 {
color: var(--grey-five);
font-size: 0.8rem;
font-weight: 400;
}
.patch-container {
background-color: var(--grey-six);
padding: 1.5rem;
border-radius: 8px;
}
.title {
display: flex;
align-items: center;
}
.things {
display: flex;
justify-content: space-between;
}
img {
height: 1.5rem;
}
.expanded {
}
</style>

View File

@ -0,0 +1,165 @@
<script lang="ts">
import { slide, fade } from 'svelte/transition';
import { quintOut } from 'svelte/easing';
import type { CompatiblePackage, PatchOption } from '$lib/types';
export let name: string;
export let description: string;
export let version: string;
export let options: PatchOption[];
export let compatiblePackages: CompatiblePackage[];
export let hasPatchOptions: boolean;
export let current: boolean;
let expanded: boolean = false;
</script>
<!-- svelte-ignore a11y-click-events-have-key-events -->
<div
class="patch-container {hasPatchOptions ? 'expanded' : ''}"
class:rotate={expanded === true}
on:click={() => (expanded = !expanded)}
>
<div class="things">
<div class="title">
<h1>
{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')}
</h1>
</div>
{#if hasPatchOptions}
<img id="arrow" src="/icons/arrow.svg" alt="dropdown" />
{/if}
</div>
<div class="info-container">
{#each compatiblePackages as pkg, i}
{#if current === false}
<h2>{pkg.name}</h2>
{/if}
<!-- gets only the last supported version (cant get 'any' to work without duplicates help) -->
{#if i < pkg.versions.length - 1}
<h2>
Target Package Version: {pkg.versions.slice(-1)[0] || 'Any'}
</h2>
{/if}
{/each}
<h2>Patch Version: {version}</h2>
</div>
<h4>{description}</h4>
{#if expanded && hasPatchOptions}
<span transition:fade|local={{ easing: quintOut, duration: 1000 }}>
<div class="options" transition:slide|local={{ easing: quintOut, duration: 500 }}>
{#each options as option}
<div class="option">
<h3>{option.title}</h3>
<h4>{option.description}</h4>
</div>
{/each}
</div>
</span>
{/if}
</div>
<style>
h1 {
font-weight: 600;
margin-right: 0.5rem;
font-size: 1.25rem;
color: var(--accent-color-two);
}
h2 {
color: var(--accent-color);
font-size: 0.75rem;
font-weight: 500;
border-radius: 8px;
background-color: var(--grey-two);
padding: 0.2rem 0.4rem;
display: flex;
}
.info-container {
display: flex;
flex-wrap: wrap;
gap: 0.25rem;
margin-bottom: 0.5rem;
margin-left: -0.2rem;
margin-top: 0.5rem;
width: 100%;
}
h3 {
color: var(--accent-color);
font-size: 0.85rem;
margin-bottom: 0.1rem;
font-weight: 500;
}
h4 {
color: var(--grey-five);
font-size: 0.8rem;
font-weight: 400;
}
.patch-container {
transition: all 2s var(--bezier-one);
background-color: var(--grey-six);
padding: 1.5rem;
border-radius: 12px;
}
.patch-container:active {
background-color: var(--grey-three);
}
.title {
display: flex;
align-items: center;
}
.things {
display: flex;
justify-content: space-between;
}
#arrow {
height: 1.5rem;
transition: all 0.2s var(--bezier-one);
user-select: none;
}
.rotate #arrow {
transform: rotate(180deg);
}
.expanded {
cursor: pointer;
}
.option {
padding: 1rem;
}
.option + .option {
border-top: 1px solid var(--grey-three);
}
.options {
border: 1px solid var(--grey-three);
overflow: hidden;
border-radius: 8px;
margin-top: 1rem;
display: flex;
flex-direction: column;
}
</style>

View File

@ -3,7 +3,7 @@
export let href = '#';
</script>
<a {href} target="_blank">
<a {href} rel="noreferrer" target="_blank">
<div>
<img src="socials/{src}.svg" alt={src} />
</div>

View File

@ -0,0 +1,67 @@
<script lang="ts">
export let current: string | boolean;
export let name: string;
</script>
<!-- svelte-ignore a11y-click-events-have-key-events -->
<div
class="package"
class:selected = {current === name}
on:click={() => (current = (current === name) ? false : name) && window.scrollTo({ top: 0, behavior: 'smooth' })}
>
<h3>{name}</h3>
</div>
<style>
.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;
}
h3 {
font-size: 0.9rem;
}
.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);
}
</style>

View File

@ -1,5 +1,5 @@
<script lang="ts">
import type { Contributor } from '$lib/types';
import type { Contributor } from '$lib/types';
import ContributorButton from '../atoms/ContributorPerson.svelte';
export let contribs: Contributor[];
@ -17,18 +17,14 @@
{#if contribs}
<div class="container">
<a href="https://github.com/{repo}" target="_blank">
<a href="https://github.com/{repo}" rel="noreferrer" target="_blank">
<h2>{repo_name}</h2>
</a>
<div class="contrib-host">
{#each contribs as contrib}
{#if !usersIwantToExplodeSoBadly.includes(contrib.login)}
<ContributorButton
name={contrib.login}
pfp={contrib.avatar_url}
url={contrib.html_url}
/>
<ContributorButton name={contrib.login} pfp={contrib.avatar_url} url={contrib.html_url} />
{/if}
{/each}
</div>

View File

@ -1,4 +1,16 @@
<script>
<script lang="ts">
import { onMount } from 'svelte';
import type { ContribData } from '../../../data/ContributorsStore';
import { ContributorsStore } from '../../../data/ContributorsStore';
let data: ContribData;
onMount(() => {
ContributorsStore.subscribe(async (e: Promise<ContribData>) => {
data = await e;
});
});
</script>
<hr />
@ -17,31 +29,39 @@
<section class="links-container">
<div class="link-column">
<h5>Pages</h5>
<h6>Home</h6>
<h6>Download</h6>
<h6>Docs</h6>
<h6>Patches</h6>
<h6>Credits</h6>
<a href="/"><h6>Home</h6></a>
<a href="/download"><h6>Download</h6></a>
<a href="/docs"><h6>Docs</h6></a>
<a href="/patches"><h6>Patches</h6></a>
<a href="/credits"><h6>Credits</h6></a>
</div>
<div class="link-column">
<h5>Repos</h5>
<h6>CLI</h6>
<h6>Patcher</h6>
<h6>Patches</h6>
<h6>Integrations</h6>
<h6>Manager</h6>
<h6>Website</h6>
<h6>API</h6>
{#if data}
{#each data.repositories as { name }}
<a href="https://github.com/{name}" target="_blank" rel="noreferrer">
<div>
<h6>{name
.replace(/-/g, ' ')
.replace(/revanced\/revanced/g, '')
.replace(/cli/g, 'CLI')
.replace(/api/g, 'API')
.replace(/(?:^|\s)\S/g, (x) => x.toUpperCase())}
</h6>
</div>
</a>
{/each}
{/if}
</div>
<div class="link-column">
<h5>Repos</h5>
<h6>CLI</h6>
<h6>Patcher</h6>
<h6>Patches</h6>
<h6>Integrations</h6>
<h6>Manager</h6>
<h6>Website</h6>
<h6>API</h6>
<!-- to replace -->
<h5>Socials</h5>
<a href="/"><h6>Github</h6></a>
<a href="/"><h6>Discord</h6></a>
<a href="/"><h6>Reddit</h6></a>
<a href="/"><h6>Twitter</h6></a>
<a href="/"><h6>Telegram</h6></a>
<a href="/"><h6>Video Site</h6></a>
</div>
</section>
</footer>
@ -74,6 +94,10 @@
height: 3rem;
}
a {
text-decoration: none;
}
.links-container {
display: flex;
gap: 5rem;

View File

@ -0,0 +1,48 @@
<script lang="ts">
export let title: string;
</script>
<div class="menu">
<h5>{title.toUpperCase()}</h5>
<hr />
<div class="package-list">
<slot />
</div>
</div>
<style>
.menu {
height: calc(100vh - 7.5rem);
width: 100%;
padding: 0px 10px 30px 10px;
display: flex;
flex-direction: column;
position: sticky;
top: 7.5rem;
overflow-y: scroll;
}
h5 {
font-weight: 500;
}
hr {
margin-top: 0.75rem;
display: block;
height: 1px;
border: 0;
border-top: 1px solid var(--grey-three);
}
.package-list {
margin-top: 0.75rem;
display: flex;
flex-direction: column;
white-space: normal;
word-break: break-all;
}
/* .package-list:has(.loading) {
padding-top: 7.5rem;
} */
</style>

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 };
}