mirror of
https://github.com/roleypoly/roleypoly.git
synced 2025-06-17 01:59:08 +00:00
feat(web): show recent guilds in masthead
This commit is contained in:
parent
8ace9abf63
commit
f01325cfba
8 changed files with 81 additions and 37 deletions
|
@ -9,6 +9,7 @@ import { GuildNavItem } from './GuildNav.styled';
|
|||
|
||||
type Props = {
|
||||
guilds: GuildSlug[];
|
||||
recentGuilds: string[];
|
||||
};
|
||||
|
||||
const tooltipId = 'guildnav';
|
||||
|
@ -27,23 +28,53 @@ 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 recentGuildSlugs: GuildSlug[] = props.recentGuilds
|
||||
.reduce<(GuildSlug | undefined)[]>(
|
||||
(acc, id) => [...acc, props.guilds.find((guild) => guild.id === id)],
|
||||
[]
|
||||
)
|
||||
.filter((slug) => slug !== undefined);
|
||||
|
||||
console.log({
|
||||
recentGuilds: props.recentGuilds,
|
||||
slugs: props.guilds,
|
||||
recentSlugs: recentGuildSlugs,
|
||||
});
|
||||
|
||||
const sortedSlugs = sortBy(props.guilds, 'name', (a: string, b: string) =>
|
||||
a.toLowerCase() > b.toLowerCase() ? 1 : -1
|
||||
);
|
||||
|
||||
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={sortedSlugs} />
|
||||
<ReactTooltip id={tooltipId} />
|
||||
</Scrollbars>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
|
|
@ -69,7 +69,7 @@ export const Authed = (props: Props) => {
|
|||
{() => (
|
||||
<GuildNav
|
||||
guilds={props.guilds}
|
||||
recentGuilds={props.recentGuilds}
|
||||
recentGuilds={props.recentGuilds || []}
|
||||
/>
|
||||
)}
|
||||
</Popover>
|
||||
|
|
|
@ -8,9 +8,15 @@ import * as React from 'react';
|
|||
export type RolePickerTemplateProps = RolePickerProps & Omit<AppShellProps, 'children'>;
|
||||
|
||||
export const RolePickerTemplate = (props: RolePickerTemplateProps) => {
|
||||
const { user, guilds, activeGuildId, ...pickerProps } = props;
|
||||
const { user, guilds, activeGuildId, recentGuilds, ...pickerProps } = props;
|
||||
return (
|
||||
<AppShell activeGuildId={activeGuildId} user={user} guilds={guilds} small>
|
||||
<AppShell
|
||||
activeGuildId={activeGuildId}
|
||||
user={user}
|
||||
guilds={guilds}
|
||||
recentGuilds={recentGuilds}
|
||||
small
|
||||
>
|
||||
<RolePicker {...pickerProps} />
|
||||
</AppShell>
|
||||
);
|
||||
|
|
|
@ -1,11 +1,8 @@
|
|||
import { AppShell, AppShellProps } from '@roleypoly/design-system/organisms/app-shell';
|
||||
import { ServersListing } from '@roleypoly/design-system/organisms/servers-listing/ServersListing';
|
||||
import { GuildSlug } from '@roleypoly/types';
|
||||
import * as React from 'react';
|
||||
|
||||
type ServerTemplateProps = Omit<AppShellProps, 'children'> & {
|
||||
guilds: GuildSlug[];
|
||||
};
|
||||
type ServerTemplateProps = Omit<AppShellProps, 'children'>;
|
||||
|
||||
export const ServersTemplate = (props: ServerTemplateProps) => (
|
||||
<AppShell {...props} disableGuildPicker>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue