Skip to content

Commit

Permalink
refactor: sort interface keys
Browse files Browse the repository at this point in the history
  • Loading branch information
remvze committed Oct 20, 2023
1 parent bad2d31 commit c5240ff
Show file tree
Hide file tree
Showing 10 changed files with 742 additions and 219 deletions.
2 changes: 2 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
"extends": [
"eslint:recommended",
"plugin:@typescript-eslint/recommended",
"plugin:typescript-sort-keys/recommended",
"plugin:import/recommended",
"plugin:react/recommended",
"plugin:react/jsx-runtime",
Expand All @@ -32,6 +33,7 @@

"plugins": [
"@typescript-eslint",
"typescript-sort-keys",
"sort-keys-fix",
"sort-destructure-keys",
"prettier"
Expand Down
902 changes: 715 additions & 187 deletions package-lock.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
"eslint-plugin-react-hooks": "4.6.0",
"eslint-plugin-sort-destructure-keys": "1.5.0",
"eslint-plugin-sort-keys-fix": "1.1.2",
"eslint-plugin-typescript-sort-keys": "3.1.0",
"husky": "8.0.3",
"lint-staged": "14.0.1",
"postcss-html": "1.5.0",
Expand Down
2 changes: 1 addition & 1 deletion src/components/sound/sound.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ import styles from './sound.module.css';
import type { Sound } from '@/data/types';

interface SoundProps extends Sound {
hidden: boolean;
functional: boolean;
hidden: boolean;
selectHidden: (key: string) => void;
unselectHidden: (key: string) => void;
}
Expand Down
2 changes: 1 addition & 1 deletion src/components/sounds/sounds.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ import styles from './sounds.module.css';
import type { Sounds } from '@/data/types';

interface SoundsProps {
id: string;
functional: boolean;
id: string;
sounds: Sounds;
}

Expand Down
14 changes: 3 additions & 11 deletions src/data/sounds.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,10 @@ import { BsFire, BsAirplaneFill } from 'react-icons/bs/index';

// const defaultIcon = <BsSoundwave />;

import type { Categories } from './types';

export const sounds: {
categories: Array<{
id: string;
title: string;
icon: React.ReactNode;
sounds: Array<{
label: string;
src: string;
icon: React.ReactNode;
id: string;
}>;
}>;
categories: Categories;
} = {
categories: [
{
Expand Down
8 changes: 4 additions & 4 deletions src/data/types.d.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
export interface Sound {
label: string;
src: string;
icon: React.ReactNode;
id: string;
label: string;
src: string;
}

export type Sounds = Array<Sound>;

export interface Category {
id: string;
title: string;
icon: React.ReactNode;
id: string;
sounds: Sounds;
title: string;
}

export type Categories = Array<Category>;
2 changes: 1 addition & 1 deletion src/hooks/use-sound.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { useSSR } from './use-ssr';

export function useSound(
src: string,
options: { volume?: number; loop?: boolean } = {},
options: { loop?: boolean; volume?: number } = {},
): HTMLAudioElement | null {
const { isBrowser } = useSSR();
const sound = useMemo<HTMLAudioElement | null>(() => {
Expand Down
10 changes: 5 additions & 5 deletions src/store/sound/sound.actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@ import type { StateCreator } from 'zustand';
import type { SoundState } from './sound.state';

export interface SoundActions {
pause: () => void;
play: () => void;
restoreHistory: () => void;
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;
play: () => void;
togglePlay: () => void;
unselect: (id: string) => void;
unselectAll: (pushToHistory?: boolean) => void;
}

export const createActions: StateCreator<
Expand Down
18 changes: 9 additions & 9 deletions src/store/sound/sound.state.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,23 @@ import type { SoundActions } from './sound.actions';
import { sounds } from '@/data/sounds';

export interface SoundState {
isPlaying: boolean;
sounds: {
getFavorites: () => Array<string>;
history: {
[id: string]: {
isSelected: boolean;
isFavorite: boolean;
isSelected: boolean;
volume: number;
};
};
history: {
} | null;
isPlaying: boolean;
noSelected: () => boolean;
sounds: {
[id: string]: {
isSelected: boolean;
isFavorite: boolean;
isSelected: boolean;
volume: number;
};
} | null;
noSelected: () => boolean;
getFavorites: () => Array<string>;
};
}

export const createState: StateCreator<
Expand Down

0 comments on commit c5240ff

Please sign in to comment.