From 2cbb64e930ca0d44aa6fe49c40c15cc6e454c714 Mon Sep 17 00:00:00 2001 From: liyunze <50455574+liyunze-coding@users.noreply.github.com> Date: Fri, 6 Nov 2026 15:09:11 +0800 Subject: [PATCH] separate components --- .../src/components/media-kit/About.svelte | 10 + .../src/components/media-kit/Intro.svelte | 23 +++ .../components/media-kit/PlatformCard.svelte | 46 +++++ .../src/components/media-kit/Platforms.svelte | 29 +++ .../components/media-kit/ProfileImage.svelte | 18 ++ .../src/components/media-kit/Services.svelte | 29 +++ frontend/src/lib/format.ts | 12 ++ frontend/src/lib/platforms.ts | 27 +++ frontend/src/routes/MediaKit.svelte | 193 +----------------- 9 files changed, 205 insertions(+), 182 deletions(-) create mode 100644 frontend/src/components/media-kit/About.svelte create mode 100644 frontend/src/components/media-kit/Intro.svelte create mode 100644 frontend/src/components/media-kit/PlatformCard.svelte create mode 100644 frontend/src/components/media-kit/Platforms.svelte create mode 100644 frontend/src/components/media-kit/ProfileImage.svelte create mode 100644 frontend/src/components/media-kit/Services.svelte create mode 100644 frontend/src/lib/format.ts create mode 100644 frontend/src/lib/platforms.ts diff --git a/frontend/src/components/media-kit/About.svelte b/frontend/src/components/media-kit/About.svelte new file mode 100644 index 0000000..79be2b1 --- /dev/null +++ b/frontend/src/components/media-kit/About.svelte @@ -0,0 +1,10 @@ + + +
+
About Me
+

+ {about} +

