Skip to content

Build your personal knowledge base with Trilium Notes

refactor(client): give numeric style values an explicit `px` unit

Elian Doran710152ad18c5
diff --git a/apps/client/src/widgets/FloatingButtons.tsx b/apps/client/src/widgets/FloatingButtons.tsx
index f38039afd6..55620d4b97 100644
--- a/apps/client/src/widgets/FloatingButtons.tsx
+++ b/apps/client/src/widgets/FloatingButtons.tsx
@@ -55,7 +55,7 @@ export default function FloatingButtons({ items }: FloatingButtonsProps) {
});
return (
- <div className="floating-buttons no-print" style={{top}}>
+ <div className="floating-buttons no-print" style={{ top: `${top}px` }}>
<div className={`floating-buttons-children ${!visible ? "temporarily-hidden" : ""}`}>
{context && items.map((Component) => (
<Component {...context} />
diff --git a/apps/client/src/widgets/dialogs/delete_notes.tsx b/apps/client/src/widgets/dialogs/delete_notes.tsx
index 9c7fde511f..b751811999 100644
--- a/apps/client/src/widgets/dialogs/delete_notes.tsx
+++ b/apps/client/src/widgets/dialogs/delete_notes.tsx
@@ -213,7 +213,7 @@ function DeletedNotes({ noteIdsToBeDeleted }: { noteIdsToBeDeleted: DeleteNotesP
rowCount={noteIdsToBeDeleted.length}
rowHeight={ROW_HEIGHT}
rowProps={{ noteIds: noteIdsToBeDeleted }}
- style={{ maxHeight: MAX_LIST_HEIGHT }}
+ style={{ maxHeight: `${MAX_LIST_HEIGHT}px` }}
/>
) : (
<ul className="preview-list">
diff --git a/apps/client/src/widgets/dialogs/markdown_import.tsx b/apps/client/src/widgets/dialogs/markdown_import.tsx
index a3f53666bb..4b7fbcff27 100644
--- a/apps/client/src/widgets/dialogs/markdown_import.tsx
+++ b/apps/client/src/widgets/dialogs/markdown_import.tsx
@@ -58,7 +58,7 @@ export default function MarkdownImportDialog() {
<p>{t("markdown_import.modal_body_text")}</p>
<textarea ref={markdownImportTextArea} value={text}
onInput={(e) => setText(e.currentTarget.value)}
- style={{ height: 340, width: "100%" }}
+ style={{ height: "340px", width: "100%" }}
onKeyDown={(e) => {
if (e.key === "Enter" && e.ctrlKey) {
e.preventDefault();
diff --git a/apps/client/src/widgets/launch_bar/CalendarWidget.tsx b/apps/client/src/widgets/launch_bar/CalendarWidget.tsx
index 00b89d7e0b..014dc3deea 100644
--- a/apps/client/src/widgets/launch_bar/CalendarWidget.tsx
+++ b/apps/client/src/widgets/launch_bar/CalendarWidget.tsx
@@ -79,7 +79,7 @@ export default function CalendarWidget({ launcherNote }: LauncherNoteProps) {
dropdownRef={dropdownRef}
autoClose="outside"
>
- {calendarArgs && date && <div className="calendar-dropdown-widget" style={{ width: 400 }}>
+ {calendarArgs && date && <div className="calendar-dropdown-widget" style={{ width: "400px" }}>
<CalendarHeader date={date} setDate={setDate} />
<Calendar
date={date}
diff --git a/apps/client/src/widgets/launch_bar/SpacerWidget.tsx b/apps/client/src/widgets/launch_bar/SpacerWidget.tsx
index a01ed4cb83..24b7868fd6 100644
--- a/apps/client/src/widgets/launch_bar/SpacerWidget.tsx
+++ b/apps/client/src/widgets/launch_bar/SpacerWidget.tsx
@@ -12,7 +12,7 @@ export default function SpacerWidget({ launcherNote, baseSize, growthFactor }: S
<div
className="spacer"
style={{
- flexBasis: baseSize ?? 0,
+ flexBasis: `${baseSize ?? 0}px`,
flexGrow: growthFactor ?? 1000,
flexShrink: 1000
}}
diff --git a/apps/client/src/widgets/mobile_widgets/toggle_sidebar_button.tsx b/apps/client/src/widgets/mobile_widgets/toggle_sidebar_button.tsx
index 395c049e86..4033715cd0 100644
--- a/apps/client/src/widgets/mobile_widgets/toggle_sidebar_button.tsx
+++ b/apps/client/src/widgets/mobile_widgets/toggle_sidebar_button.tsx
@@ -6,7 +6,7 @@ export default function ToggleSidebarButton() {
const { noteContext, parentComponent } = useNoteContext();
return (
- <div style={{ contain: "none", minWidth: 8 }}>
+ <div style={{ contain: "none", minWidth: "8px" }}>
{ noteContext?.isMainContext() && <ActionButton
icon="bx bx-sidebar"
text={t("note_tree.toggle-sidebar")}
diff --git a/apps/client/src/widgets/react/Collapsible.tsx b/apps/client/src/widgets/react/Collapsible.tsx
index 38d2e4caf0..cfd8ccf9b4 100644
--- a/apps/client/src/widgets/react/Collapsible.tsx
+++ b/apps/client/src/widgets/react/Collapsible.tsx
@@ -73,7 +73,9 @@ export function ExternallyControlledCollapsible({ title, children, className, ex
id={contentId}
ref={bodyRef}
className={clsx("collapsible-body", {"fully-expanded": fullyExpanded})}
- style={{ height: expanded ? height : "0" }}
+ style={{
+ height: expanded ? (height === undefined ? undefined : `${height}px`) : "0"
+ }}
aria-hidden={!expanded}
>
<div
diff --git a/apps/client/src/widgets/react/IconPicker.tsx b/apps/client/src/widgets/react/IconPicker.tsx
index 175f780310..d4e2289339 100644
--- a/apps/client/src/widgets/react/IconPicker.tsx
+++ b/apps/client/src/widgets/react/IconPicker.tsx
@@ -91,10 +91,10 @@ export default function IconPicker({ onSelect, onReset, resetText, columnCount,
class="icon-list"
ref={iconListRef}
style={{
- width: (columnCount * iconSize + 10),
+ width: `${columnCount * iconSize + 10}px`,
// The CSS sets the height of the regular grid; the compact grid shows
// `COMPACT_ROWS` rows.
- ...(compact && { height: COMPACT_ROWS * iconSize })
+ ...(compact && { height: `${COMPACT_ROWS * iconSize}px` })
}}
onClick={(e) => {
// Make sure we are not clicking on something else than a button.
diff --git a/apps/client/src/widgets/react/NotePropertyMenu.tsx b/apps/client/src/widgets/react/NotePropertyMenu.tsx
index b72dfe53a2..6c99f9c9a1 100644
--- a/apps/client/src/widgets/react/NotePropertyMenu.tsx
+++ b/apps/client/src/widgets/react/NotePropertyMenu.tsx
@@ -237,7 +237,7 @@ function NumberPropertyView({ note, property }: { note: FNote, property: NumberP
<FormTextBox
type="number"
currentValue={value ?? ""} onChange={setValue}
- style={{ width: (property.width ?? 100) }}
+ style={{ width: `${property.width ?? 100}px` }}
min={property.min ?? 0}
disabled={disabled}
/>
diff --git a/apps/client/src/widgets/react/charts/DonutChart.tsx b/apps/client/src/widgets/react/charts/DonutChart.tsx
index dd3e39df81..e927a54f03 100644
--- a/apps/client/src/widgets/react/charts/DonutChart.tsx
+++ b/apps/client/src/widgets/react/charts/DonutChart.tsx
@@ -122,7 +122,7 @@ function Ring<T>({ ring, selectedSegmentId, onSegmentHover }: {
<g>
{/* First, so every segment paints over it. */}
{ring.track && (
- <circle className="donut-track" r={ring.radius} fill="none" style={{ strokeWidth: ring.thickness }} />
+ <circle className="donut-track" r={ring.radius} fill="none" style={{ strokeWidth: `${ring.thickness}px` }} />
)}
{ring.segments.map((segment, index) => {
const arc = layout[index];
@@ -150,9 +150,9 @@ function Ring<T>({ ring, selectedSegmentId, onSegmentHover }: {
// Arc geometry is data-driven; as inline *style* (not attributes) it stays
// animatable by the stylesheet's transition and sweep keyframes.
style={{
- strokeWidth: ring.thickness,
+ strokeWidth: `${ring.thickness}px`,
strokeDasharray: `${arc.length} ${Math.max(circumference - arc.length, 0)}`,
- strokeDashoffset: -arc.offset,
+ strokeDashoffset: `${-arc.offset}px`,
"--donut-circumference": `${circumference}px`,
...(segment.hue !== undefined && { "--donut-hue": String(segment.hue) })
}}
diff --git a/apps/client/src/widgets/react/charts/Treemap.tsx b/apps/client/src/widgets/react/charts/Treemap.tsx
index 9831b4953b..9e44ab6198 100644
--- a/apps/client/src/widgets/react/charts/Treemap.tsx
+++ b/apps/client/src/widgets/react/charts/Treemap.tsx
@@ -143,10 +143,10 @@ export default function Treemap<T>({ root, selectedItemId, onItemClick, onItemCo
)}
// Geometry and tint are computed per layout run, so they cannot live in a stylesheet.
style={{
- left: cell.x0,
- top: cell.y0,
- width: cellWidth,
- height: cellHeight,
+ left: `${cell.x0}px`,
+ top: `${cell.y0}px`,
+ width: `${cellWidth}px`,
+ height: `${cellHeight}px`,
borderRadius: blockCornerRadius(cell),
...(item.hue !== undefined && { "--treemap-hue": String(item.hue) })
}}
@@ -157,7 +157,7 @@ export default function Treemap<T>({ root, selectedItemId, onItemClick, onItemCo
{...item.attributes}
>
{item.icon && iconSize >= MIN_ICON_SIZE && (
- <span className={clsx("treemap-cell-icon", item.icon)} style={{ fontSize: iconSize }} />
+ <span className={clsx("treemap-cell-icon", item.icon)} style={{ fontSize: `${iconSize}px` }} />
)}
</div>
);
diff --git a/apps/client/src/widgets/react/charts/chart_tooltip.tsx b/apps/client/src/widgets/react/charts/chart_tooltip.tsx
index 5d70cb655d..92ca4104e3 100644
--- a/apps/client/src/widgets/react/charts/chart_tooltip.tsx
+++ b/apps/client/src/widgets/react/charts/chart_tooltip.tsx
@@ -69,7 +69,7 @@ export function useChartTooltip<T extends HTMLElement>() {
tooltip.flipX && "chart-tooltip-flip-x",
tooltip.flipY && "chart-tooltip-flip-y"
)}
- style={{ left: tooltip.x, top: tooltip.y }}
+ style={{ left: `${tooltip.x}px`, top: `${tooltip.y}px` }}
>
<div className="tooltip-inner">{tooltip.text}</div>
</div>
diff --git a/apps/client/src/widgets/scroll_padding.tsx b/apps/client/src/widgets/scroll_padding.tsx
index 4cf83020af..208a23f860 100644
--- a/apps/client/src/widgets/scroll_padding.tsx
+++ b/apps/client/src/widgets/scroll_padding.tsx
@@ -40,7 +40,7 @@ export default function ScrollPadding() {
<div
ref={ref}
className="scroll-padding-widget"
- style={{ height }}
+ style={{ height: `${height}px` }}
onClick={() => parentComponent.triggerCommand("scrollToEnd", { ntxId })}
/>
: <div />
diff --git a/apps/client/src/widgets/sidebar/pdf/PdfPages.tsx b/apps/client/src/widgets/sidebar/pdf/PdfPages.tsx
index f11604fc03..78c4463416 100644
--- a/apps/client/src/widgets/sidebar/pdf/PdfPages.tsx
+++ b/apps/client/src/widgets/sidebar/pdf/PdfPages.tsx
@@ -86,7 +86,7 @@ function PdfPagesList({ pagesData, ntxId }: { pagesData: NoteContextDataMap["pdf
requestThumbnail,
scrollToPage: pagesData.scrollToPage
}}
- style={{ height: containerHeight }}
+ style={{ height: `${containerHeight}px` }}
/>
)}
</div>
diff --git a/apps/client/src/widgets/type_widgets/relation_map/jsplumb.tsx b/apps/client/src/widgets/type_widgets/relation_map/jsplumb.tsx
index 31e59bbcfc..81d47fc7f4 100644
--- a/apps/client/src/widgets/type_widgets/relation_map/jsplumb.tsx
+++ b/apps/client/src/widgets/type_widgets/relation_map/jsplumb.tsx
@@ -86,7 +86,7 @@ export function JsPlumbItem({ x, y, children, draggable, sourceConfig, targetCon
<div
ref={containerRef}
{...restProps}
- style={{ left: x, top: y }}
+ style={{ left: `${x}px`, top: `${y}px` }}
>
{children}
</div>