+ {clickableComponent && (
+
+ {clickableComponent}
+
+ )}
{hotkey && (
)}
- {buttonComponents && (
-
{buttonComponents}
- )}
- {isDropdownButtonOpen && (
+ {isDropdownOpen && (
{dropdownComponents}
diff --git a/front/src/modules/ui/dropdown/components/DropdownToggleEffect.tsx b/front/src/modules/ui/dropdown/components/DropdownToggleEffect.tsx
index d537eba1f..47099e214 100644
--- a/front/src/modules/ui/dropdown/components/DropdownToggleEffect.tsx
+++ b/front/src/modules/ui/dropdown/components/DropdownToggleEffect.tsx
@@ -1,6 +1,6 @@
import { useEffect } from 'react';
-import { useDropdownButton } from '../hooks/useDropdownButton';
+import { useDropdown } from '@/ui/dropdown/hooks/useDropdown';
export const DropdownToggleEffect = ({
dropdownId,
@@ -11,15 +11,15 @@ export const DropdownToggleEffect = ({
onDropdownClose?: () => void;
onDropdownOpen?: () => void;
}) => {
- const { isDropdownButtonOpen } = useDropdownButton({ dropdownId });
+ const { isDropdownOpen } = useDropdown({ dropdownId });
useEffect(() => {
- if (isDropdownButtonOpen) {
+ if (isDropdownOpen) {
onDropdownOpen?.();
} else {
onDropdownClose?.();
}
- }, [isDropdownButtonOpen, onDropdownClose, onDropdownOpen]);
+ }, [isDropdownOpen, onDropdownClose, onDropdownOpen]);
return null;
};
diff --git a/front/src/modules/ui/dropdown/hooks/useDropdownButton.ts b/front/src/modules/ui/dropdown/hooks/useDropdown.ts
similarity index 86%
rename from front/src/modules/ui/dropdown/hooks/useDropdownButton.ts
rename to front/src/modules/ui/dropdown/hooks/useDropdown.ts
index a1e373401..32b3def04 100644
--- a/front/src/modules/ui/dropdown/hooks/useDropdownButton.ts
+++ b/front/src/modules/ui/dropdown/hooks/useDropdown.ts
@@ -5,7 +5,7 @@ import { dropdownButtonHotkeyScopeScopedFamilyState } from '../states/dropdownBu
import { isDropdownButtonOpenScopedFamilyState } from '../states/isDropdownButtonOpenScopedFamilyState';
import { DropdownRecoilScopeContext } from '../states/recoil-scope-contexts/DropdownRecoilScopeContext';
-export const useDropdownButton = ({ dropdownId }: { dropdownId: string }) => {
+export const useDropdown = ({ dropdownId }: { dropdownId: string }) => {
const {
setHotkeyScopeAndMemorizePreviousScope,
goBackToPreviousHotkeyScope,
@@ -49,9 +49,9 @@ export const useDropdownButton = ({ dropdownId }: { dropdownId: string }) => {
};
return {
- isDropdownButtonOpen,
- closeDropdownButton,
- toggleDropdownButton,
- openDropdownButton,
+ isDropdownOpen: isDropdownButtonOpen,
+ closeDropdown: closeDropdownButton,
+ toggleDropdown: toggleDropdownButton,
+ openDropdown: openDropdownButton,
};
};
diff --git a/front/src/modules/ui/layout/show-page/components/ShowPageAddButton.tsx b/front/src/modules/ui/layout/show-page/components/ShowPageAddButton.tsx
index 9dacf20f9..63505ce0c 100644
--- a/front/src/modules/ui/layout/show-page/components/ShowPageAddButton.tsx
+++ b/front/src/modules/ui/layout/show-page/components/ShowPageAddButton.tsx
@@ -4,12 +4,12 @@ import { useOpenCreateActivityDrawer } from '@/activities/hooks/useOpenCreateAct
import { ActivityTargetableEntity } from '@/activities/types/ActivityTargetableEntity';
import { PageHotkeyScope } from '@/types/PageHotkeyScope';
import { IconButton } from '@/ui/button/components/IconButton';
-import { DropdownButton } from '@/ui/dropdown/components/DropdownButton';
import { StyledDropdownMenu } from '@/ui/dropdown/components/StyledDropdownMenu';
import { StyledDropdownMenuItemsContainer } from '@/ui/dropdown/components/StyledDropdownMenuItemsContainer';
-import { useDropdownButton } from '@/ui/dropdown/hooks/useDropdownButton';
+import { useDropdown } from '@/ui/dropdown/hooks/useDropdown';
import { IconCheckbox, IconNotes, IconPlus } from '@/ui/icon/index';
import { MenuItem } from '@/ui/menu-item/components/MenuItem';
+import { ViewBarDropdownButton } from '@/ui/view-bar/components/ViewBarDropdownButton';
import { ActivityType } from '~/generated/graphql';
const StyledContainer = styled.div`
@@ -21,28 +21,28 @@ export const ShowPageAddButton = ({
}: {
entity: ActivityTargetableEntity;
}) => {
- const { closeDropdownButton, toggleDropdownButton } = useDropdownButton({
+ const { closeDropdown, toggleDropdown } = useDropdown({
dropdownId: 'add-show-page',
});
const openCreateActivity = useOpenCreateActivityDrawer();
const handleSelect = (type: ActivityType) => {
openCreateActivity({ type, targetableEntities: [entity] });
- closeDropdownButton();
+ closeDropdown();
};
return (
-
}
dropdownComponents={
diff --git a/front/src/modules/ui/view-bar/components/AddFilterFromDetailsButton.tsx b/front/src/modules/ui/view-bar/components/AddFilterFromDetailsButton.tsx
index 46d168e1e..37f13118c 100644
--- a/front/src/modules/ui/view-bar/components/AddFilterFromDetailsButton.tsx
+++ b/front/src/modules/ui/view-bar/components/AddFilterFromDetailsButton.tsx
@@ -1,16 +1,16 @@
import { LightButton } from '@/ui/button/components/LightButton';
-import { useDropdownButton } from '@/ui/dropdown/hooks/useDropdownButton';
+import { useDropdown } from '@/ui/dropdown/hooks/useDropdown';
import { IconPlus } from '@/ui/icon';
import { FilterDropdownId } from '../constants/FilterDropdownId';
export const AddFilterFromDropdownButton = () => {
- const { toggleDropdownButton } = useDropdownButton({
+ const { toggleDropdown } = useDropdown({
dropdownId: FilterDropdownId,
});
const handleClick = () => {
- toggleDropdownButton();
+ toggleDropdown();
};
return (
diff --git a/front/src/modules/ui/view-bar/components/MultipleFiltersButton.tsx b/front/src/modules/ui/view-bar/components/MultipleFiltersButton.tsx
index 1d025d9c6..b9b5636b2 100644
--- a/front/src/modules/ui/view-bar/components/MultipleFiltersButton.tsx
+++ b/front/src/modules/ui/view-bar/components/MultipleFiltersButton.tsx
@@ -1,5 +1,5 @@
import { StyledHeaderDropdownButton } from '@/ui/dropdown/components/StyledHeaderDropdownButton';
-import { useDropdownButton } from '@/ui/dropdown/hooks/useDropdownButton';
+import { useDropdown } from '@/ui/dropdown/hooks/useDropdown';
import { useRecoilScopedState } from '@/ui/utilities/recoil-scope/hooks/useRecoilScopedState';
import { FilterDropdownId } from '../constants/FilterDropdownId';
@@ -12,7 +12,7 @@ import { selectedOperandInDropdownScopedState } from '../states/selectedOperandI
export const MultipleFiltersButton = () => {
const { ViewBarRecoilScopeContext } = useViewBarContext();
- const { isDropdownButtonOpen, toggleDropdownButton } = useDropdownButton({
+ const { isDropdownOpen, toggleDropdown } = useDropdown({
dropdownId: FilterDropdownId,
});
@@ -44,13 +44,13 @@ export const MultipleFiltersButton = () => {
};
const handleClick = () => {
- toggleDropdownButton();
+ toggleDropdown();
resetState();
};
return (
Filter
diff --git a/front/src/modules/ui/view-bar/components/MultipleFiltersDropdownButton.tsx b/front/src/modules/ui/view-bar/components/MultipleFiltersDropdownButton.tsx
index 5951cb4e2..1e212d958 100644
--- a/front/src/modules/ui/view-bar/components/MultipleFiltersDropdownButton.tsx
+++ b/front/src/modules/ui/view-bar/components/MultipleFiltersDropdownButton.tsx
@@ -1,10 +1,10 @@
-import { DropdownButton } from '@/ui/dropdown/components/DropdownButton';
import { HotkeyScope } from '@/ui/utilities/hotkey/types/HotkeyScope';
import { FilterDropdownId } from '../constants/FilterDropdownId';
import { MultipleFiltersButton } from './MultipleFiltersButton';
import { MultipleFiltersDropdownContent } from './MultipleFiltersDropdownContent';
+import { ViewBarDropdownButton } from './ViewBarDropdownButton';
type MultipleFiltersDropdownButtonProps = {
hotkeyScope: HotkeyScope;
@@ -14,9 +14,9 @@ export const MultipleFiltersDropdownButton = ({
hotkeyScope,
}: MultipleFiltersDropdownButtonProps) => {
return (
- }
+ buttonComponent={}
dropdownComponents={}
dropdownHotkeyScope={hotkeyScope}
/>
diff --git a/front/src/modules/ui/view-bar/components/SortDropdownButton.tsx b/front/src/modules/ui/view-bar/components/SortDropdownButton.tsx
index cd9a8b6c1..ecde95e1c 100644
--- a/front/src/modules/ui/view-bar/components/SortDropdownButton.tsx
+++ b/front/src/modules/ui/view-bar/components/SortDropdownButton.tsx
@@ -2,12 +2,11 @@ import { useCallback, useState } from 'react';
import { produce } from 'immer';
import { LightButton } from '@/ui/button/components/LightButton';
-import { DropdownButton } from '@/ui/dropdown/components/DropdownButton';
import { DropdownMenuHeader } from '@/ui/dropdown/components/DropdownMenuHeader';
import { StyledDropdownMenu } from '@/ui/dropdown/components/StyledDropdownMenu';
import { StyledDropdownMenuItemsContainer } from '@/ui/dropdown/components/StyledDropdownMenuItemsContainer';
import { StyledDropdownMenuSeparator } from '@/ui/dropdown/components/StyledDropdownMenuSeparator';
-import { useDropdownButton } from '@/ui/dropdown/hooks/useDropdownButton';
+import { useDropdown } from '@/ui/dropdown/hooks/useDropdown';
import { IconChevronDown } from '@/ui/icon';
import { MenuItem } from '@/ui/menu-item/components/MenuItem';
import { HotkeyScope } from '@/ui/utilities/hotkey/types/HotkeyScope';
@@ -20,6 +19,8 @@ import { sortsScopedState } from '../states/sortsScopedState';
import { SortDefinition } from '../types/SortDefinition';
import { SORT_DIRECTIONS, SortDirection } from '../types/SortDirection';
+import { ViewBarDropdownButton } from './ViewBarDropdownButton';
+
export type SortDropdownButtonProps = {
hotkeyScope: HotkeyScope;
isPrimaryButton?: boolean;
@@ -53,17 +54,17 @@ export const SortDropdownButton = ({
const isSortSelected = sorts.length > 0;
- const { toggleDropdownButton } = useDropdownButton({
+ const { toggleDropdown } = useDropdown({
dropdownId: SortDropdownId,
});
const handleButtonClick = () => {
- toggleDropdownButton();
+ toggleDropdown();
resetState();
};
const handleAddSort = (selectedSortDefinition: SortDefinition) => {
- toggleDropdownButton();
+ toggleDropdown();
setSorts(
produce(sorts, (existingSortsDraft) => {
@@ -90,10 +91,10 @@ export const SortDropdownButton = ({
};
return (
-
}
onClose={handleDropdownButtonClose}
- >
+ >
);
};
diff --git a/front/src/modules/ui/view-bar/components/ViewBar.tsx b/front/src/modules/ui/view-bar/components/ViewBar.tsx
index fe755e6df..900596d37 100644
--- a/front/src/modules/ui/view-bar/components/ViewBar.tsx
+++ b/front/src/modules/ui/view-bar/components/ViewBar.tsx
@@ -1,6 +1,6 @@
import { ReactNode } from 'react';
-import { useDropdownButton } from '@/ui/dropdown/hooks/useDropdownButton';
+import { useDropdown } from '@/ui/dropdown/hooks/useDropdown';
import { TopBar } from '@/ui/top-bar/TopBar';
import { FiltersHotkeyScope } from '../types/FiltersHotkeyScope';
@@ -23,7 +23,7 @@ export const ViewBar = ({
optionsDropdownButton,
optionsDropdownKey,
}: ViewBarProps) => {
- const { openDropdownButton: openOptionsDropdownButton } = useDropdownButton({
+ const { openDropdown: openOptionsDropdownButton } = useDropdown({
dropdownId: optionsDropdownKey,
});
diff --git a/front/src/modules/ui/view-bar/components/ViewBarDropdownButton.tsx b/front/src/modules/ui/view-bar/components/ViewBarDropdownButton.tsx
new file mode 100644
index 000000000..58d51f660
--- /dev/null
+++ b/front/src/modules/ui/view-bar/components/ViewBarDropdownButton.tsx
@@ -0,0 +1,47 @@
+import { Keys } from 'react-hotkeys-hook';
+import { Placement } from '@floating-ui/react';
+
+import { DropdownMenu } from '@/ui/dropdown/components/DropdownMenu';
+import { HotkeyScope } from '@/ui/utilities/hotkey/types/HotkeyScope';
+
+type DropdownButtonProps = {
+ buttonComponent: JSX.Element | JSX.Element[];
+ dropdownComponents: JSX.Element | JSX.Element[];
+ dropdownId: string;
+ hotkey?: {
+ key: Keys;
+ scope: string;
+ };
+ dropdownHotkeyScope: HotkeyScope;
+ dropdownPlacement?: Placement;
+ onClickOutside?: () => void;
+ onClose?: () => void;
+ onOpen?: () => void;
+};
+
+export const ViewBarDropdownButton = ({
+ buttonComponent,
+ dropdownComponents,
+ dropdownId,
+ hotkey,
+ dropdownHotkeyScope,
+ dropdownPlacement = 'bottom-end',
+ onClickOutside,
+ onClose,
+ onOpen,
+}: DropdownButtonProps) => {
+ return (
+
+ );
+};
diff --git a/front/src/modules/ui/view-bar/components/ViewsDropdownButton.tsx b/front/src/modules/ui/view-bar/components/ViewsDropdownButton.tsx
index d877bc419..95bd57686 100644
--- a/front/src/modules/ui/view-bar/components/ViewsDropdownButton.tsx
+++ b/front/src/modules/ui/view-bar/components/ViewsDropdownButton.tsx
@@ -8,12 +8,11 @@ import {
useSetRecoilState,
} from 'recoil';
-import { DropdownButton } from '@/ui/dropdown/components/DropdownButton';
import { StyledDropdownButtonContainer } from '@/ui/dropdown/components/StyledDropdownButtonContainer';
import { StyledDropdownMenu } from '@/ui/dropdown/components/StyledDropdownMenu';
import { StyledDropdownMenuItemsContainer } from '@/ui/dropdown/components/StyledDropdownMenuItemsContainer';
import { StyledDropdownMenuSeparator } from '@/ui/dropdown/components/StyledDropdownMenuSeparator';
-import { useDropdownButton } from '@/ui/dropdown/hooks/useDropdownButton';
+import { useDropdown } from '@/ui/dropdown/hooks/useDropdown';
import {
IconChevronDown,
IconList,
@@ -42,6 +41,8 @@ import { ViewsDropdownId } from '../constants/ViewsDropdownId';
import { ViewBarContext } from '../contexts/ViewBarContext';
import { useRemoveView } from '../hooks/useRemoveView';
+import { ViewBarDropdownButton } from './ViewBarDropdownButton';
+
const StyledBoldDropdownMenuItemsContainer = styled(
StyledDropdownMenuItemsContainer,
)`
@@ -105,10 +106,9 @@ export const ViewsDropdownButton = ({
entityCountInCurrentViewState as RecoilValueReadOnly,
);
- const { isDropdownButtonOpen, closeDropdownButton, toggleDropdownButton } =
- useDropdownButton({
- dropdownId: ViewsDropdownId,
- });
+ const { isDropdownOpen, closeDropdown } = useDropdown({
+ dropdownId: ViewsDropdownId,
+ });
const setViewEditMode = useSetRecoilState(viewEditModeState);
@@ -127,15 +127,15 @@ export const ViewsDropdownButton = ({
set(filtersScopedState(recoilScopeId), savedFilters);
set(sortsScopedState(recoilScopeId), savedSorts);
set(currentViewIdScopedState(recoilScopeId), viewId);
- closeDropdownButton();
+ closeDropdown();
},
- [onViewSelect, recoilScopeId, closeDropdownButton],
+ [onViewSelect, recoilScopeId, closeDropdown],
);
const handleAddViewButtonClick = () => {
setViewEditMode({ mode: 'create', viewId: undefined });
onViewEditModeChange?.();
- closeDropdownButton();
+ closeDropdown();
};
const handleEditViewButtonClick = (
@@ -145,7 +145,7 @@ export const ViewsDropdownButton = ({
event.stopPropagation();
setViewEditMode({ mode: 'edit', viewId });
onViewEditModeChange?.();
- closeDropdownButton();
+ closeDropdown();
};
const { removeView } = useRemoveView();
@@ -157,22 +157,15 @@ export const ViewsDropdownButton = ({
event.stopPropagation();
await removeView(viewId);
- closeDropdownButton();
- };
-
- const handleViewButtonClick = () => {
- toggleDropdownButton();
+ closeDropdown();
};
return (
-
+ buttonComponent={
+
{currentView?.name || defaultViewName}