From 4433c4ce1b58651d4d56dbe9e71178300f2c4b8c Mon Sep 17 00:00:00 2001 From: hamid zarghami Date: Mon, 4 Aug 2025 12:18:23 +0330 Subject: [PATCH] font size and font weight + social align --- src/langs/fa.json | 2 + .../personality/components/SocialRenderer.tsx | 5 +- .../personality/components/TextRenderer.tsx | 1 + .../personality/components/TextSidebar.tsx | 51 ++++++++++++++++++- src/pages/setting/personality/types/Types.ts | 1 + .../setting/personality/utils/ExportHTML.ts | 36 +++++++------ 6 files changed, 74 insertions(+), 22 deletions(-) diff --git a/src/langs/fa.json b/src/langs/fa.json index e495f1a..c46947a 100644 --- a/src/langs/fa.json +++ b/src/langs/fa.json @@ -96,6 +96,8 @@ "select": "انتخاب", "border": "حاشیه", "text_color": "رنگ متن", + "font_size": "اندازه فونت", + "font_weight": "ضخامت فونت", "background_color": "رنگ زمینه", "border_color": "رنگ حاشیه", "add_button": "اضافه کردن دکمه", diff --git a/src/pages/setting/personality/components/SocialRenderer.tsx b/src/pages/setting/personality/components/SocialRenderer.tsx index f945da6..b20adfd 100644 --- a/src/pages/setting/personality/components/SocialRenderer.tsx +++ b/src/pages/setting/personality/components/SocialRenderer.tsx @@ -132,7 +132,7 @@ const SocialRenderer: FC = ({ socials, itemId, sectionKey } valign={getVerticalAlign(socials[0]?.verticalAlignment)} style={{ padding: '4px 0' }} > -
+
{socials.map((social) => (
= ({ socials, itemId, sectionKey } outlineOffset: '2px', borderRadius: '4px', padding: '2px', - display: 'inline-block' + display: 'inline-block', + margin: '2px' }} >
diff --git a/src/pages/setting/personality/components/TextRenderer.tsx b/src/pages/setting/personality/components/TextRenderer.tsx index df47c9e..f977e16 100644 --- a/src/pages/setting/personality/components/TextRenderer.tsx +++ b/src/pages/setting/personality/components/TextRenderer.tsx @@ -51,6 +51,7 @@ const TextRenderer: FC = ({ texts, itemId, sectionKey }) => { style={{ color: textItem.color || '#000000', fontSize: `${textItem.fontSize || 14}px`, + fontWeight: textItem.fontWeight || 400, lineHeight: '1.4', paddingBottom: textIndex < (texts?.length || 0) - 1 ? '4px' : '0', pointerEvents: 'none' // Prevent double click handling diff --git a/src/pages/setting/personality/components/TextSidebar.tsx b/src/pages/setting/personality/components/TextSidebar.tsx index 7f1f78e..9e23c64 100644 --- a/src/pages/setting/personality/components/TextSidebar.tsx +++ b/src/pages/setting/personality/components/TextSidebar.tsx @@ -6,12 +6,16 @@ import { usePersonalityStore } from '../store/Store'; import ColorPicker from '@/components/ColorPicker'; import { HorizontalAlignment, VerticalAlignment, ElementType } from '../types/Types'; import Textarea from '@/components/Textarea'; +import Input from '@/components/Input'; +import Select from '@/components/Select'; const TextSidebar: FC = () => { const { t } = useTranslation() const [value, setValue] = useState(''); const [color, setColor] = useState('#000'); + const [fontSize, setFontSize] = useState(14); + const [fontWeight, setFontWeight] = useState('400'); const [horizontalPosition, setHorizontalPosition] = useState(HorizontalAlignment.CENTER); const [verticalPosition, setVerticalPosition] = useState(VerticalAlignment.MIDDLE); @@ -49,6 +53,8 @@ const TextSidebar: FC = () => { if (text) { setValue(text.text); setColor(text.color || '#000'); + setFontSize(text.fontSize || 14); + setFontWeight((text.fontWeight || 400).toString()); setHorizontalPosition(text.alignment || HorizontalAlignment.CENTER); setVerticalPosition(text.verticalAlignment || VerticalAlignment.MIDDLE); } else { @@ -61,6 +67,8 @@ const TextSidebar: FC = () => { // Reset form when not in edit mode setValue(''); setColor('#000'); + setFontSize(14); + setFontWeight('400'); setHorizontalPosition(HorizontalAlignment.CENTER); setVerticalPosition(VerticalAlignment.MIDDLE); } @@ -71,13 +79,16 @@ const TextSidebar: FC = () => { addTextToActiveItem({ text: value, color: color, + fontSize: fontSize, + fontWeight: parseInt(fontWeight), verticalAlignment: verticalPosition, alignment: horizontalPosition, }); - // خالی کردن فیلدها بعد از ذخیره setValue(''); setColor('#000'); + setFontSize(14); + setFontWeight('400'); setHorizontalPosition(HorizontalAlignment.CENTER); setVerticalPosition(VerticalAlignment.MIDDLE); } @@ -92,6 +103,8 @@ const TextSidebar: FC = () => { { text: value, color: color, + fontSize: fontSize, + fontWeight: parseInt(fontWeight), alignment: horizontalPosition, verticalAlignment: verticalPosition, } @@ -165,6 +178,42 @@ const TextSidebar: FC = () => { />
+
+
+ + setFontSize(+e.target.value || 0)} + onBlur={(e) => { + if (fontSize === 0 || e.target.value === '') { + setFontSize(14); + } + }} + className='text-sm' + placeholder="14" + /> +
+
+