Tina Tarighian
commited on
Commit
·
1f41141
1
Parent(s):
b4dece4
font change
Browse files- components/ThoughtBubble.js +24 -3
components/ThoughtBubble.js
CHANGED
@@ -16,6 +16,26 @@ const ThoughtBubble = ({
|
|
16 |
}) => {
|
17 |
const thoughtBubbleRef = useRef(null);
|
18 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
19 |
// Add particle effects when thought appears
|
20 |
useEffect(() => {
|
21 |
if (thought && isMouthOpen && thoughtBubbleRef.current) {
|
@@ -57,14 +77,15 @@ const ThoughtBubble = ({
|
|
57 |
}
|
58 |
|
59 |
if (thought && isMouthOpen) {
|
60 |
-
// Much larger text size with word-break control
|
61 |
return (
|
62 |
<p
|
63 |
style={{
|
64 |
-
fontSize:
|
65 |
hyphens: 'none',
|
66 |
wordBreak: 'normal',
|
67 |
-
overflowWrap: 'break-word'
|
|
|
|
|
68 |
}}
|
69 |
className="font-medium text-gray-800"
|
70 |
>
|
|
|
16 |
}) => {
|
17 |
const thoughtBubbleRef = useRef(null);
|
18 |
|
19 |
+
// Calculate dynamic font size based on text length
|
20 |
+
const calculateFontSize = (text) => {
|
21 |
+
if (!text) return isMobile ? '18px' : '22px';
|
22 |
+
|
23 |
+
const length = text.length;
|
24 |
+
let fontSize;
|
25 |
+
|
26 |
+
if (length <= 20) {
|
27 |
+
fontSize = isMobile ? 18 : 22;
|
28 |
+
} else if (length <= 50) {
|
29 |
+
fontSize = isMobile ? 16 : 20;
|
30 |
+
} else if (length <= 100) {
|
31 |
+
fontSize = isMobile ? 14 : 18;
|
32 |
+
} else {
|
33 |
+
fontSize = isMobile ? 12 : 16;
|
34 |
+
}
|
35 |
+
|
36 |
+
return `${fontSize}px`;
|
37 |
+
};
|
38 |
+
|
39 |
// Add particle effects when thought appears
|
40 |
useEffect(() => {
|
41 |
if (thought && isMouthOpen && thoughtBubbleRef.current) {
|
|
|
77 |
}
|
78 |
|
79 |
if (thought && isMouthOpen) {
|
|
|
80 |
return (
|
81 |
<p
|
82 |
style={{
|
83 |
+
fontSize: calculateFontSize(thought),
|
84 |
hyphens: 'none',
|
85 |
wordBreak: 'normal',
|
86 |
+
overflowWrap: 'break-word',
|
87 |
+
lineHeight: '1.4',
|
88 |
+
margin: 0
|
89 |
}}
|
90 |
className="font-medium text-gray-800"
|
91 |
>
|