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';
interface Sound {
src: string;
label: string;
id: string;
icon: React.ReactNode;
}
import type { Sound } from '@/data/types';
export function App() {
const categories = useMemo(() => sounds.categories, []);

View File

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

View File

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

View File

@ -9,12 +9,10 @@ import { cn } from '@/helpers/styles';
import styles from './sound.module.css';
interface SoundProps {
label: string;
src: string;
icon: React.ReactNode;
import type { Sound } from '@/data/types';
interface SoundProps extends Sound {
hidden: boolean;
id: string;
functional: boolean;
selectHidden: (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 type { Sounds } from '@/data/types';
interface SoundsProps {
id: string;
functional: boolean;
sounds: Array<{
label: string;
src: string;
icon: React.ReactNode;
id: string;
}>;
sounds: Sounds;
}
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>;