mirror of
https://github.com/CommunityOx/ox_lib.git
synced 2026-08-17 06:56:03 +01:00
* feat: Support image Tag in buttons in my server. ox_lib is heavily used. most of sample use cases for this is. Food image, Ingredients, Vehicle Parts, etc.. i believe font awesome is not enough for some use cases. i did suggest this on v3 pending PR. but it seems gets ignored. here i am gonna try to push this PR. to use this. icon must be not existing in the options. if both icon and image is in options, nothing will appear. image in metadata will still appear normaly. * tweak(web/menu): resize render image comparable to FA * refactor(web/context): use icon prop for images * refactor(web/list): use icon prop for images --------- Co-authored-by: Luke <39926192+LukeWasTakenn@users.noreply.github.com>
42 lines
1.5 KiB
TypeScript
42 lines
1.5 KiB
TypeScript
import { IconName, IconPrefix } from '@fortawesome/fontawesome-common-types';
|
|
|
|
type MenuPosition = 'top-left' | 'top-right' | 'bottom-left' | 'bottom-right';
|
|
type ChangeFunction = (selected: number, scrollIndex?: number, args?: any, checked?: boolean) => void;
|
|
|
|
interface MenuOptions {
|
|
label: string;
|
|
icon?: IconName | [IconPrefix, IconName] | string;
|
|
checked?: boolean;
|
|
values?: Array<string | { label: string; description: string }>;
|
|
description?: string;
|
|
defaultIndex?: number;
|
|
args?: Record<any, any>;
|
|
close?: boolean;
|
|
}
|
|
|
|
interface MenuProps {
|
|
id: string;
|
|
title: string;
|
|
options: MenuOptions[];
|
|
position?: MenuPosition;
|
|
disableInput?: boolean;
|
|
canClose?: boolean;
|
|
onClose?: (keyPressed?: 'Escape' | 'Backspace') => void;
|
|
onSelected?: ChangeFunction;
|
|
onSideScroll?: ChangeFunction;
|
|
onChecked?: ChangeFunction;
|
|
cb?: ChangeFunction;
|
|
}
|
|
|
|
type registerMenu = (data: MenuProps, cb: ChangeFunction) => void;
|
|
export const registerMenu: registerMenu = (data, cb) => exports.ox_lib.registerMenu(data, cb);
|
|
|
|
export const showMenu = (id: string): string => exports.ox_lib.showMenu(id);
|
|
|
|
export const hideMenu = (onExit: boolean): void => exports.ox_lib.hideMenu(onExit);
|
|
|
|
export const getOpenMenu = (): string | null => exports.ox_lib.getOpenMenu();
|
|
|
|
type setMenuOptions = (id: string, options: MenuOptions | MenuOptions[], index?: number) => void;
|
|
export const setMenuOptions: setMenuOptions = (id, options, index) => exports.ox_lib.setMenuOptions(id, options, index);
|