import React, { useContext } from 'react'; import { SchemaForUI, getFallbackFontName, DEFAULT_FONT_SIZE, DEFAULT_LINE_HEIGHT, DEFAULT_CHARACTER_SPACING, DEFAULT_FONT_COLOR, } from '@pdfme/common'; import { FontContext } from '../../../../contexts'; import { SidebarProps } from '..'; import closeIcon from '../../../../assets/icons/close.svg'; const inputStyle = { width: '90%', color: '#333', background: 'none', borderRadius: 2, border: '1px solid #767676', }; const selectStyle = inputStyle; const NumberInputSet = (props: { width: string; label: string; value: number; onChange: (e: React.ChangeEvent) => void; }) => { const { label, value, width, onChange } = props; return (
); }; const ColorInputSet = (props: { label: string; value: string; onChange: (e: React.ChangeEvent) => void; onClear: () => void; }) => { const { label, value, onChange, onClear } = props; return (
); }; const SelectSet = (props: { label: string; value: string; options: string[]; onChange: (e: React.ChangeEvent) => void; }) => { const { label, value, options, onChange } = props; return (
); }; const TextPropEditor = ( props: Pick & { activeSchema: SchemaForUI } ) => { const { changeSchemas, activeSchema } = props; const alignments = ['left', 'center', 'right']; const font = useContext(FontContext); const fallbackFontName = getFallbackFontName(font); if (activeSchema.type !== 'text') return <>; return (
{ changeSchemas([{ key: 'fontName', value: e.target.value, schemaId: activeSchema.id }]); }} /> changeSchemas([{ key: 'alignment', value: e.target.value, schemaId: activeSchema.id }]) } />
changeSchemas([ { key: 'fontSize', value: Number(e.target.value), schemaId: activeSchema.id }, ]) } /> changeSchemas([ { key: 'lineHeight', value: Number(e.target.value), schemaId: activeSchema.id }, ]) } /> changeSchemas([ { key: 'characterSpacing', value: Number(e.target.value), schemaId: activeSchema.id }, ]) } />
changeSchemas([{ key: 'fontColor', value: e.target.value, schemaId: activeSchema.id }]) } onClear={() => changeSchemas([ { key: 'fontColor', value: DEFAULT_FONT_COLOR, schemaId: activeSchema.id }, ]) } /> changeSchemas([ { key: 'backgroundColor', value: e.target.value, schemaId: activeSchema.id }, ]) } onClear={() => changeSchemas([{ key: 'backgroundColor', value: '', schemaId: activeSchema.id }]) } />
); }; export default TextPropEditor;