Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions resource/interface/client/context.lua
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ local openContextMenu = nil
---@field id string
---@field title string
---@field menu? string
---@field position? MenuPosition
---@field onExit? fun()
---@field onBack? fun()
---@field canClose? boolean
Expand Down Expand Up @@ -67,6 +68,7 @@ function lib.showContext(id)
title = data.title,
canClose = data.canClose,
menu = data.menu,
position = data.position,
options = data.options
}
}, { sort_keys = true }))
Expand Down
10 changes: 6 additions & 4 deletions web/src/features/menu/context/ContextMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,13 @@ const openMenu = (id: string | undefined) => {
fetchNui<ContextMenuProps>('openContext', { id: id, back: true });
};

const useStyles = createStyles((theme) => ({
const useStyles = createStyles((theme, params: { position?: 'top-left' | 'top-right' | 'bottom-left' | 'bottom-right' }) => ({
container: {
position: 'absolute',
top: '15%',
right: '25%',
top: params.position === 'top-left' || params.position === 'top-right' ? '15%' : undefined,
left: params.position === 'top-left' || params.position === 'bottom-left' ? '5%' : undefined,
right: params.position === 'top-right' || params.position === 'bottom-right' ? '25%' : undefined,
bottom: params.position === 'bottom-left' || params.position === 'bottom-right' ? '15%' : undefined,,
width: 320,
height: 580,
},
Expand Down Expand Up @@ -47,7 +49,7 @@ const useStyles = createStyles((theme) => ({
}));

const ContextMenu: React.FC = () => {
const { classes } = useStyles();
const { classes } = useStyles({ position: contextMenu.position || 'top-right' });
const [visible, setVisible] = useState(false);
const [contextMenu, setContextMenu] = useState<ContextMenuProps>({
title: '',
Expand Down
1 change: 1 addition & 0 deletions web/src/typings/context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,6 @@ export interface ContextMenuProps {
title: string;
menu?: string;
canClose?: boolean;
position?: 'top-left' | 'top-right' | 'bottom-left' | 'bottom-right';
options: Options | Option[];
}