Skip to content

A modern and easy to use dashboard. 80+ integrations. 20K+ icons built in. Authentication out of the box. No YAML, drag and drop configuration.

fix(bookmarks): show vertical hostnames when rows fit (#7291)

Thomasb31a03375a7f
diff --git a/packages/widgets/src/bookmarks/bookmarks-widget.tsx b/packages/widgets/src/bookmarks/bookmarks-widget.tsx
index 1f0270762..7e5ff56ce 100644
--- a/packages/widgets/src/bookmarks/bookmarks-widget.tsx
+++ b/packages/widgets/src/bookmarks/bookmarks-widget.tsx
@@ -97,6 +97,28 @@ export default function BookmarksWidget({
titleHeight = 36 + (options.titleSize - 11) * 1.2;
}
const contentHeight = Math.max(0, responsiveHeight - titleHeight);
+ const isTight = responsiveHeight < 120;
+ let contentPadding = 12;
+ if (isTight) contentPadding = 6;
+ let layoutHeight = contentHeight;
+ let layoutItemCount = data.length;
+ if (!advanced && options.layout === "column") {
+ layoutHeight = Math.max(0, responsiveHeight - contentPadding * 2 - 2);
+ if (showTitle) layoutHeight = Math.max(0, layoutHeight - options.titleSize * 1.2 - contentPadding);
+ if (sections.length > 0) {
+ const expandedSections = sections.filter((section) => !collapsedGroups.includes(section.id));
+ layoutItemCount =
+ ungroupedItems.length + expandedSections.reduce((count, section) => count + section.items.length, 0);
+ layoutHeight -= sections.length * bookmarkGroupControlHeight + expandedSections.length * bookmarkGroupSpacing;
+ let visibleListCount = expandedSections.length;
+ if (ungroupedItems.length > 0) {
+ layoutHeight -= bookmarkUngroupedHeadingHeight + bookmarkGroupSpacing * 2;
+ visibleListCount += 1;
+ }
+ layoutHeight += Math.max(0, visibleListCount - 1) * Math.min(bookmarkSpacingPixels[options.spacing], 4);
+ layoutHeight = Math.max(0, layoutHeight);
+ }
+ }
let layoutWidth = responsiveWidth;
if (options.layout === "gridHorizontal") layoutWidth = width;
@@ -130,12 +152,13 @@ export default function BookmarksWidget({
getBookmarkDisplayPlan({
advanced,
gap: bookmarkSpacingPixels[options.spacing],
- height: contentHeight,
- itemCount: data.length,
+ height: layoutHeight,
+ hideHostname: options.hideHostname,
+ itemCount: layoutItemCount,
layout: options.layout,
width: layoutWidth,
}),
- [advanced, contentHeight, data.length, layoutWidth, options.layout, options.spacing],
+ [advanced, layoutHeight, layoutItemCount, layoutWidth, options.hideHostname, options.layout, options.spacing],
);
const cardDisplay = getBookmarkCardDisplay({
@@ -192,7 +215,6 @@ export default function BookmarksWidget({
if (appIds.length > 0 && isInitialWidgetQueryPending(appsQuery)) return <WidgetQueryLoadingState />;
- const isTight = responsiveHeight < 120;
let compactStyle: CSSProperties | undefined;
if (!advanced && Number.isFinite(displayScale) && displayScale > 1) {
// Low-column boards zoom the canvas above 100%. Keep bookmark controls at their intended physical size.
@@ -207,7 +229,7 @@ export default function BookmarksWidget({
}
return (
- <Stack h="100%" mih={0} gap={isTight ? 6 : "sm"} p={isTight ? 6 : "sm"} style={compactStyle}>
+ <Stack h="100%" mih={0} gap={contentPadding} p={contentPadding} style={compactStyle}>
{showTitle && (
<Text fz={options.titleSize} fw={600} px={2} lh={1.2} lineClamp={1} style={{ flexShrink: 0 }}>
{options.title}
@@ -233,7 +255,7 @@ export default function BookmarksWidget({
>
<Box miw="100%" h="100%" pb={2}>
{sections.length > 0 ? (
- <Stack gap={4}>
+ <Stack gap={bookmarkGroupSpacing}>
<Accordion
multiple
value={sections
@@ -248,9 +270,9 @@ export default function BookmarksWidget({
}}
transitionDuration={0}
styles={{
- control: { padding: rem(4), minHeight: rem(28) },
+ control: { padding: rem(bookmarkGroupSpacing), minHeight: rem(bookmarkGroupControlHeight) },
label: { padding: 0, fontSize: "var(--mantine-font-size-xxs)", fontWeight: 600 },
- content: { padding: `0 0 ${rem(4)}` },
+ content: { padding: `0 0 ${rem(bookmarkGroupSpacing)}` },
item: { border: 0 },
chevron: zoomCompensatedSize(14),
}}
@@ -272,8 +294,8 @@ export default function BookmarksWidget({
))}
</Accordion>
{ungroupedItems.length > 0 && (
- <Stack gap={4}>
- <Text size="xxs" fw={600} px={4}>
+ <Stack gap={bookmarkGroupSpacing}>
+ <Text size="xxs" fw={600} px={bookmarkGroupSpacing} lh={rem(bookmarkUngroupedHeadingHeight)}>
{t("groups.ungrouped")}
</Text>
{renderItems(ungroupedItems)}
@@ -501,3 +523,7 @@ const bookmarkSpacingPixels = {
lg: 20,
xl: 32,
} as const;
+
+const bookmarkGroupControlHeight = 28;
+const bookmarkGroupSpacing = 4;
+const bookmarkUngroupedHeadingHeight = 18;
diff --git a/packages/widgets/src/bookmarks/layout.ts b/packages/widgets/src/bookmarks/layout.ts
index 1f71bbad1..51cdeb59a 100644
--- a/packages/widgets/src/bookmarks/layout.ts
+++ b/packages/widgets/src/bookmarks/layout.ts
@@ -197,6 +197,7 @@ export const getBookmarkDisplayPlan = ({
advanced,
gap = 0,
height,
+ hideHostname = false,
itemCount,
layout,
width,
@@ -204,6 +205,7 @@ export const getBookmarkDisplayPlan = ({
advanced: boolean;
gap?: number;
height: number;
+ hideHostname?: boolean;
itemCount: number;
layout: BookmarkLayout;
width: number;
@@ -247,14 +249,19 @@ export const getBookmarkDisplayPlan = ({
}
if (layout === "column") {
+ const itemGap = Math.min(gap, 4);
+ const availableItemHeight = (normalizedHeight - Math.max(0, count - 1) * itemGap) / count;
+ let itemHeight = 32;
+ if (!hideHostname && widthSettings.showTitle && availableItemHeight >= 48) itemHeight = 48;
+
return {
columns: 1,
horizontalScroll: false,
- itemGap: Math.min(gap, 4),
- itemHeight: 32,
+ itemGap,
+ itemHeight,
itemWidth: width,
orientation: "horizontal",
- showHostname: widthSettings.showHostname,
+ showHostname: widthSettings.showTitle,
showTitle: widthSettings.showTitle,
};
}