Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 | import { css } from '@emotion/react'; import styled from '@emotion/styled'; import { memo, type ReactNode } from 'react'; import { match } from 'ts-pattern'; import { Group } from '@allshares/studio-design-system'; import { useDesignerTemplateDrawerContext } from './RuleTemplateDrawer.context'; import { ListTemplates } from './templates/list-templates/ListTemplates'; import { PerformanceSharePlanTemplate } from './templates/performance-share-plan/PerformanceSharePlanTemplate'; import { SingleRateCommissionTemplate } from './templates/single-rate-commission/SingleRateCommissionTemplate'; const DRAWER_WIDTH = '440px'; const StyledDrawerContainer = styled.div<{ isDrawerOpen: boolean }>` display: flex; flex-direction: column; position: absolute; left: 0; width: ${({ isDrawerOpen }) => (isDrawerOpen ? DRAWER_WIDTH : '0')}; left: ${({ isDrawerOpen }) => (isDrawerOpen ? '0' : `-${DRAWER_WIDTH}`)}; height: 100%; z-index: 500; flex: 1; background-color: ${({ theme }) => theme.ds.colors.gray[0]}; transition: ${({ theme }) => theme.ds.transitions.default('margin-left')}; border-right: 1px solid ${({ theme }) => theme.ds.colors.gray[100]}; box-shadow: ${({ theme }) => theme.ds.shadows.soft}; [data-color-scheme='dark'] & { background-color: ${({ theme }) => theme.ds.colors.dark[800]}; border-color: ${({ theme }) => theme.ds.colors.dark[600]}; } `; const StyledEditorContainer = styled.div<{ readonly isDrawerOpen: boolean; }>` flex: 1; min-height: 0; min-width: 0; margin-left: ${({ isDrawerOpen }) => (isDrawerOpen ? DRAWER_WIDTH : '0')}; `; interface RuleTemplateDrawerContainerProps { readonly children: ReactNode; } export const RuleTemplateDrawerContainer = memo(function RuleTemplateDrawerContainer({ children, }: RuleTemplateDrawerContainerProps) { const { isRuleTemplateDrawerOpen, selectedRuleTemplate } = useDesignerTemplateDrawerContext(); return ( <Group css={css` height: 100%; `} > <StyledDrawerContainer isDrawerOpen={isRuleTemplateDrawerOpen}> {match(selectedRuleTemplate) .with(null, () => <ListTemplates />) .with('performance-share-plan', () => <PerformanceSharePlanTemplate />) .with('single-rate-commission', () => <SingleRateCommissionTemplate />) .exhaustive()} </StyledDrawerContainer> <StyledEditorContainer isDrawerOpen={isRuleTemplateDrawerOpen}>{children}</StyledEditorContainer> </Group> ); }); |