From 69b6735497e37677ac7ef3bfb6a140abfb8fc0f1 Mon Sep 17 00:00:00 2001 From: Eric Vicenti Date: Tue, 30 Apr 2024 14:35:55 -0700 Subject: [PATCH] Create dropdown button --- .../packages/app/components/new-group.tsx | 10 ++- .../app/components/options-dropdown.tsx | 26 ++++--- .../app/components/titlebar-common.tsx | 75 +++++++++++++++---- 3 files changed, 85 insertions(+), 26 deletions(-) diff --git a/frontend/packages/app/components/new-group.tsx b/frontend/packages/app/components/new-group.tsx index 03c574a77..d3efc9f15 100644 --- a/frontend/packages/app/components/new-group.tsx +++ b/frontend/packages/app/components/new-group.tsx @@ -6,7 +6,7 @@ import {SubmitHandler, useForm} from 'react-hook-form' import * as z from 'zod' import {useCreateGroup} from '../models/groups' import {useNavigate} from '../utils/useNavigate' -import {AppDialog, DialogTitle} from './dialog' +import {AppDialog, DialogTitle, useAppDialog} from './dialog' import {FormInput} from './form-input' const newGroupSchema = z.object({ @@ -117,3 +117,11 @@ export function CreateGroupButton({ /> ) } + +function AddGroupDialog({onClose}: {onClose: () => void}) { + return +} + +export function useCreateGroupDialog() { + return useAppDialog(AddGroupDialog) +} diff --git a/frontend/packages/app/components/options-dropdown.tsx b/frontend/packages/app/components/options-dropdown.tsx index 3aa12571d..8249803ce 100644 --- a/frontend/packages/app/components/options-dropdown.tsx +++ b/frontend/packages/app/components/options-dropdown.tsx @@ -13,6 +13,7 @@ import {usePopoverState} from '../use-popover-state' export type MenuItemType = { key: string label: string + subLabel?: string icon: FC onPress: () => void } @@ -20,10 +21,12 @@ export type MenuItemType = { export function OptionsDropdown({ menuItems, hiddenUntilItemHover, + button, }: { menuItems: (MenuItemType | null)[] hiddenUntilItemHover?: boolean hover?: boolean + button?: JSX.Element }) { const popoverState = usePopoverState() return ( @@ -35,16 +38,18 @@ export function OptionsDropdown({ > - + } + /> + {createGroup.content} + + ) +} + export function PageActionButtons(props: TitleBarProps) { const route = useNavRoute() - let buttonGroup: ReactNode[] = [] + let buttonGroup: ReactNode[] = [] if (route.key === 'draft') { buttonGroup = [] - } else if (route.key === 'documents') { - buttonGroup = [ - , - ] } else if (route.key == 'contacts') { - buttonGroup = [] - } else if (route.key == 'account' && route.tab === 'groups') { buttonGroup = [ - , + , + , ] + } else if (route.key == 'account' && route.tab === 'groups') { + buttonGroup = [] } else if (route.key == 'group') { buttonGroup = [ , - , , - , - , + , + , ] } else if (route.key === 'publication') { buttonGroup = [ , , + , , ] } else if (route.key === 'account') { buttonGroup = [ , + , , ] }