Feat/recent guilds (#89) (#167)

* 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
This commit is contained in:
41666 2021-03-13 19:31:36 -05:00 committed by GitHub
parent 3a36d7a85d
commit 99952aa19f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
22 changed files with 302 additions and 66 deletions

View file

@ -1,5 +1,5 @@
import { NavSlug } from '@roleypoly/design-system/molecules/nav-slug';
import { sortBy } from '@roleypoly/misc-utils/sortBy';
import { getRecentAndSortedGuilds } from '@roleypoly/misc-utils/guildListing';
import { GuildSlug, UserGuildPermissions } from '@roleypoly/types';
import * as React from 'react';
import Scrollbars from 'react-custom-scrollbars';
@ -9,6 +9,7 @@ import { GuildNavItem } from './GuildNav.styled';
type Props = {
guilds: GuildSlug[];
recentGuilds: string[];
};
const tooltipId = 'guildnav';
@ -27,23 +28,41 @@ const Badges = (props: { guild: GuildSlug }) => {
}, [props.guild.permissionLevel]);
};
export const GuildNav = (props: Props) => (
<div>
<Scrollbars
universal
autoHide
// autoHeight
style={{ height: 'calc(100vh - 45px - 1.4em)', overflowX: 'hidden' }}
>
{sortBy(props.guilds, 'name', (a: string, b: string) =>
a.toLowerCase() > b.toLowerCase() ? 1 : -1
).map((guild) => (
<GuildNavItem href={`/s/${guild.id}`} key={guild.id}>
<NavSlug guild={guild || null} key={guild.id} />
<Badges guild={guild} />
</GuildNavItem>
))}
<ReactTooltip id={tooltipId} />
</Scrollbars>
</div>
const NavList = (props: { guilds: Props['guilds'] }) => (
<>
{props.guilds.map((guild) => (
<GuildNavItem href={`/s/${guild.id}`} key={guild.id}>
<NavSlug guild={guild || null} key={guild.id} />
<Badges guild={guild} />
</GuildNavItem>
))}
</>
);
export const GuildNav = (props: Props) => {
const { sortedGuildSlugs, recentGuildSlugs } = getRecentAndSortedGuilds(
props.guilds,
props.recentGuilds
);
return (
<div>
<Scrollbars
universal
autoHide
// autoHeight
style={{ height: 'calc(100vh - 45px - 1.4em)', overflowX: 'hidden' }}
>
{recentGuildSlugs && (
<>
<div>Recents</div>
<NavList guilds={recentGuildSlugs} />
<div>All Guilds</div>
</>
)}
<NavList guilds={sortedGuildSlugs} />
<ReactTooltip id={tooltipId} />
</Scrollbars>
</div>
);
};