@ -1,14 +1,14 @@
|
|||||||
import { useRecoilState } from 'recoil';
|
import { useRecoilState } from 'recoil';
|
||||||
|
|
||||||
import { useSetHotkeyScope } from '@/ui/hotkey/hooks/useSetHotkeyScope';
|
import { useSetHotkeyScope } from '@/ui/hotkey/hooks/useSetHotkeyScope';
|
||||||
import { useOpenRightDrawer } from '@/ui/right-drawer/hooks/useOpenRightDrawer';
|
import { useRightDrawer } from '@/ui/right-drawer/hooks/useRightDrawer';
|
||||||
import { RightDrawerHotkeyScope } from '@/ui/right-drawer/types/RightDrawerHotkeyScope';
|
import { RightDrawerHotkeyScope } from '@/ui/right-drawer/types/RightDrawerHotkeyScope';
|
||||||
import { RightDrawerPages } from '@/ui/right-drawer/types/RightDrawerPages';
|
import { RightDrawerPages } from '@/ui/right-drawer/types/RightDrawerPages';
|
||||||
|
|
||||||
import { viewableCommentThreadIdState } from '../states/viewableCommentThreadIdState';
|
import { viewableCommentThreadIdState } from '../states/viewableCommentThreadIdState';
|
||||||
|
|
||||||
export function useOpenCommentThreadRightDrawer() {
|
export function useOpenCommentThreadRightDrawer() {
|
||||||
const openRightDrawer = useOpenRightDrawer();
|
const { openRightDrawer } = useRightDrawer();
|
||||||
const [, setViewableCommentThreadId] = useRecoilState(
|
const [, setViewableCommentThreadId] = useRecoilState(
|
||||||
viewableCommentThreadIdState,
|
viewableCommentThreadIdState,
|
||||||
);
|
);
|
||||||
|
|||||||
@ -6,7 +6,7 @@ import { currentUserState } from '@/auth/states/currentUserState';
|
|||||||
import { GET_COMPANIES } from '@/companies/queries';
|
import { GET_COMPANIES } from '@/companies/queries';
|
||||||
import { GET_PEOPLE } from '@/people/queries';
|
import { GET_PEOPLE } from '@/people/queries';
|
||||||
import { useSetHotkeyScope } from '@/ui/hotkey/hooks/useSetHotkeyScope';
|
import { useSetHotkeyScope } from '@/ui/hotkey/hooks/useSetHotkeyScope';
|
||||||
import { useOpenRightDrawer } from '@/ui/right-drawer/hooks/useOpenRightDrawer';
|
import { useRightDrawer } from '@/ui/right-drawer/hooks/useRightDrawer';
|
||||||
import { RightDrawerHotkeyScope } from '@/ui/right-drawer/types/RightDrawerHotkeyScope';
|
import { RightDrawerHotkeyScope } from '@/ui/right-drawer/types/RightDrawerHotkeyScope';
|
||||||
import { RightDrawerPages } from '@/ui/right-drawer/types/RightDrawerPages';
|
import { RightDrawerPages } from '@/ui/right-drawer/types/RightDrawerPages';
|
||||||
import { selectedRowIdsSelector } from '@/ui/table/states/selectedRowIdsSelector';
|
import { selectedRowIdsSelector } from '@/ui/table/states/selectedRowIdsSelector';
|
||||||
@ -22,7 +22,7 @@ import { viewableCommentThreadIdState } from '../states/viewableCommentThreadIdS
|
|||||||
import { CommentableEntity } from '../types/CommentableEntity';
|
import { CommentableEntity } from '../types/CommentableEntity';
|
||||||
|
|
||||||
export function useOpenCreateCommentThreadDrawerForSelectedRowIds() {
|
export function useOpenCreateCommentThreadDrawerForSelectedRowIds() {
|
||||||
const openRightDrawer = useOpenRightDrawer();
|
const { openRightDrawer } = useRightDrawer();
|
||||||
const [createCommentThreadMutation] = useCreateCommentThreadMutation();
|
const [createCommentThreadMutation] = useCreateCommentThreadMutation();
|
||||||
const currentUser = useRecoilValue(currentUserState);
|
const currentUser = useRecoilValue(currentUserState);
|
||||||
const [, setViewableCommentThreadId] = useRecoilState(
|
const [, setViewableCommentThreadId] = useRecoilState(
|
||||||
|
|||||||
@ -6,7 +6,7 @@ import { currentUserState } from '@/auth/states/currentUserState';
|
|||||||
import { GET_COMPANIES } from '@/companies/queries';
|
import { GET_COMPANIES } from '@/companies/queries';
|
||||||
import { GET_PEOPLE } from '@/people/queries';
|
import { GET_PEOPLE } from '@/people/queries';
|
||||||
import { useSetHotkeyScope } from '@/ui/hotkey/hooks/useSetHotkeyScope';
|
import { useSetHotkeyScope } from '@/ui/hotkey/hooks/useSetHotkeyScope';
|
||||||
import { useOpenRightDrawer } from '@/ui/right-drawer/hooks/useOpenRightDrawer';
|
import { useRightDrawer } from '@/ui/right-drawer/hooks/useRightDrawer';
|
||||||
import { RightDrawerHotkeyScope } from '@/ui/right-drawer/types/RightDrawerHotkeyScope';
|
import { RightDrawerHotkeyScope } from '@/ui/right-drawer/types/RightDrawerHotkeyScope';
|
||||||
import { RightDrawerPages } from '@/ui/right-drawer/types/RightDrawerPages';
|
import { RightDrawerPages } from '@/ui/right-drawer/types/RightDrawerPages';
|
||||||
import {
|
import {
|
||||||
@ -20,7 +20,7 @@ import { viewableCommentThreadIdState } from '../states/viewableCommentThreadIdS
|
|||||||
import { CommentableEntity } from '../types/CommentableEntity';
|
import { CommentableEntity } from '../types/CommentableEntity';
|
||||||
|
|
||||||
export function useOpenCreateCommentThreadDrawer() {
|
export function useOpenCreateCommentThreadDrawer() {
|
||||||
const openRightDrawer = useOpenRightDrawer();
|
const { openRightDrawer } = useRightDrawer();
|
||||||
const [createCommentThreadMutation] = useCreateCommentThreadMutation();
|
const [createCommentThreadMutation] = useCreateCommentThreadMutation();
|
||||||
const currentUser = useRecoilValue(currentUserState);
|
const currentUser = useRecoilValue(currentUserState);
|
||||||
const setHotkeyScope = useSetHotkeyScope();
|
const setHotkeyScope = useSetHotkeyScope();
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
import { useRecoilState } from 'recoil';
|
import { useRecoilState } from 'recoil';
|
||||||
|
|
||||||
import { useSetHotkeyScope } from '@/ui/hotkey/hooks/useSetHotkeyScope';
|
import { useSetHotkeyScope } from '@/ui/hotkey/hooks/useSetHotkeyScope';
|
||||||
import { useOpenRightDrawer } from '@/ui/right-drawer/hooks/useOpenRightDrawer';
|
import { useRightDrawer } from '@/ui/right-drawer/hooks/useRightDrawer';
|
||||||
import { RightDrawerHotkeyScope } from '@/ui/right-drawer/types/RightDrawerHotkeyScope';
|
import { RightDrawerHotkeyScope } from '@/ui/right-drawer/types/RightDrawerHotkeyScope';
|
||||||
import { RightDrawerPages } from '@/ui/right-drawer/types/RightDrawerPages';
|
import { RightDrawerPages } from '@/ui/right-drawer/types/RightDrawerPages';
|
||||||
|
|
||||||
@ -10,7 +10,7 @@ import { CommentableEntity } from '../types/CommentableEntity';
|
|||||||
|
|
||||||
// TODO: refactor with recoil callback to avoid rerender
|
// TODO: refactor with recoil callback to avoid rerender
|
||||||
export function useOpenTimelineRightDrawer() {
|
export function useOpenTimelineRightDrawer() {
|
||||||
const openRightDrawer = useOpenRightDrawer();
|
const { openRightDrawer } = useRightDrawer();
|
||||||
const [, setCommentableEntityArray] = useRecoilState(
|
const [, setCommentableEntityArray] = useRecoilState(
|
||||||
commentableEntityArrayState,
|
commentableEntityArrayState,
|
||||||
);
|
);
|
||||||
|
|||||||
@ -8,7 +8,7 @@ type OwnProps = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const StyledContainer = styled.div`
|
const StyledContainer = styled.div`
|
||||||
width: 220px;
|
width: ${({ theme }) => theme.leftNavBarWidth};
|
||||||
`;
|
`;
|
||||||
|
|
||||||
export default function MainNavbar({ children }: OwnProps) {
|
export default function MainNavbar({ children }: OwnProps) {
|
||||||
|
|||||||
@ -12,6 +12,8 @@ import {
|
|||||||
import { isDefined } from '~/utils/isDefined';
|
import { isDefined } from '~/utils/isDefined';
|
||||||
|
|
||||||
import { useScopedHotkeys } from '../../hotkey/hooks/useScopedHotkeys';
|
import { useScopedHotkeys } from '../../hotkey/hooks/useScopedHotkeys';
|
||||||
|
import { useRightDrawer } from '../hooks/useRightDrawer';
|
||||||
|
import { isRightDrawerExpandedState } from '../states/isRightDrawerExpandedState';
|
||||||
import { isRightDrawerOpenState } from '../states/isRightDrawerOpenState';
|
import { isRightDrawerOpenState } from '../states/isRightDrawerOpenState';
|
||||||
import { rightDrawerPageState } from '../states/rightDrawerPageState';
|
import { rightDrawerPageState } from '../states/rightDrawerPageState';
|
||||||
import { RightDrawerHotkeyScope } from '../types/RightDrawerHotkeyScope';
|
import { RightDrawerHotkeyScope } from '../types/RightDrawerHotkeyScope';
|
||||||
@ -41,23 +43,39 @@ export function RightDrawer() {
|
|||||||
isRightDrawerOpenState,
|
isRightDrawerOpenState,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
const [isRightDrawerExpanded] = useRecoilState(isRightDrawerExpandedState);
|
||||||
|
|
||||||
const [rightDrawerPage] = useRecoilState(rightDrawerPageState);
|
const [rightDrawerPage] = useRecoilState(rightDrawerPageState);
|
||||||
|
|
||||||
|
const { closeRightDrawer } = useRightDrawer();
|
||||||
|
|
||||||
const rightDrawerRef = useRef(null);
|
const rightDrawerRef = useRef(null);
|
||||||
|
|
||||||
useListenClickOutsideArrayOfRef({
|
useListenClickOutsideArrayOfRef({
|
||||||
refs: [rightDrawerRef],
|
refs: [rightDrawerRef],
|
||||||
callback: () => setIsRightDrawerOpen(false),
|
callback: () => closeRightDrawer(),
|
||||||
mode: ClickOutsideMode.absolute,
|
mode: ClickOutsideMode.absolute,
|
||||||
});
|
});
|
||||||
|
|
||||||
const theme = useTheme();
|
const theme = useTheme();
|
||||||
|
|
||||||
useScopedHotkeys(
|
useScopedHotkeys(
|
||||||
[Key.Escape],
|
[Key.Escape],
|
||||||
() => setIsRightDrawerOpen(false),
|
() => closeRightDrawer(),
|
||||||
RightDrawerHotkeyScope.RightDrawer,
|
RightDrawerHotkeyScope.RightDrawer,
|
||||||
[setIsRightDrawerOpen],
|
[setIsRightDrawerOpen],
|
||||||
);
|
);
|
||||||
|
|
||||||
|
const rightDrawerWidthExpanded = `calc(100% - ${
|
||||||
|
theme.leftNavBarWidth
|
||||||
|
} - ${theme.spacing(2)})`;
|
||||||
|
|
||||||
|
const rightDrawerWidth = isRightDrawerOpen
|
||||||
|
? isRightDrawerExpanded
|
||||||
|
? rightDrawerWidthExpanded
|
||||||
|
: theme.rightDrawerWidth
|
||||||
|
: '0';
|
||||||
|
|
||||||
if (!isDefined(rightDrawerPage)) {
|
if (!isDefined(rightDrawerPage)) {
|
||||||
return <></>;
|
return <></>;
|
||||||
}
|
}
|
||||||
@ -65,7 +83,7 @@ export function RightDrawer() {
|
|||||||
return (
|
return (
|
||||||
<StyledContainer
|
<StyledContainer
|
||||||
animate={{
|
animate={{
|
||||||
width: isRightDrawerOpen ? theme.rightDrawerWidth : '0',
|
width: rightDrawerWidth,
|
||||||
}}
|
}}
|
||||||
transition={{
|
transition={{
|
||||||
duration: theme.animation.duration.normal,
|
duration: theme.animation.duration.normal,
|
||||||
|
|||||||
@ -1,6 +1,7 @@
|
|||||||
import styled from '@emotion/styled';
|
import styled from '@emotion/styled';
|
||||||
|
|
||||||
import { RightDrawerTopBarCloseButton } from './RightDrawerTopBarCloseButton';
|
import { RightDrawerTopBarCloseButton } from './RightDrawerTopBarCloseButton';
|
||||||
|
import { RightDrawerTopBarExpandButton } from './RightDrawerTopBarExpandButton';
|
||||||
|
|
||||||
const StyledRightDrawerTopBar = styled.div`
|
const StyledRightDrawerTopBar = styled.div`
|
||||||
align-items: center;
|
align-items: center;
|
||||||
@ -10,20 +11,19 @@ const StyledRightDrawerTopBar = styled.div`
|
|||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: row;
|
flex-direction: row;
|
||||||
font-size: ${({ theme }) => theme.font.size.md};
|
font-size: ${({ theme }) => theme.font.size.md};
|
||||||
|
gap: ${({ theme }) => theme.spacing(1)};
|
||||||
height: 56px;
|
height: 56px;
|
||||||
justify-content: space-between;
|
justify-content: flex-start;
|
||||||
padding-left: 8px;
|
padding-left: ${({ theme }) => theme.spacing(2)};
|
||||||
padding-right: 8px;
|
|
||||||
|
padding-right: ${({ theme }) => theme.spacing(2)};
|
||||||
`;
|
`;
|
||||||
|
|
||||||
type OwnProps = {
|
export function RightDrawerTopBar() {
|
||||||
title?: string | null | undefined;
|
|
||||||
};
|
|
||||||
|
|
||||||
export function RightDrawerTopBar({ title }: OwnProps) {
|
|
||||||
return (
|
return (
|
||||||
<StyledRightDrawerTopBar>
|
<StyledRightDrawerTopBar>
|
||||||
<RightDrawerTopBarCloseButton />
|
<RightDrawerTopBarCloseButton />
|
||||||
|
<RightDrawerTopBarExpandButton />
|
||||||
</StyledRightDrawerTopBar>
|
</StyledRightDrawerTopBar>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,42 +1,19 @@
|
|||||||
import styled from '@emotion/styled';
|
|
||||||
import { useRecoilState } from 'recoil';
|
|
||||||
|
|
||||||
import { IconChevronsRight } from '@/ui/icon/index';
|
import { IconChevronsRight } from '@/ui/icon/index';
|
||||||
|
|
||||||
import { isRightDrawerOpenState } from '../states/isRightDrawerOpenState';
|
import { IconButton } from '../../button/components/IconButton';
|
||||||
|
import { useRightDrawer } from '../hooks/useRightDrawer';
|
||||||
const StyledButton = styled.button`
|
|
||||||
align-items: center;
|
|
||||||
background: none;
|
|
||||||
border: 1px solid ${({ theme }) => theme.border.color.light};
|
|
||||||
border-radius: ${({ theme }) => theme.border.radius.sm};
|
|
||||||
cursor: pointer;
|
|
||||||
display: flex;
|
|
||||||
flex-direction: row;
|
|
||||||
height: 24px;
|
|
||||||
padding: 3px;
|
|
||||||
|
|
||||||
transition: ${({ theme }) => theme.clickableElementBackgroundTransition};
|
|
||||||
|
|
||||||
width: 24px;
|
|
||||||
&:hover {
|
|
||||||
background: ${({ theme }) => theme.background.transparent.light};
|
|
||||||
}
|
|
||||||
svg {
|
|
||||||
color: ${({ theme }) => theme.font.color.tertiary};
|
|
||||||
}
|
|
||||||
`;
|
|
||||||
|
|
||||||
export function RightDrawerTopBarCloseButton() {
|
export function RightDrawerTopBarCloseButton() {
|
||||||
const [, setIsRightDrawerOpen] = useRecoilState(isRightDrawerOpenState);
|
const { closeRightDrawer } = useRightDrawer();
|
||||||
|
|
||||||
function handleButtonClick() {
|
function handleButtonClick() {
|
||||||
setIsRightDrawerOpen(false);
|
closeRightDrawer();
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<StyledButton onClick={handleButtonClick}>
|
<IconButton
|
||||||
<IconChevronsRight size={16} />
|
icon={<IconChevronsRight size={16} />}
|
||||||
</StyledButton>
|
onClick={handleButtonClick}
|
||||||
|
/>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -0,0 +1,31 @@
|
|||||||
|
import {
|
||||||
|
IconLayoutSidebarRightCollapse,
|
||||||
|
IconLayoutSidebarRightExpand,
|
||||||
|
} from '@tabler/icons-react';
|
||||||
|
import { useRecoilState } from 'recoil';
|
||||||
|
|
||||||
|
import { IconButton } from '../../button/components/IconButton';
|
||||||
|
import { isRightDrawerExpandedState } from '../states/isRightDrawerExpandedState';
|
||||||
|
|
||||||
|
export function RightDrawerTopBarExpandButton() {
|
||||||
|
const [isRightDrawerExpanded, setIsRightDrawerExpanded] = useRecoilState(
|
||||||
|
isRightDrawerExpandedState,
|
||||||
|
);
|
||||||
|
|
||||||
|
function handleButtonClick() {
|
||||||
|
setIsRightDrawerExpanded(!isRightDrawerExpanded);
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<IconButton
|
||||||
|
icon={
|
||||||
|
isRightDrawerExpanded ? (
|
||||||
|
<IconLayoutSidebarRightCollapse size={16} />
|
||||||
|
) : (
|
||||||
|
<IconLayoutSidebarRightExpand size={16} />
|
||||||
|
)
|
||||||
|
}
|
||||||
|
onClick={handleButtonClick}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
}
|
||||||
@ -22,7 +22,7 @@ type Story = StoryObj<typeof RightDrawerTopBar>;
|
|||||||
export const Default: Story = {
|
export const Default: Story = {
|
||||||
render: getRenderWrapperForComponent(
|
render: getRenderWrapperForComponent(
|
||||||
<div style={{ width: '500px' }}>
|
<div style={{ width: '500px' }}>
|
||||||
<RightDrawerTopBar title={'Title'} />
|
<RightDrawerTopBar />
|
||||||
</div>,
|
</div>,
|
||||||
),
|
),
|
||||||
parameters: {
|
parameters: {
|
||||||
|
|||||||
@ -1,15 +1,31 @@
|
|||||||
import { useRecoilState } from 'recoil';
|
import { useRecoilState } from 'recoil';
|
||||||
|
|
||||||
|
import { isRightDrawerExpandedState } from '../states/isRightDrawerExpandedState';
|
||||||
import { isRightDrawerOpenState } from '../states/isRightDrawerOpenState';
|
import { isRightDrawerOpenState } from '../states/isRightDrawerOpenState';
|
||||||
import { rightDrawerPageState } from '../states/rightDrawerPageState';
|
import { rightDrawerPageState } from '../states/rightDrawerPageState';
|
||||||
import { RightDrawerPages } from '../types/RightDrawerPages';
|
import { RightDrawerPages } from '../types/RightDrawerPages';
|
||||||
|
|
||||||
export function useOpenRightDrawer() {
|
export function useRightDrawer() {
|
||||||
const [, setIsRightDrawerOpen] = useRecoilState(isRightDrawerOpenState);
|
const [, setIsRightDrawerOpen] = useRecoilState(isRightDrawerOpenState);
|
||||||
|
const [, setIsRightDrawerExpanded] = useRecoilState(
|
||||||
|
isRightDrawerExpandedState,
|
||||||
|
);
|
||||||
|
|
||||||
const [, setRightDrawerPage] = useRecoilState(rightDrawerPageState);
|
const [, setRightDrawerPage] = useRecoilState(rightDrawerPageState);
|
||||||
|
|
||||||
return function openRightDrawer(rightDrawerPage: RightDrawerPages) {
|
function openRightDrawer(rightDrawerPage: RightDrawerPages) {
|
||||||
setRightDrawerPage(rightDrawerPage);
|
setRightDrawerPage(rightDrawerPage);
|
||||||
|
setIsRightDrawerExpanded(false);
|
||||||
setIsRightDrawerOpen(true);
|
setIsRightDrawerOpen(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
function closeRightDrawer() {
|
||||||
|
setIsRightDrawerExpanded(false);
|
||||||
|
setIsRightDrawerOpen(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
openRightDrawer,
|
||||||
|
closeRightDrawer,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@ -0,0 +1,6 @@
|
|||||||
|
import { atom } from 'recoil';
|
||||||
|
|
||||||
|
export const isRightDrawerExpandedState = atom<boolean>({
|
||||||
|
key: 'isRightDrawerExpandedState',
|
||||||
|
default: false,
|
||||||
|
});
|
||||||
@ -35,6 +35,7 @@ const common = {
|
|||||||
checkboxColumnWidth: '32px',
|
checkboxColumnWidth: '32px',
|
||||||
},
|
},
|
||||||
rightDrawerWidth: '500px',
|
rightDrawerWidth: '500px',
|
||||||
|
leftNavBarWidth: '220px',
|
||||||
clickableElementBackgroundTransition: 'background 0.1s ease',
|
clickableElementBackgroundTransition: 'background 0.1s ease',
|
||||||
lastLayerZIndex: 2147483647,
|
lastLayerZIndex: 2147483647,
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user