import { Autocomplete, Skeleton, Slider, TextField } from '@mui/material'; import { Font, TypeCategory, TypeProperty, Typography as TypographyType } from '@reactive-resume/schema'; import get from 'lodash/get'; import isEmpty from 'lodash/isEmpty'; import { useTranslation } from 'next-i18next'; import { useQuery } from 'react-query'; import Heading from '@/components/shared/Heading'; import { FONTS_QUERY } from '@/constants/index'; import { fetchFonts } from '@/services/fonts'; import { useAppDispatch, useAppSelector } from '@/store/hooks'; import { setResumeState } from '@/store/resume/resumeSlice'; import styles from './Typography.module.scss'; const TypographySkeleton: React.FC = () => ( <>
); type WidgetProps = { label: string; category: TypeCategory; }; const Widgets: React.FC = ({ label, category }) => { const { t } = useTranslation(); const dispatch = useAppDispatch(); const { family, size } = useAppSelector((state) => get(state.resume, 'metadata.typography')); const { data: fonts } = useQuery(FONTS_QUERY, fetchFonts, { select: (fonts) => fonts.sort((a, b) => a.category.localeCompare(b.category)), }); const handleChange = (property: TypeProperty, value: number | number[] | Font | null) => { if (!value) return; dispatch( setResumeState({ path: `metadata.typography.${property}.${category}`, value: property === 'family' ? (value as Font).family : value, }) ); }; if (!fonts || isEmpty(fonts)) return ; return ( <>
{label}
handleChange('size', size)} />
options={fonts} disableClearable={true} groupBy={(font) => font.category} getOptionLabel={(font) => font.family} isOptionEqualToValue={(a, b) => a.family === b.family} value={fonts.find((font) => font.family === family[category])} onChange={(_, font: Font | null) => handleChange('family', font)} renderInput={(params) => ( )} />
); }; const Typography = () => { const { t } = useTranslation(); return ( <> ); }; export default Typography;