tangled
alpha
login
or
join now
timtinkers.online
/
lemoncalendar
0
fork
atom
this repo has no description
0
fork
atom
overview
issues
pulls
pipelines
Added helper function for summary font size (WIP)
timtinkers.online
1 year ago
97326149
a9bb20ba
+31
-3
1 changed file
expand all
collapse all
unified
split
components
WeeklySchedule.tsx
+31
-3
components/WeeklySchedule.tsx
···
115
115
return null;
116
116
};
117
117
118
118
+
const getSummaryFontSize = (summary: string | undefined): string => {
119
119
+
const baseFontSize = 1.1; // em
120
120
+
const idealLength = 10;
121
121
+
const minFontSize = 0.55; // em
122
122
+
const reductionStartLength = idealLength;
123
123
+
const reductionEndLength = 50; // Length at which minFontSize is reached
124
124
+
const fontSizeRange = baseFontSize - minFontSize;
125
125
+
const lengthRange = reductionEndLength - reductionStartLength;
126
126
+
127
127
+
if (!summary) return `${baseFontSize}em`;
128
128
+
129
129
+
const summaryLength = summary.length;
130
130
+
131
131
+
if (summaryLength <= idealLength) {
132
132
+
return `${baseFontSize}em`;
133
133
+
} else if (summaryLength >= reductionEndLength) {
134
134
+
return `${minFontSize}em`;
135
135
+
} else {
136
136
+
const lengthOverIdeal = summaryLength - reductionStartLength;
137
137
+
const fontSizeReduction = (lengthOverIdeal / lengthRange) *
138
138
+
fontSizeRange;
139
139
+
const calculatedFontSize = baseFontSize - fontSizeReduction;
140
140
+
return `${calculatedFontSize.toFixed(2)}em`; // Format to 2 decimal places for cleaner output
141
141
+
}
142
142
+
};
143
143
+
118
144
return (
119
145
<div
120
146
style={{
···
206
232
const hasEvent = !!event;
207
233
const eventBgColor = getEventBgColor(event);
208
234
const eventIcon = getEventIcon(event);
235
235
+
const summaryFontSize = getSummaryFontSize(event?.summary);
209
236
210
237
return (
211
238
<div
···
221
248
padding: "10px",
222
249
borderRadius: "15px",
223
250
marginBottom: "8px",
224
224
-
fontSize: "1.3em",
251
251
+
fontSize: "1.2em",
225
252
fontFamily: theme.fontFamily,
226
253
position: "relative",
227
254
}}
···
245
272
className="weekday"
246
273
style={{
247
274
fontWeight: "bold",
248
248
-
marginRight: "12px",
275
275
+
marginRight: "10px",
249
276
justifyContent: "flex-start",
250
277
flex: "1",
251
278
color: theme.dayColor,
···
261
288
justifyContent: "center",
262
289
textAlign: "center",
263
290
flex: 2,
264
264
-
marginRight: "12px",
291
291
+
marginRight: "10px",
265
292
wordWrap: "break-word",
266
293
color: theme.eventTextColor,
294
294
+
fontSize: summaryFontSize,
267
295
}}
268
296
>
269
297
{hasEvent ? event.summary : "-"}