2024-01-20 16:16:14 +00:00
|
|
|
import Skeleton, { SkeletonTheme } from 'react-loading-skeleton';
|
|
|
|
import 'react-loading-skeleton/dist/skeleton.css';
|
|
|
|
import { getPatrons } from '../lib/patreon';
|
|
|
|
import Link from 'next/link'
|
|
|
|
|
|
|
|
interface PatronsListProps {
|
|
|
|
displayStyle: string;
|
|
|
|
}
|
|
|
|
|
|
|
|
export default async function PatronsList({ displayStyle }: PatronsListProps) {
|
|
|
|
const patrons = await getPatrons()
|
|
|
|
|
2024-07-04 21:20:29 +00:00
|
|
|
|
2024-08-13 21:18:01 +00:00
|
|
|
if (!patrons || patrons.length === 0) return (
|
2024-01-20 16:16:14 +00:00
|
|
|
<SkeletonTheme baseColor="#000" highlightColor="#000">
|
2024-08-13 21:18:01 +00:00
|
|
|
<Skeleton count={1} enableAnimation={false} width={'25em'} />
|
2024-01-20 16:16:14 +00:00
|
|
|
</SkeletonTheme>
|
|
|
|
);
|
2024-07-04 21:20:29 +00:00
|
|
|
|
2024-01-20 16:16:14 +00:00
|
|
|
if (displayStyle === 'box') {
|
|
|
|
return (
|
|
|
|
<div className="columns is-multiline">
|
|
|
|
{patrons.map((patron) => (
|
|
|
|
<div key={patron.username} className="column is-full-mobile is-half-tablet is-one-third-desktop">
|
|
|
|
<div className="box">
|
|
|
|
<article className="media">
|
|
|
|
<div className="media-content">
|
|
|
|
<div className="content">
|
|
|
|
{patron.username && (
|
|
|
|
<span>
|
|
|
|
<b>{patron.username}</b>
|
|
|
|
</span>
|
|
|
|
)}
|
|
|
|
{patron.vanityLink && (
|
|
|
|
<Link target="_blank" href={patron.vanityLink}>
|
|
|
|
<span>{patron.vanityLink}</span>
|
|
|
|
<span className="icon">
|
|
|
|
<i className="fas fa-external-link-alt"></i>
|
|
|
|
</span>
|
|
|
|
</Link>
|
|
|
|
)}
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</article>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
))}
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
} else if (displayStyle === 'list') {
|
|
|
|
const patronNames = patrons.map((patron) => patron.username.trim()).join(', ');
|
|
|
|
return <span>{patronNames}</span>;
|
|
|
|
} else {
|
|
|
|
return <span></span>; // Handle unsupported display styles or provide a default display style
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|