chore: restructure project into yarn workspaces, remove next

This commit is contained in:
41666 2021-03-09 23:25:16 -05:00
parent 49e308507e
commit 8d06327c03
266 changed files with 16466 additions and 3350 deletions

View file

@ -0,0 +1,34 @@
import * as React from 'react';
import { mockCategory, roleCategory, roleWikiData } from '../../fixtures/storyData';
import { PickerCategory } from './PickerCategory';
export default {
title: 'Molecules/Picker Category',
component: PickerCategory,
args: {
title: 'Pronouns',
roles: roleCategory,
category: mockCategory,
selectedRoles: [],
},
};
export const Default = (args) => {
return <PickerCategory {...args} />;
};
export const Single = (args) => {
return <PickerCategory {...args} type="single" />;
};
Single.args = {
type: 'single',
};
export const Multi = (args) => {
return <PickerCategory {...args} type="single" />;
};
Multi.args = {
type: 'multi',
};
export const Wiki = (args) => {
return <PickerCategory {...args} wikiMode roleWikiData={roleWikiData} />;
};

View file

@ -0,0 +1,20 @@
import styled from 'styled-components';
export const Head = styled.div`
margin: 7px 5px;
line-height: 200%;
display: flex;
align-items: center;
justify-content: space-between;
`;
export const HeadTitle = styled.div`
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
`;
export const HeadSub = styled.div`
flex-shrink: 0;
margin-top: -4px;
`;

View file

@ -0,0 +1,68 @@
import { Role } from '@roleypoly/design-system/atoms/role';
import { AmbientLarge, LargeText } from '@roleypoly/design-system/atoms/typography';
import * as React from 'react';
import ReactTooltip from 'react-tooltip';
import styled from 'styled-components';
import {
Category as RPCCategory,
Role as RPCRole,
RoleSafety,
} from '../../../../src/common/types';
import { sortBy } from '../../../../src/common/utils/sortBy';
import { Head, HeadSub, HeadTitle } from './PickerCategory.styled';
export type CategoryProps = {
title: string;
roles: RPCRole[];
category: RPCCategory;
selectedRoles: string[];
onChange: (role: RPCRole) => (newState: boolean) => void;
type: 'single' | 'multi';
} & (
| {
wikiMode: true;
roleWikiData: { [roleId: string]: string };
}
| {
wikiMode: false;
}
);
const Category = styled.div`
display: flex;
flex-wrap: wrap;
`;
const Container = styled.div`
overflow: hidden;
padding: 5px;
`;
export const PickerCategory = (props: CategoryProps) => (
<div>
<Head>
<HeadTitle>
<LargeText>{props.title}</LargeText>
</HeadTitle>
{props.type === 'single' && (
<HeadSub>
<AmbientLarge>Pick one</AmbientLarge>
</HeadSub>
)}
</Head>
<Category>
{sortBy(props.roles, 'position').map((role, idx) => (
<Container key={idx}>
<Role
role={role}
selected={props.selectedRoles.includes(role.id)}
onClick={props.onChange(role)}
disabled={role.safety !== RoleSafety.Safe}
tooltipId={props.category.id}
/>
</Container>
))}
</Category>
<ReactTooltip id={props.category.id} />
</div>
);

View file

@ -0,0 +1 @@
export { PickerCategory } from './PickerCategory';