Refactored hooks to specify events and reworked the dropdowns to be significantly faster and more responsive. (#304)
* Updated events to be more specific * Update more events * Update globalmousepos * Update themes and submap module to show submap name. * Type fixes * Reworked menu position calculation logic to be much more efficient. * Revert import file location * We luv arrow functions * Remove globalMousePos remnants since it's unused. * Added the ability to configure menu dropdown transition and duration. * Fix type
This commit is contained in:
@@ -1,13 +1,29 @@
|
||||
import { Opt } from 'lib/option';
|
||||
import { HexColor, RecursiveOptionsObject } from 'lib/types/options';
|
||||
import { HexColor, MatugenTheme, RecursiveOptionsObject } from 'lib/types/options';
|
||||
|
||||
export const isOpt = <T>(value: unknown): value is Opt<T> =>
|
||||
typeof value === 'object' && value !== null && 'value' in value && value instanceof Opt;
|
||||
|
||||
export const isRecursiveOptionsObject = (value: unknown): value is RecursiveOptionsObject => {
|
||||
return typeof value === 'object' && value !== null && !Array.isArray(value);
|
||||
export const isOptString = (value: unknown): value is Opt<string> => {
|
||||
return value instanceof Opt && typeof value.value === 'string';
|
||||
};
|
||||
|
||||
export const isHexColor = (value: string): value is HexColor => {
|
||||
return /^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/.test(value);
|
||||
export const isOptNumber = (value: unknown): value is Opt<number> => {
|
||||
return value instanceof Opt && typeof value.value === 'number';
|
||||
};
|
||||
|
||||
export const isOptBoolean = (value: unknown): value is Opt<boolean> => {
|
||||
return value instanceof Opt && typeof value.value === 'boolean';
|
||||
};
|
||||
|
||||
export const isOptMatugenTheme = (value: unknown): value is Opt<MatugenTheme> => {
|
||||
return value instanceof Opt && typeof value.value === 'object' && 'specificProperty' in value.value; // Replace 'specificProperty' with an actual property of MatugenTheme
|
||||
};
|
||||
|
||||
export const isRecursiveOptionsObject = (value: unknown): value is RecursiveOptionsObject => {
|
||||
return typeof value === 'object' && value !== null && !(value instanceof Opt);
|
||||
};
|
||||
|
||||
export const isHexColor = (val: unknown): val is HexColor => {
|
||||
return typeof val === 'string' && /^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/.test(val);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user