refactor: seperate common types

This commit is contained in:
MAZE 2023-10-20 17:14:28 +03:30
parent f1688cb53c
commit bad2d31b2d
6 changed files with 30 additions and 38 deletions

View File

@ -11,12 +11,7 @@ import { Categories } from '@/components/categories';
import { sounds } from '@/data/sounds'; import { sounds } from '@/data/sounds';
interface Sound { import type { Sound } from '@/data/types';
src: string;
label: string;
id: string;
icon: React.ReactNode;
}
export function App() { export function App() {
const categories = useMemo(() => sounds.categories, []); const categories = useMemo(() => sounds.categories, []);

View File

@ -2,18 +2,10 @@ import { AnimatePresence } from 'framer-motion';
import { Category } from '@/components/category'; import { Category } from '@/components/category';
import type { Categories } from '@/data/types';
interface CategoriesProps { interface CategoriesProps {
categories: Array<{ categories: Categories;
id: string;
title: string;
icon: React.ReactNode;
sounds: Array<{
label: string;
src: string;
icon: React.ReactNode;
id: string;
}>;
}>;
} }
export function Categories({ categories }: CategoriesProps) { export function Categories({ categories }: CategoriesProps) {

View File

@ -5,17 +5,10 @@ import { fade } from '@/lib/motion';
import styles from './category.module.css'; import styles from './category.module.css';
interface CategoryProps { import type { Category } from '@/data/types';
icon: React.ReactNode;
title: string; interface CategoryProps extends Category {
id: string;
functional?: boolean; functional?: boolean;
sounds: Array<{
label: string;
src: string;
icon: React.ReactNode;
id: string;
}>;
} }
export function Category({ export function Category({

View File

@ -9,12 +9,10 @@ import { cn } from '@/helpers/styles';
import styles from './sound.module.css'; import styles from './sound.module.css';
interface SoundProps { import type { Sound } from '@/data/types';
label: string;
src: string; interface SoundProps extends Sound {
icon: React.ReactNode;
hidden: boolean; hidden: boolean;
id: string;
functional: boolean; functional: boolean;
selectHidden: (key: string) => void; selectHidden: (key: string) => void;
unselectHidden: (key: string) => void; unselectHidden: (key: string) => void;

View File

@ -8,15 +8,12 @@ import { fade, scale, mix } from '@/lib/motion';
import styles from './sounds.module.css'; import styles from './sounds.module.css';
import type { Sounds } from '@/data/types';
interface SoundsProps { interface SoundsProps {
id: string; id: string;
functional: boolean; functional: boolean;
sounds: Array<{ sounds: Sounds;
label: string;
src: string;
icon: React.ReactNode;
id: string;
}>;
} }
export function Sounds({ functional, id, sounds }: SoundsProps) { export function Sounds({ functional, id, sounds }: SoundsProps) {

17
src/data/types.d.ts vendored Normal file
View File

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