Move to Zustand and add Filters to web_test (#1077)

* Moved to zustand and started refactored filters

- Move from redux to zustand
- Refactor Filters typings and add some helper types
- Add Filters button and Picker/Switch filter options
- Fixed Syosetu typings

* Add rule consistent-type-definitions

- Add consistent-type-definitions eslint rule to force consistent use of types instead of interfaces
- Run eslint to auto-change every interface to types

https://dev.to/atheodosiou/types-vs-interfaces-in-typescript-making-the-right-choice-48a4
https://www.youtube.com/watch?v=zM9UPcIyyhQ

* Add other filters and refactor

- Move Dialog to FiltersDialog
- CheckboxFilter, TextFilter, XCheckboxFilter added
- Added TripleCheckbox and TripleSwitch as tri-state checkbox/switch items using Mui stylings

* TriStateCheckbox/Switch refactor

- Change name of TripleSwitch and TripleCheckbox to TriState
- Change slightly TriStateSwitch and StyledSwitch styles
- Add option to change into TriStateSwitches via `localStorage` value `useSwitches`

* Refactor code and fix issues

* fix: prettier

---------

Co-authored-by: nyagami <hoangquan05112002@gmail.com>
This commit is contained in:
Marcin Majewski
2024-08-18 17:31:41 +02:00
committed by GitHub
parent eb5522b066
commit b2caf26da3
73 changed files with 1914 additions and 916 deletions
+26 -27
View File
@@ -1,6 +1,6 @@
import { FilterToValues, Filters } from '@libs/filterInputs';
export namespace Plugin {
export interface ChapterItem {
export type ChapterItem = {
name: string;
path: string;
/**
@@ -17,13 +17,13 @@ export namespace Plugin {
* For novel without pages only
*/
page?: string;
}
export interface NovelItem {
};
export type NovelItem = {
name: string;
path: string;
cover?: string;
}
export interface SourceNovel extends NovelItem {
};
export type SourceNovel = {
/** Comma separated genre list -> "action,fantasy,romance" */
genres?: string;
summary?: string;
@@ -31,32 +31,32 @@ export namespace Plugin {
artist?: string;
status?: string;
chapters?: ChapterItem[];
}
} & NovelItem;
export interface SourcePage {
export type SourcePage = {
chapters: ChapterItem[];
}
};
export interface PopularNovelsOptions<
export type PopularNovelsOptions<
Q extends Filters | undefined = Filters | undefined,
> {
> = {
showLatestNovels?: boolean;
filters?: Q extends undefined ? undefined : FilterToValues<Q>;
}
export interface PluginItem {
filters: Q extends undefined ? undefined : FilterToValues<Q>;
};
export type PluginItem = {
id: string;
name: string;
version: string;
icon: string;
site: string;
}
export interface ImageRequestInit {
};
export type ImageRequestInit = {
method?: string;
headers?: Record<string, string>;
body?: string;
}
};
export interface PluginBase {
export type PluginBase = {
id: string;
name: string;
/**
@@ -87,32 +87,31 @@ export namespace Plugin {
parseChapter(chapterPath: string): Promise<string>;
searchNovels(searchTerm: string, pageNo: number): Promise<NovelItem[]>;
resolveUrl?(path: string, isNovel?: boolean): string;
}
};
export interface PagePlugin extends PluginBase {
export type PagePlugin = {
parseNovel(
novelPath: string,
): Promise<SourceNovel & { totalPages: number }>;
parsePage(novelPath: string, page: string): Promise<SourcePage>;
}
} & PluginBase;
}
export namespace HTMLParser2Util {
interface HandlerBase {
type HandlerBase = {
onopentag?(name: string, attribs: Record<string, string>): void;
ontext?(data: string): void;
onclosetag?(name: string, isImplied: boolean): void;
}
};
export interface Handler extends HandlerBase {
export type Handler = {
isStarted?: boolean;
isDone?: boolean;
}
} & HandlerBase;
// route htmlparser2 event to handlers
export interface HandlerRouter<ActionType extends string>
extends HandlerBase {
export type HandlerRouter<ActionType extends string> = {
handlers: Record<ActionType, Handler | undefined>;
action: ActionType;
}
} & HandlerBase;
}