storybook and template fixes

This commit is contained in:
41666 2020-12-03 11:32:09 -05:00
parent 7371b5e490
commit 0e2c981560
11 changed files with 69 additions and 30 deletions

View file

@ -62,6 +62,8 @@ jobs:
- ui - ui
- bot - bot
steps: steps:
- uses: actions/checkout@master
- uses: actions/cache@v2 - uses: actions/cache@v2
with: with:
path: /tmp/.buildx-cache path: /tmp/.buildx-cache

View file

@ -1,5 +1,6 @@
const path = require('path'); const path = require('path');
const TsconfigPathsPlugin = require('tsconfig-paths-webpack-plugin'); const TsconfigPathsPlugin = require('tsconfig-paths-webpack-plugin');
const { NormalModuleReplacementPlugin } = require('webpack');
module.exports = { module.exports = {
stories: ['../src/**/*.stories.mdx', '../src/**/*.stories.@(js|jsx|ts|tsx)'], stories: ['../src/**/*.stories.mdx', '../src/**/*.stories.@(js|jsx|ts|tsx)'],
@ -11,6 +12,11 @@ module.exports = {
}), }),
]; ];
config.resolve.alias['next/link'] = path.resolve(
__dirname,
'mocks/next_link.tsx'
);
return config; return config;
}, },
typescript: { typescript: {

View file

@ -0,0 +1,8 @@
import * as React from 'react';
type Props = {
children: React.ReactNode;
};
const Link = (props: Props) => <>{props.children}</>;
export default Link;

View file

@ -31,6 +31,7 @@ As for infrastructure:
- CI/CD process deploys all pieces. - CI/CD process deploys all pieces.
- Discord Bot is deployed on a Google Cloud VM - Discord Bot is deployed on a Google Cloud VM
- UI & Backend is deployed via a Cloudflare Worker - Backend is deployed via a Cloudflare Worker
- UI is deployed via Google Cloud Run
Biggest thing to note: this "discord bot" is an optional piece of the system, and should always remain as such. Giving it responsibility has actual engineering and dollar cost. Biggest thing to note: this "discord bot" is an optional piece of the system, and should always remain as such. Giving it responsibility has actual engineering and dollar cost.

View file

@ -10,6 +10,7 @@ import {
RoleSafety, RoleSafety,
RoleypolyUser, RoleypolyUser,
CategoryType, CategoryType,
GuildSlug,
} from '.'; } from '.';
export const roleCategory: Role[] = [ export const roleCategory: Role[] = [
@ -139,9 +140,8 @@ export const roleWikiData = {
export const guild: Guild = { export const guild: Guild = {
name: 'emoji megaporium', name: 'emoji megaporium',
id: 'aaa', id: '421896162539470888',
icon: icon: '3372fd895ed913b55616c5e49cd50e60',
'https://cdn.discordapp.com/icons/421896162539470888/3372fd895ed913b55616c5e49cd50e60.png?size=256',
ownerid: 'bbb', ownerid: 'bbb',
membercount: 23453, membercount: 23453,
splash: '', splash: '',
@ -151,9 +151,8 @@ export const guildMap: { [x: string]: Guild } = {
'emoji megaporium': guild, 'emoji megaporium': guild,
Roleypoly: { Roleypoly: {
name: 'Roleypoly', name: 'Roleypoly',
id: 'aaa', id: '203493697696956418',
icon: icon: 'ff08d36f5aee1ff48f8377b65d031ab0',
'https://cdn.discordapp.com/icons/203493697696956418/ff08d36f5aee1ff48f8377b65d031ab0.png?size=256',
ownerid: 'bbb', ownerid: 'bbb',
membercount: 23453, membercount: 23453,
splash: '', splash: '',
@ -168,9 +167,8 @@ export const guildMap: { [x: string]: Guild } = {
}, },
Eclipse: { Eclipse: {
name: 'Eclipse', name: 'Eclipse',
id: 'aaa', id: '408821059161423873',
icon: icon: '49dfdd8b2456e2977e80a8b577b19c0d',
'https://cdn.discordapp.com/icons/408821059161423873/49dfdd8b2456e2977e80a8b577b19c0d.png?size=256',
ownerid: 'bbb', ownerid: 'bbb',
membercount: 23453, membercount: 23453,
splash: '', splash: '',
@ -185,11 +183,10 @@ export const guildData: GuildData = {
}; };
export const user: DiscordUser = { export const user: DiscordUser = {
id: '123', id: '62601275618889728',
username: 'okano cat', username: 'okano',
discriminator: '3266', discriminator: '0001',
avatar: avatar: 'ca2028bab0fe30e1af4392f3fa3576e2',
'https://cdn.discordapp.com/avatars/62601275618889728/b1292bb974557337702cb941fc038085.png',
bot: false, bot: false,
}; };
@ -239,3 +236,12 @@ export const guildEnum: GuildEnumeration = {
}, },
], ],
}; };
export const mastheadSlugs: GuildSlug[] = guildEnum.guildsList.map<GuildSlug>(
(guild, idx) => ({
id: guild.guild.id,
name: guild.guild.name,
icon: guild.guild.icon,
permissionLevel: idx % 3,
})
);

View file

@ -1,10 +1,16 @@
export const initialsFromName = (name: string) => export const initialsFromName = (name: string) =>
name !!name
? name
.split(' ') .split(' ')
.slice(0, 2) .slice(0, 2)
.map((x) => x[0]) .map((x) => x[0])
.join('') .join('')
.toUpperCase(); .toUpperCase()
: '';
export const avatarHash = (id: string, hash: string) => export const avatarHash = (
`https://cdn.discordapp.com/icons/${id}/${hash}.webp?size=256`; id: string,
hash: string,
bucket: 'icons' | 'avatars' = 'icons',
size: number = 256
) => `https://cdn.discordapp.com/${bucket}/${id}/${hash}.webp?size=${size}`;

View file

@ -276,7 +276,7 @@ export const BicycleDay: Variant = {
export const Christmas: Variant = { export const Christmas: Variant = {
// Dec 20-27 // Dec 20-27
activeIf: (currentDate?: Date) => activeIf: (currentDate?: Date) =>
true || matchDay(new Date('2021-Dec-20'), new Date('2021-Dec-28'), currentDate), matchDay(new Date('2021-Dec-20'), new Date('2021-Dec-28'), currentDate),
sharedProps: { sharedProps: {
circleFill: palette.green200, circleFill: palette.green200,
circleOuterFill: palette.red200, circleOuterFill: palette.red200,

View file

@ -16,7 +16,10 @@ export const ServerMasthead = (props: ServerMastheadProps) => {
return ( return (
<Wrapper> <Wrapper>
<Icon> <Icon>
<Avatar size={props.editable ? 60 : 48} src={guild.icon}> <Avatar
size={props.editable ? 60 : 48}
src={utils.avatarHash(guild.id, guild.icon, 'icons', 512)}
>
{utils.initialsFromName(props.guild.name)} {utils.initialsFromName(props.guild.name)}
</Avatar> </Avatar>
</Icon> </Icon>

View file

@ -17,7 +17,10 @@ export const UserAvatarGroup = (props: Props) => (
</GroupText> </GroupText>
&nbsp; &nbsp;
</Collapse> </Collapse>
<Avatar size={34} src={props.user.avatar}> <Avatar
size={34}
src={utils.avatarHash(props.user.id, props.user.avatar, 'avatars')}
>
{utils.initialsFromName(props.user.username)} {utils.initialsFromName(props.user.username)}
</Avatar> </Avatar>
</Group> </Group>

View file

@ -32,7 +32,7 @@ export const Authed = (props: Props) => {
<MastheadBase> <MastheadBase>
<MastheadAlignment> <MastheadAlignment>
<MastheadLeft> <MastheadLeft>
<Link href="/dashboard" passHref> <Link href="/dashboard" passHref prefetch={false}>
<MastheadA> <MastheadA>
<DynamicLogomark height={35} /> <DynamicLogomark height={35} />
</MastheadA> </MastheadA>
@ -75,7 +75,9 @@ export const Authed = (props: Props) => {
}} }}
hide={!userPopoverState} hide={!userPopoverState}
> >
{props.user && <UserAvatarGroup user={props.user} />} {props.user !== undefined && (
<UserAvatarGroup user={props.user} />
)}
</InteractionBase> </InteractionBase>
<Popover <Popover
headContent={<></>} headContent={<></>}

View file

@ -5,8 +5,9 @@ import {
member, member,
guildRoles, guildRoles,
guild, guild,
rpUser, user,
guildEnum, guildEnum,
mastheadSlugs,
} from 'roleypoly/common/types/storyData'; } from 'roleypoly/common/types/storyData';
const props: RolePickerTemplateProps = { const props: RolePickerTemplateProps = {
@ -17,9 +18,10 @@ const props: RolePickerTemplateProps = {
}, },
member: member, member: member,
guild: guild, guild: guild,
guilds: mastheadSlugs,
roles: guildRoles, roles: guildRoles,
editable: false, editable: false,
user: rpUser, user: user,
guildEnumeration: guildEnum, guildEnumeration: guildEnum,
activeGuildId: guild.id, activeGuildId: guild.id,
onSubmit: () => {}, onSubmit: () => {},