mirror of
https://github.com/roleypoly/roleypoly.git
synced 2025-06-16 09:39:09 +00:00
Refactor node packages to yarn workspaces & ditch next.js for CRA. (#161)
* chore: restructure project into yarn workspaces, remove next * fix tests, remove webapp from terraform * remove more ui deployment bits * remove pages, fix FUNDING.yml * remove isomorphism * remove next providers * fix linting issues * feat: start basis of new web ui system on CRA * chore: move types to @roleypoly/types package * chore: move src/common/utils to @roleypoly/misc-utils * chore: remove roleypoly/ path remappers * chore: renmove vercel config * chore: re-add worker-types to api package * chore: fix type linting scope for api * fix(web): craco should include all of packages dir * fix(ci): change api webpack path for wrangler * chore: remove GAR actions from CI * chore: update codeql job * chore: test better github dar matcher in lint-staged
This commit is contained in:
parent
49e308507e
commit
2ff6588030
328 changed files with 16624 additions and 3525 deletions
34
packages/design-system/atoms/popover/Popover.stories.tsx
Normal file
34
packages/design-system/atoms/popover/Popover.stories.tsx
Normal file
|
@ -0,0 +1,34 @@
|
|||
import { Button } from '@roleypoly/design-system/atoms/button';
|
||||
import * as React from 'react';
|
||||
import { Popover as PopoverComponent } from './Popover';
|
||||
|
||||
export default {
|
||||
title: 'Atoms/Popover',
|
||||
argTypes: {
|
||||
canDefocus: { control: 'boolean' },
|
||||
},
|
||||
args: {
|
||||
canDefocus: true,
|
||||
},
|
||||
};
|
||||
|
||||
export const Popover = ({ canDefocus }) => {
|
||||
const [isOpen, setIsOpen] = React.useState(false);
|
||||
|
||||
return (
|
||||
<div style={{ padding: 50 }}>
|
||||
<Button size="small" onClick={() => setIsOpen(!isOpen)}>
|
||||
{!isOpen ? 'Open' : 'Close'} me!
|
||||
</Button>
|
||||
<PopoverComponent
|
||||
position="top right"
|
||||
active={isOpen}
|
||||
onExit={() => setIsOpen(false)}
|
||||
canDefocus={canDefocus}
|
||||
headContent={<>Hello c:</>}
|
||||
>
|
||||
stuff
|
||||
</PopoverComponent>
|
||||
</div>
|
||||
);
|
||||
};
|
90
packages/design-system/atoms/popover/Popover.styled.ts
Normal file
90
packages/design-system/atoms/popover/Popover.styled.ts
Normal file
|
@ -0,0 +1,90 @@
|
|||
import { onSmallScreen, onTablet } from '@roleypoly/design-system/atoms/breakpoints';
|
||||
import { palette } from '@roleypoly/design-system/atoms/colors';
|
||||
import { transitions } from '@roleypoly/design-system/atoms/timings';
|
||||
import styled, { css } from 'styled-components';
|
||||
|
||||
type PopoverStyledProps = {
|
||||
active: boolean;
|
||||
preferredWidth?: number;
|
||||
};
|
||||
|
||||
export const PopoverBase = styled.div<PopoverStyledProps>`
|
||||
box-sizing: border-box;
|
||||
position: absolute;
|
||||
background-color: ${palette.taupe100};
|
||||
padding: 5px;
|
||||
border: 2px solid rgba(0, 0, 0, 0.15);
|
||||
border-radius: 3px;
|
||||
z-index: 10;
|
||||
transition: opacity ${transitions.out2in}s ease-in,
|
||||
transform ${transitions.out2in}s ease-in;
|
||||
min-width: ${(props) => props.preferredWidth || 320}px;
|
||||
max-width: 100vw;
|
||||
${(props) =>
|
||||
!props.active &&
|
||||
css`
|
||||
transform: translateY(-2vh);
|
||||
opacity: 0;
|
||||
pointer-events: none;
|
||||
`}
|
||||
${onSmallScreen(
|
||||
css`
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
bottom: 0;
|
||||
right: 0;
|
||||
min-width: unset;
|
||||
width: 100vw;
|
||||
height: 100vh;
|
||||
`
|
||||
)};
|
||||
`;
|
||||
|
||||
export const DefocusHandler = styled.div<PopoverStyledProps>`
|
||||
background-color: rgba(0, 0, 0, 0.01);
|
||||
position: fixed;
|
||||
z-index: -1;
|
||||
top: 0;
|
||||
bottom: 0;
|
||||
left: 0;
|
||||
right: 0;
|
||||
${(props) =>
|
||||
!props.active &&
|
||||
css`
|
||||
display: none;
|
||||
pointer-events: none;
|
||||
`}
|
||||
`;
|
||||
|
||||
export const PopoverHead = styled.div`
|
||||
display: flex;
|
||||
align-items: center;
|
||||
`;
|
||||
|
||||
export const PopoverHeadCloser = styled.div`
|
||||
flex: 0;
|
||||
font-size: 2em;
|
||||
cursor: pointer;
|
||||
margin-right: 10px;
|
||||
border-radius: 2em;
|
||||
min-width: 1.4em;
|
||||
height: 1.4em;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
${onTablet(
|
||||
css`
|
||||
display: none;
|
||||
`
|
||||
)}
|
||||
|
||||
&:hover {
|
||||
background: rgba(0, 0, 0, 0.1);
|
||||
}
|
||||
`;
|
||||
|
||||
export const PopoverContent = styled.div`
|
||||
padding: 5px;
|
||||
overflow-y: hidden;
|
||||
`;
|
43
packages/design-system/atoms/popover/Popover.tsx
Normal file
43
packages/design-system/atoms/popover/Popover.tsx
Normal file
|
@ -0,0 +1,43 @@
|
|||
import { globalOnKeyUp } from '@roleypoly/design-system/atoms/key-events';
|
||||
import * as React from 'react';
|
||||
import { IoMdClose } from 'react-icons/io';
|
||||
import {
|
||||
DefocusHandler,
|
||||
PopoverBase,
|
||||
PopoverContent,
|
||||
PopoverHead,
|
||||
PopoverHeadCloser,
|
||||
} from './Popover.styled';
|
||||
|
||||
type PopoverProps = {
|
||||
children: () => React.ReactNode;
|
||||
position: 'top left' | 'top right' | 'bottom left' | 'bottom right';
|
||||
active: boolean;
|
||||
canDefocus?: boolean;
|
||||
onExit?: (type: 'escape' | 'defocus' | 'explicit') => void;
|
||||
headContent: React.ReactNode;
|
||||
preferredWidth?: number;
|
||||
};
|
||||
|
||||
export const Popover = (props: PopoverProps) => {
|
||||
globalOnKeyUp(['Escape'], () => props.onExit?.('escape'), props.active);
|
||||
return (
|
||||
<>
|
||||
<PopoverBase active={props.active} preferredWidth={props.preferredWidth}>
|
||||
<PopoverHead>
|
||||
<PopoverHeadCloser onClick={() => props.onExit?.('explicit')}>
|
||||
<IoMdClose />
|
||||
</PopoverHeadCloser>
|
||||
<div>{props.headContent}</div>
|
||||
</PopoverHead>
|
||||
<PopoverContent>{props.children()}</PopoverContent>
|
||||
</PopoverBase>
|
||||
{props.canDefocus && (
|
||||
<DefocusHandler
|
||||
active={props.active}
|
||||
onClick={() => props.onExit?.('defocus')}
|
||||
/>
|
||||
)}
|
||||
</>
|
||||
);
|
||||
};
|
1
packages/design-system/atoms/popover/index.ts
Normal file
1
packages/design-system/atoms/popover/index.ts
Normal file
|
@ -0,0 +1 @@
|
|||
export * from './Popover';
|
Loading…
Add table
Add a link
Reference in a new issue