mirror of
https://github.com/remvze/moodist.git
synced 2025-12-08 14:15:07 -05:00
refactor: seperate common types
This commit is contained in:
parent
f1688cb53c
commit
bad2d31b2d
@ -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, []);
|
||||||
|
|||||||
@ -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) {
|
||||||
|
|||||||
@ -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({
|
||||||
|
|||||||
@ -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;
|
||||||
|
|||||||
@ -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
17
src/data/types.d.ts
vendored
Normal 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>;
|
||||||
Loading…
x
Reference in New Issue
Block a user