sendou.ink/app/features/tournament-organization/components/SocialLinksList.tsx
Kalle 9312fad90f
Tournament organization page (#1811)
* Initial

* Calendar initial

* Extract EventCalendar

* Events list initial

* Winners

* SQL fixes

* List events by series

* Leaderboards

* Series leaderboard

* Own entry peek

* Edit page skeleton

* RHF initial test

* RHF stuff

* Form etc. progress

* Fix tournament series description

* Fix tabs layout

* Fix socials insert

* Check for not removing admin

* Adding series

* TODOs

* Allow updating org with no series

* FormFieldset

* Allow series without events

* TextAreaFormfield accepting array syntax

* Input form array field

* ToggleFormField

* SelectFormField

* UserSearchFormField

* Fetch badgeOptions

* Badge editing

* Progress

* Use native preventScrollReset

* Rename func

* Fix sticky scroll

* Fix translation

* i18n errors

* handle,meta in edit

* Add ref to user search

* TODOs

* Done
2024-07-25 23:06:29 +03:00

69 lines
1.4 KiB
TypeScript

import clsx from "clsx";
import { LinkIcon } from "~/components/icons/Link";
import { TwitchIcon } from "~/components/icons/Twitch";
import { TwitterIcon } from "~/components/icons/Twitter";
import { YouTubeIcon } from "~/components/icons/YouTube";
export function SocialLinksList({ links }: { links: string[] }) {
return (
<div className="stack sm text-sm">
{links.map((url, i) => {
return <SocialLink key={i} url={url} />;
})}
</div>
);
}
function SocialLink({ url }: { url: string }) {
const type = urlToLinkType(url);
return (
<a href={url} target="_blank" rel="noreferrer" className="org__social-link">
<div
className={clsx("org__social-link__icon-container", {
youtube: type === "youtube",
twitter: type === "twitter",
twitch: type === "twitch",
})}
>
<SocialLinkIcon url={url} />
</div>
{url}
</a>
);
}
function SocialLinkIcon({ url }: { url: string }) {
const type = urlToLinkType(url);
if (type === "twitter") {
return <TwitterIcon />;
}
if (type === "twitch") {
return <TwitchIcon />;
}
if (type === "youtube") {
return <YouTubeIcon />;
}
return <LinkIcon />;
}
const urlToLinkType = (url: string) => {
if (url.includes("twitter.com") || url.includes("x.com")) {
return "twitter";
}
if (url.includes("twitch.tv")) {
return "twitch";
}
if (url.includes("youtube.com")) {
return "youtube";
}
return null;
};