mirror of
https://github.com/roleypoly/roleypoly.git
synced 2025-04-24 19:39:11 +00:00
* feat(web): add server-setup page for when bot isn't in the server picked * chore: move contexts into their own folder * feat(web): add recent guilds context, and app shell helper context * feat(web): show recent guilds in masthead * feat(web): functionally add recents to servers list * fix(web): correct styling for servers listing recents/all headers * fix(web): correct some type issues with appShellProps * fix(web): don't show ServerListing recents when recents is empty
45 lines
1.5 KiB
TypeScript
45 lines
1.5 KiB
TypeScript
import { CompletelyStylelessLink } from '@roleypoly/design-system/atoms/typography';
|
|
import { ServerListingCard } from '@roleypoly/design-system/molecules/server-listing-card';
|
|
import { getRecentAndSortedGuilds } from '@roleypoly/misc-utils/guildListing';
|
|
import { GuildSlug } from '@roleypoly/types';
|
|
import * as React from 'react';
|
|
import { CardContainer, ContentContainer, SectionHead } from './ServersListing.styled';
|
|
|
|
type ServersListingProps = {
|
|
guilds: GuildSlug[];
|
|
recentGuilds: string[];
|
|
};
|
|
|
|
const CardList = (props: { guilds: GuildSlug[] }) => (
|
|
<>
|
|
{props.guilds.map((guild, idx) => (
|
|
<CardContainer key={idx}>
|
|
<a href={`/s/${guild.id}`}>
|
|
<CompletelyStylelessLink>
|
|
<ServerListingCard guild={guild} />
|
|
</CompletelyStylelessLink>
|
|
</a>
|
|
</CardContainer>
|
|
))}
|
|
</>
|
|
);
|
|
|
|
export const ServersListing = (props: ServersListingProps) => {
|
|
const { recentGuildSlugs, sortedGuildSlugs } = getRecentAndSortedGuilds(
|
|
props.guilds,
|
|
props.recentGuilds
|
|
);
|
|
|
|
return (
|
|
<ContentContainer>
|
|
{recentGuildSlugs.length !== 0 && (
|
|
<>
|
|
<SectionHead>Recent Guilds</SectionHead>
|
|
<CardList guilds={recentGuildSlugs} />
|
|
<SectionHead>All Guilds</SectionHead>
|
|
</>
|
|
)}
|
|
<CardList guilds={sortedGuildSlugs} />
|
|
</ContentContainer>
|
|
);
|
|
};
|