+
diff --git a/frontend/src/components/media-kit/Intro.svelte b/frontend/src/components/media-kit/Intro.svelte new file mode 100644 index 0000000..3a8c7ae --- /dev/null +++ b/frontend/src/components/media-kit/Intro.svelte @@ -0,0 +1,23 @@ + + +
+
+ Hi there, I'm
+ {name} +
+ {#if tagline} +

+ {tagline} +

+ {/if} +
diff --git a/frontend/src/components/media-kit/PlatformCard.svelte b/frontend/src/components/media-kit/PlatformCard.svelte new file mode 100644 index 0000000..1529ad1 --- /dev/null +++ b/frontend/src/components/media-kit/PlatformCard.svelte @@ -0,0 +1,46 @@ + + +{#if deco} + +
+ {name} +
+ + {name} + +
+ {handle} +
+ {formatCount(followers)} + {metricLabel(name)} +
+
+
+
+{/if} diff --git a/frontend/src/components/media-kit/Platforms.svelte b/frontend/src/components/media-kit/Platforms.svelte new file mode 100644 index 0000000..5a58c6c --- /dev/null +++ b/frontend/src/components/media-kit/Platforms.svelte @@ -0,0 +1,29 @@ + + +
+ + {#each platforms as platform (platform.name)} + + {/each} +
diff --git a/frontend/src/components/media-kit/ProfileImage.svelte b/frontend/src/components/media-kit/ProfileImage.svelte new file mode 100644 index 0000000..4c37344 --- /dev/null +++ b/frontend/src/components/media-kit/ProfileImage.svelte @@ -0,0 +1,18 @@ + + + diff --git a/frontend/src/components/media-kit/Services.svelte b/frontend/src/components/media-kit/Services.svelte new file mode 100644 index 0000000..ca27a82 --- /dev/null +++ b/frontend/src/components/media-kit/Services.svelte @@ -0,0 +1,29 @@ + + +{#if items.length} +
+
Services
+
+ + +
+
+{/if} diff --git a/frontend/src/lib/format.ts b/frontend/src/lib/format.ts new file mode 100644 index 0000000..567d876 --- /dev/null +++ b/frontend/src/lib/format.ts @@ -0,0 +1,12 @@ +export function formatCount(value: number | undefined | null): string { + if (value == null) return "—"; + if (value >= 1_000_000) { + const millions = value / 1_000_000; + return `${millions >= 100 ? Math.round(millions) : millions.toFixed(1).replace(/\.0$/, "")}M`; + } + if (value >= 1_000) { + const thousands = value / 1_000; + return `${thousands >= 100 ? Math.round(thousands) : thousands.toFixed(1).replace(/\.0$/, "")}K`; + } + return value.toLocaleString(); +} diff --git a/frontend/src/lib/platforms.ts b/frontend/src/lib/platforms.ts new file mode 100644 index 0000000..05bad14 --- /dev/null +++ b/frontend/src/lib/platforms.ts @@ -0,0 +1,27 @@ +export type PlatformDeco = { + image: string; + color?: string | null; +}; + +export const platformImageMap: Record = { + twitch: { + image: "/images/logos/twitch.svg", + color: "#8E60F5", + }, + youtube: { + image: "/images/logos/youtube.svg", + color: "#FF0000", + }, + instagram: { + image: "/images/logos/instagram.svg", + color: "#E1306C", + }, + tiktok: { + image: "/images/logos/tiktok.svg", + color: "#FFFFFF", + }, +}; + +export function metricLabel(name: string): string { + return name.toLowerCase() === "youtube" ? "subscribers" : "followers"; +} diff --git a/frontend/src/routes/MediaKit.svelte b/frontend/src/routes/MediaKit.svelte index 02aefba..abc0893 100644 --- a/frontend/src/routes/MediaKit.svelte +++ b/frontend/src/routes/MediaKit.svelte @@ -2,8 +2,12 @@ import { onMount } from "svelte"; import { fetchMediaKit } from "../lib/api"; import type { MediaKit } from "../lib/types"; - import Card from "../components/Card.svelte"; import Collabs from "../components/Collabs.svelte"; + import About from "../components/media-kit/About.svelte"; + import Intro from "../components/media-kit/Intro.svelte"; + import Platforms from "../components/media-kit/Platforms.svelte"; + import ProfileImage from "../components/media-kit/ProfileImage.svelte"; + import Services from "../components/media-kit/Services.svelte"; let data = $state(null); let error = $state(""); @@ -19,51 +23,7 @@ let content = $derived(data?.content ?? {}); let platforms = $derived(data?.platforms ?? []); let collabs = $derived(data?.collabs ?? []); - let services = $derived( - (content.services ?? "") - .split("\n") - .map((service) => service.trim()) - .filter(Boolean) - .slice(0, 6), - ); let twitch = $derived(data?.twitch); - // let twitchLogin = $derived(twitch?.login ?? ""); - - type platformDecoType = { - image: string; - color?: string | null; - }; - - let platformImageMap: Record = { - twitch: { - image: "/images/logos/twitch.svg", - color: "#8E60F5", - }, - youtube: { - image: "/images/logos/youtube.svg", - color: "#FF0000", - }, - instagram: { - image: "/images/logos/instagram.svg", - color: "#E1306C", - }, - tiktok: { - image: "/images/logos/tiktok.svg", - color: "#FFFFFF", - }, - }; - function formatCount(value: number | undefined | null): string { - if (value == null) return "—"; - if (value >= 1_000_000) { - const millions = value / 1_000_000; - return `${millions >= 100 ? Math.round(millions) : millions.toFixed(1).replace(/\.0$/, "")}M`; - } - if (value >= 1_000) { - const thousands = value / 1_000; - return `${thousands >= 100 ? Math.round(thousands) : thousands.toFixed(1).replace(/\.0$/, "")}K`; - } - return value.toLocaleString(); - } {#if error} @@ -84,11 +44,9 @@ > {#if content.profile_image_url}
- {content.brand_name
{/if} @@ -96,122 +54,20 @@
-
- - -
- Twitch -
- - Twitch - -
- {twitch?.display_name} -
- {formatCount(twitch?.followers)} - followers -
-
-
-
- {#each platforms as platform (platform.name)} - -
- Twitch -
- - {platform.name} - -
- {platform.handle} -
- {formatCount(platform.followers)} - - {#if platform.name != "youtube"} - followers - {:else} - subscribers - {/if} - -
-
-
-
- {/each} -
+
-
-
-
- Hi there, I'm
- RythonDev -
- {#if content.tagline} -

- {content.tagline} -

- {/if} -
-
-
- About Me -
-

- {content.about ?? ""} -

-
+ + {#if collabs.length}
@@ -220,34 +76,7 @@
{/if} - {#if services.length} -
-
- Services -
-
-
    - {#each services.slice(0, 3) as service} -
  • {service}
  • - {/each} -
-
    - {#each services.slice(3, 6) as service} -
  • {service}
  • - {/each} -
-
-
- {/if} +
{/if} - -