mirror of
https://github.com/roleypoly/roleypoly.git
synced 2025-06-17 09:59:10 +00:00
feat: Add majority of design system components, build system fixes (#11)
* feat(design-system): pre-port of roleypoly/ui * feat(design-system): port molecules * chore(design-system): prettier * feat(design-system): add intro card and MDX components * fix(common/utils): hack fixtures test data moved to design-system, update accordingly * chore: document protoReflection.ts * fix(design-system): some molecules missed the magic fuckery * ci: keep going on bazel test failures * fix(design-system): server masthead molecule missed the magic fuckery * chore: fix ts paths * chore: fix docker publisher * chore: fix docker publisher names * chore(discord-bot): fix publisher * chore(discord-bot): fix publisher
This commit is contained in:
parent
c41fcabfd0
commit
89f237cf22
133 changed files with 2795 additions and 278 deletions
28
src/design-system/molecules/server-masthead/BUILD.bazel
Normal file
28
src/design-system/molecules/server-masthead/BUILD.bazel
Normal file
|
@ -0,0 +1,28 @@
|
|||
load("//:hack/react.bzl", "react_library")
|
||||
load("//:hack/jest.bzl", "jest_test")
|
||||
|
||||
package(default_visibility = ["//visibility:public"])
|
||||
|
||||
react_library(
|
||||
name = "server-masthead",
|
||||
deps = [
|
||||
"next",
|
||||
"react",
|
||||
"react-icons",
|
||||
"styled-components",
|
||||
"//src/design-system/atoms/avatar",
|
||||
"//src/design-system/atoms/colors",
|
||||
"//src/design-system/atoms/timings",
|
||||
"//src/design-system/atoms/typography",
|
||||
"//src/design-system/shared-types",
|
||||
"@types/react",
|
||||
"@types/styled-components",
|
||||
],
|
||||
)
|
||||
|
||||
jest_test(
|
||||
src = ":server-masthead",
|
||||
deps = [
|
||||
"//src/design-system/shared-types",
|
||||
],
|
||||
)
|
|
@ -0,0 +1,19 @@
|
|||
jest.unmock('./ServerMasthead');
|
||||
|
||||
import * as React from 'react';
|
||||
import { shallow } from 'enzyme';
|
||||
import { ServerMasthead } from './ServerMasthead';
|
||||
import { guild } from 'roleypoly/src/design-system/shared-types/storyData';
|
||||
import { Editable } from './ServerMasthead.styled';
|
||||
|
||||
it('shows Edit Server when editable is true', () => {
|
||||
const view = shallow(<ServerMasthead editable={true} guild={guild} />);
|
||||
|
||||
expect(view.find(Editable).length).not.toBe(0);
|
||||
});
|
||||
|
||||
it('hides Edit Server when editable is true', () => {
|
||||
const view = shallow(<ServerMasthead editable={false} guild={guild} />);
|
||||
|
||||
expect(view.find(Editable).length).toBe(0);
|
||||
});
|
|
@ -0,0 +1,17 @@
|
|||
import * as React from 'react';
|
||||
import { ServerMasthead } from './ServerMasthead';
|
||||
import { guild } from 'roleypoly/src/design-system/shared-types/storyData';
|
||||
|
||||
export default {
|
||||
title: 'Molecules/Server Masthead',
|
||||
args: {
|
||||
editable: false,
|
||||
guild,
|
||||
},
|
||||
};
|
||||
|
||||
export const Default = (args) => <ServerMasthead {...args} />;
|
||||
export const Editable = (args) => <ServerMasthead {...args} />;
|
||||
Editable.args = {
|
||||
editable: true,
|
||||
};
|
|
@ -0,0 +1,37 @@
|
|||
import styled from 'styled-components';
|
||||
import { palette } from 'roleypoly/src/design-system/atoms/colors';
|
||||
import { transitions } from 'roleypoly/src/design-system/atoms/timings';
|
||||
import * as _ from 'styled-components'; // tslint:disable-line:no-duplicate-imports
|
||||
|
||||
export const Wrapper = styled.div`
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
`;
|
||||
|
||||
export const Name = styled.div`
|
||||
margin: 0 10px;
|
||||
overflow: hidden;
|
||||
white-space: nowrap;
|
||||
text-overflow: ellipsis;
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
flex-direction: column;
|
||||
justify-content: flex-start;
|
||||
`;
|
||||
|
||||
export const Icon = styled.div`
|
||||
flex-shrink: 0;
|
||||
`;
|
||||
|
||||
export const Editable = styled.div`
|
||||
color: ${palette.taupe500};
|
||||
display: flex;
|
||||
align-items: center;
|
||||
user-select: none;
|
||||
transition: color ${transitions.actionable}s ease-in-out;
|
||||
cursor: pointer;
|
||||
&:hover {
|
||||
color: ${palette.taupe600};
|
||||
}
|
||||
`;
|
|
@ -0,0 +1,36 @@
|
|||
import { Guild } from 'roleypoly/src/design-system/shared-types';
|
||||
import { Avatar, utils } from 'roleypoly/src/design-system/atoms/avatar';
|
||||
import { AccentTitle, AmbientLarge } from 'roleypoly/src/design-system/atoms/typography';
|
||||
import Link from 'next/link';
|
||||
import { guild } from 'roleypoly/src/design-system/shared-types/storyData';
|
||||
import * as React from 'react';
|
||||
import { GoPencil } from 'react-icons/go';
|
||||
import { Editable, Icon, Name, Wrapper } from './ServerMasthead.styled';
|
||||
|
||||
export type ServerMastheadProps = {
|
||||
guild: Guild;
|
||||
editable: boolean;
|
||||
};
|
||||
|
||||
export const ServerMasthead = (props: ServerMastheadProps) => {
|
||||
return (
|
||||
<Wrapper>
|
||||
<Icon>
|
||||
<Avatar size={props.editable ? 60 : 48} src={guild.icon}>
|
||||
{utils.initialsFromName(props.guild.name)}
|
||||
</Avatar>
|
||||
</Icon>
|
||||
<Name>
|
||||
<AccentTitle>{props.guild.name}</AccentTitle>
|
||||
{props.editable && (
|
||||
<Link href="/s/[id]/edit" as={`/s/${props.guild.id}/edit`}>
|
||||
<Editable role="button">
|
||||
<GoPencil />
|
||||
<AmbientLarge>Edit Server</AmbientLarge>
|
||||
</Editable>
|
||||
</Link>
|
||||
)}
|
||||
</Name>
|
||||
</Wrapper>
|
||||
);
|
||||
};
|
1
src/design-system/molecules/server-masthead/index.ts
Normal file
1
src/design-system/molecules/server-masthead/index.ts
Normal file
|
@ -0,0 +1 @@
|
|||
export * from './ServerMasthead';
|
Loading…
Add table
Add a link
Reference in a new issue