refactor: dynamically create credit repos

This commit is contained in:
afn
2022-10-20 00:29:16 -04:00
parent 6f6081eb1b
commit 9010842f73
4 changed files with 35 additions and 26 deletions

View File

@ -6,8 +6,8 @@
</script> </script>
<a href={url} target="_blank"> <a href={url} target="_blank">
<button> <button tabindex="-1">
<img src={pfp} alt={alt}><slot/> <img src={pfp} {alt}>
</button> </button>
<h2>{name}</h2> <h2>{name}</h2>
</a> </a>

View File

@ -1,21 +1,16 @@
<script lang="ts"> <script lang="ts">
import ContributorsStore from "../../stores/ContributorsStore.js"; import ContributorButton from "../atoms/ContributorPerson.svelte";
import ContributorButton from "../atoms/ContributorButton.svelte";
import { onMount } from "svelte";
import { fly } from 'svelte/transition'; import { fly } from 'svelte/transition';
import { quintOut } from 'svelte/easing'; import { quintOut } from 'svelte/easing';
let contribs: Object; export let contribs;
let repo_link: string;
export let repo: string; export let repo: string;
onMount (() => { let repo_name = repo.replace(/-/g, ' ')
ContributorsStore.subscribe(async (e) => { .replace(/revanced\/revanced/g, 'ReVanced')
let data = await e; .replace(/cli/g, 'CLI')
repo_link = 'https://github.com/' + data[repo].name; .replace(/api/g, 'API')
contribs = data[repo].contributors .replace(/(?:^|\s)\S/g, x => x.toUpperCase())
});
});
let usersIwantToExplodeSoBadly = [ let usersIwantToExplodeSoBadly = [
'semantic-release-bot', 'semantic-release-bot',
@ -24,10 +19,14 @@
</script> </script>
{#if contribs} {#if contribs}
<div class="container" in:fly="{{ y: 10, easing: quintOut, duration: 700 }}"> <div
<a href={repo_link} target="_blank"> class="container"
<h2>ReVanced {repo === 'cli' ? 'CLI' : repo.charAt(0).toUpperCase() + repo.slice(1)}</h2> in:fly="{{ y: 10, easing: quintOut, duration: 700 }}"
>
<a href='https://github.com/{repo}' target="_blank">
<h2>{repo_name}</h2>
</a> </a>
<div class="contrib-host"> <div class="contrib-host">
{#each contribs as contrib} {#each contribs as contrib}
{#if !usersIwantToExplodeSoBadly.includes(contrib.login)} {#if !usersIwantToExplodeSoBadly.includes(contrib.login)}
@ -39,6 +38,7 @@
{/if} {/if}
{/each} {/each}
</div> </div>
</div> </div>
{/if} {/if}

View File

@ -3,9 +3,7 @@ import { readable } from "svelte/store";
const fetchContributors = async () => { const fetchContributors = async () => {
const response = await fetch('https://releases.rvcd.win/contributors'); const response = await fetch('https://releases.rvcd.win/contributors');
const json = await response.json(); const json = await response.json();
return json;
let { 0: cli, 1: patcher, 2: patches, 3: integrations, 4: manager } = json.repositories;
return {cli, patcher, patches, integrations, manager};
}; };
const ContributorsStore = readable(fetchContributors()); const ContributorsStore = readable(fetchContributors());

View File

@ -1,13 +1,24 @@
<script lang="ts"> <script lang="ts">
import ContributorHost from '$lib/components/molecules/ContributorHost.svelte'; import ContributorHost from '$lib/components/molecules/ContributorHost.svelte';
import ContributorsStore from '../../lib/stores/ContributorsStore.js';
import { onMount } from "svelte";
let data;
onMount (() => {
ContributorsStore.subscribe(async (e) => {
data = await e;
console.log(data);
});
});
</script> </script>
<div class="wrapper contrib-grid"> <div class="wrapper contrib-grid">
<ContributorHost repo="cli"/> {#if data}
<ContributorHost repo="patcher"/> {#each data.repositories as { contributors, name }}
<ContributorHost repo="patches"/> <ContributorHost contribs={contributors} repo={name}/>
<ContributorHost repo="integrations"/> {/each}
<ContributorHost repo="manager"/> {/if}
</div> </div>
<style> <style>