refactor: sort interface keys

This commit is contained in:
MAZE 2023-10-20 17:24:18 +03:30
parent bad2d31b2d
commit c5240ff507
10 changed files with 746 additions and 223 deletions

View file

@ -21,6 +21,7 @@
"extends": [ "extends": [
"eslint:recommended", "eslint:recommended",
"plugin:@typescript-eslint/recommended", "plugin:@typescript-eslint/recommended",
"plugin:typescript-sort-keys/recommended",
"plugin:import/recommended", "plugin:import/recommended",
"plugin:react/recommended", "plugin:react/recommended",
"plugin:react/jsx-runtime", "plugin:react/jsx-runtime",
@ -32,6 +33,7 @@
"plugins": [ "plugins": [
"@typescript-eslint", "@typescript-eslint",
"typescript-sort-keys",
"sort-keys-fix", "sort-keys-fix",
"sort-destructure-keys", "sort-destructure-keys",
"prettier" "prettier"

906
package-lock.json generated

File diff suppressed because it is too large Load diff

View file

@ -54,6 +54,7 @@
"eslint-plugin-react-hooks": "4.6.0", "eslint-plugin-react-hooks": "4.6.0",
"eslint-plugin-sort-destructure-keys": "1.5.0", "eslint-plugin-sort-destructure-keys": "1.5.0",
"eslint-plugin-sort-keys-fix": "1.1.2", "eslint-plugin-sort-keys-fix": "1.1.2",
"eslint-plugin-typescript-sort-keys": "3.1.0",
"husky": "8.0.3", "husky": "8.0.3",
"lint-staged": "14.0.1", "lint-staged": "14.0.1",
"postcss-html": "1.5.0", "postcss-html": "1.5.0",

View file

@ -12,8 +12,8 @@ import styles from './sound.module.css';
import type { Sound } from '@/data/types'; import type { Sound } from '@/data/types';
interface SoundProps extends Sound { interface SoundProps extends Sound {
hidden: boolean;
functional: boolean; functional: boolean;
hidden: boolean;
selectHidden: (key: string) => void; selectHidden: (key: string) => void;
unselectHidden: (key: string) => void; unselectHidden: (key: string) => void;
} }

View file

@ -11,8 +11,8 @@ import styles from './sounds.module.css';
import type { Sounds } from '@/data/types'; import type { Sounds } from '@/data/types';
interface SoundsProps { interface SoundsProps {
id: string;
functional: boolean; functional: boolean;
id: string;
sounds: Sounds; sounds: Sounds;
} }

View file

@ -8,18 +8,10 @@ import { BsFire, BsAirplaneFill } from 'react-icons/bs/index';
// const defaultIcon = <BsSoundwave />; // const defaultIcon = <BsSoundwave />;
import type { Categories } from './types';
export const sounds: { export const sounds: {
categories: Array<{ categories: Categories;
id: string;
title: string;
icon: React.ReactNode;
sounds: Array<{
label: string;
src: string;
icon: React.ReactNode;
id: string;
}>;
}>;
} = { } = {
categories: [ categories: [
{ {

8
src/data/types.d.ts vendored
View file

@ -1,17 +1,17 @@
export interface Sound { export interface Sound {
label: string;
src: string;
icon: React.ReactNode; icon: React.ReactNode;
id: string; id: string;
label: string;
src: string;
} }
export type Sounds = Array<Sound>; export type Sounds = Array<Sound>;
export interface Category { export interface Category {
id: string;
title: string;
icon: React.ReactNode; icon: React.ReactNode;
id: string;
sounds: Sounds; sounds: Sounds;
title: string;
} }
export type Categories = Array<Category>; export type Categories = Array<Category>;

View file

@ -4,7 +4,7 @@ import { useSSR } from './use-ssr';
export function useSound( export function useSound(
src: string, src: string,
options: { volume?: number; loop?: boolean } = {}, options: { loop?: boolean; volume?: number } = {},
): HTMLAudioElement | null { ): HTMLAudioElement | null {
const { isBrowser } = useSSR(); const { isBrowser } = useSSR();
const sound = useMemo<HTMLAudioElement | null>(() => { const sound = useMemo<HTMLAudioElement | null>(() => {

View file

@ -3,15 +3,15 @@ import type { StateCreator } from 'zustand';
import type { SoundState } from './sound.state'; import type { SoundState } from './sound.state';
export interface SoundActions { export interface SoundActions {
select: (id: string) => void;
unselect: (id: string) => void;
setVolume: (id: string, volume: number) => void;
unselectAll: (pushToHistory?: boolean) => void;
restoreHistory: () => void;
toggleFavorite: (id: string) => void;
pause: () => void; pause: () => void;
play: () => void; play: () => void;
restoreHistory: () => void;
select: (id: string) => void;
setVolume: (id: string, volume: number) => void;
toggleFavorite: (id: string) => void;
togglePlay: () => void; togglePlay: () => void;
unselect: (id: string) => void;
unselectAll: (pushToHistory?: boolean) => void;
} }
export const createActions: StateCreator< export const createActions: StateCreator<

View file

@ -5,23 +5,23 @@ import type { SoundActions } from './sound.actions';
import { sounds } from '@/data/sounds'; import { sounds } from '@/data/sounds';
export interface SoundState { export interface SoundState {
isPlaying: boolean; getFavorites: () => Array<string>;
sounds: {
[id: string]: {
isSelected: boolean;
isFavorite: boolean;
volume: number;
};
};
history: { history: {
[id: string]: { [id: string]: {
isSelected: boolean;
isFavorite: boolean; isFavorite: boolean;
isSelected: boolean;
volume: number; volume: number;
}; };
} | null; } | null;
isPlaying: boolean;
noSelected: () => boolean; noSelected: () => boolean;
getFavorites: () => Array<string>; sounds: {
[id: string]: {
isFavorite: boolean;
isSelected: boolean;
volume: number;
};
};
} }
export const createState: StateCreator< export const createState: StateCreator<