From 34700361740ed78262fa114276ba76b46cfcff94 Mon Sep 17 00:00:00 2001 From: Matiboux Date: Sat, 7 Jun 2025 04:53:04 +0200 Subject: [PATCH 1/4] Add CountryFlag component --- app/app/src/components/CountryFlag.astro | 40 +++++++++++++++++++++ app/app/src/components/StreamersTable.astro | 19 ++-------- 2 files changed, 42 insertions(+), 17 deletions(-) create mode 100644 app/app/src/components/CountryFlag.astro diff --git a/app/app/src/components/CountryFlag.astro b/app/app/src/components/CountryFlag.astro new file mode 100644 index 0000000..c0bc7bc --- /dev/null +++ b/app/app/src/components/CountryFlag.astro @@ -0,0 +1,40 @@ +--- +type CountryCode = + | 'AUS' // Australia + | 'BEL' // Belgium + | 'CAN' // Canada + | 'CHE' // Switzerland + | 'ESP' // Spain + | 'FRA' // France + | 'GBR' // United Kingdom + | 'IDN' // Indonesia + | 'ITA' // Italy + | 'USA' // United States + +const countryCode: CountryCode = Astro.props.country +--- + +{ +countryCode === 'AUS' + ? +: countryCode === 'BEL' + ? +: countryCode === 'CAN' + ? +: countryCode === 'CHE' + ? +: countryCode === 'ESP' + ? +: countryCode === 'FRA' + ? +: countryCode === 'GBR' + ? +: countryCode === 'IDN' + ? +: countryCode === 'ITA' + ? +: countryCode === 'USA' + ? +: + {countryCode} +} diff --git a/app/app/src/components/StreamersTable.astro b/app/app/src/components/StreamersTable.astro index 02d83d1..7a84083 100644 --- a/app/app/src/components/StreamersTable.astro +++ b/app/app/src/components/StreamersTable.astro @@ -1,6 +1,7 @@ --- import YAML from 'yaml' +import CountryFlag from '~/components/CountryFlag.astro' import streamersSocialsYml from '~/data/streamers/socials.yml?raw' interface StreamerSocials { @@ -20,19 +21,6 @@ const streamers: Array = streamersList.map( (name) => streamersSocials[name] || { name, country: '?', socials: [] } ) -const countryFlag: Record = { - 'AUS': 'australia', - 'BEL': 'belgium', - 'CAN': 'canada', - 'CHE': 'switzerland', - 'ESP': 'spain', - 'FRA': 'france', - 'GBR': 'united-kingdom', - 'IDN': 'indonesia', - 'ITA': 'italy', - 'USA': 'united-states', -} - const socialIcons: Record = { 'twitch': 'mdi--twitch', 'twitter': 'mdi--twitter', @@ -56,10 +44,7 @@ const socialIcons: Record = { {streamers.map((streamer) => ( - {countryFlag[streamer.country] !== undefined - ? - : {streamer.country} - } + {streamer.name} From 61ad6cb661db8eb6dd8ac4ead26a05b22e846610 Mon Sep 17 00:00:00 2001 From: Matiboux Date: Sat, 7 Jun 2025 04:58:16 +0200 Subject: [PATCH 2/4] Update CountryFlag component --- app/app/src/components/CountryFlag.astro | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/app/app/src/components/CountryFlag.astro b/app/app/src/components/CountryFlag.astro index c0bc7bc..214931d 100644 --- a/app/app/src/components/CountryFlag.astro +++ b/app/app/src/components/CountryFlag.astro @@ -11,7 +11,12 @@ type CountryCode = | 'ITA' // Italy | 'USA' // United States -const countryCode: CountryCode = Astro.props.country +function parseCountryCode(code: any): string | undefined +{ + return typeof code === 'string' ? code.toUpperCase() : code +} + +const countryCode: CountryCode | undefined = parseCountryCode(Astro.props.country) as any --- { From 2e63ba8a7a052098a7b6d531ed822c20978ecdc7 Mon Sep 17 00:00:00 2001 From: Matiboux Date: Sat, 7 Jun 2025 05:02:35 +0200 Subject: [PATCH 3/4] Add SocialPlatformIcon component --- .../src/components/SocialPlatformIcon.astro | 30 +++++++++++++++++++ app/app/src/components/StreamersTable.astro | 5 ++-- 2 files changed, 32 insertions(+), 3 deletions(-) create mode 100644 app/app/src/components/SocialPlatformIcon.astro diff --git a/app/app/src/components/SocialPlatformIcon.astro b/app/app/src/components/SocialPlatformIcon.astro new file mode 100644 index 0000000..a45b461 --- /dev/null +++ b/app/app/src/components/SocialPlatformIcon.astro @@ -0,0 +1,30 @@ +--- +type SocialPlatform = + | 'twitch' // Twitch + | 'twitter' // Twitter + | 'youtube' // YouTube + | 'tiktok' // TikTok + | 'instagram' // Instagram + +function parseSocialPlatform(code: any): string | undefined +{ + return typeof code === 'string' ? code.toLowerCase() : code +} + +const socialPlatform: SocialPlatform | undefined = parseSocialPlatform(Astro.props.platform) as any +--- + +{ +socialPlatform === 'twitch' + ? +: socialPlatform === 'twitter' + ? +: socialPlatform === 'youtube' + ? +: socialPlatform === 'tiktok' + ? +: socialPlatform === 'instagram' + ? +: + {socialPlatform} +} diff --git a/app/app/src/components/StreamersTable.astro b/app/app/src/components/StreamersTable.astro index 7a84083..abb6e71 100644 --- a/app/app/src/components/StreamersTable.astro +++ b/app/app/src/components/StreamersTable.astro @@ -2,6 +2,7 @@ import YAML from 'yaml' import CountryFlag from '~/components/CountryFlag.astro' +import SocialPlatformIcon from '~/components/SocialPlatformIcon.astro' import streamersSocialsYml from '~/data/streamers/socials.yml?raw' interface StreamerSocials { @@ -51,9 +52,7 @@ const socialIcons: Record = { {streamer.socials?.map((social, index) => ( <> { - socialIcons[social.platform.toLowerCase()] !== undefined - ? - : {social.platform} + }{ }{index < streamer.socials.length - 1 && ', '} ))} From 3639adf4cadca0319b745022d5438bf5cc43a48d Mon Sep 17 00:00:00 2001 From: Matiboux Date: Sat, 7 Jun 2025 05:05:25 +0200 Subject: [PATCH 4/4] Remove unused variable --- app/app/src/components/StreamersTable.astro | 8 -------- 1 file changed, 8 deletions(-) diff --git a/app/app/src/components/StreamersTable.astro b/app/app/src/components/StreamersTable.astro index abb6e71..9b4015c 100644 --- a/app/app/src/components/StreamersTable.astro +++ b/app/app/src/components/StreamersTable.astro @@ -21,14 +21,6 @@ const streamersSocials = YAML.parse(streamersSocialsYml) as Record = streamersList.map( (name) => streamersSocials[name] || { name, country: '?', socials: [] } ) - -const socialIcons: Record = { - 'twitch': 'mdi--twitch', - 'twitter': 'mdi--twitter', - 'youtube': 'mdi--youtube', - 'tiktok': 'ic--baseline-tiktok', - 'instagram': 'mdi--instagram', -} ---