π A self-hostable personal dashboard built for you. Includes status-checking, widgets, themes, icon packs, a UI editor and tons more!
Vue awesomedashboarddockerhomelabhomepagemitnodejsorganizationproductivitypwaself-hostedstartpagevue
β¨ New masonry layout, for default section responsivness
Alicia Sykes0a129b7b15a2
diff --git a/docs/authentication.md b/docs/authentication.mdindex fe3ed1de..437a3a74 100644--- a/docs/authentication.md+++ b/docs/authentication.md@@ -565,7 +565,6 @@ sections:- name: AuthenticationdisplayData:sortBy: default- rows: 2cols: 1collapsed: falsehideForGuests: falsediff --git a/docs/configuring.md b/docs/configuring.mdindex 08d529ae..835f366b 100644--- a/docs/configuring.md+++ b/docs/configuring.md@@ -119,7 +119,7 @@ For more info, see the[Multi-Page docs](/docs/pages-and-sections.md#multi-page-s**`faviconApi`** | `enum` | _Optional_ | Only applicable if you are using favicons for item icons. Specifies which service to use to resolve favicons. Set to `local` to do this locally, without using an API. Services running locally will use this option always. Available options are: `local`, `allesedv`, `iconhorse`, `faviconkit`, `duckduckgo`, `yandex`, `google`, `besticon`, `webmasterapi` and `mcapi`. Defaults to `allesedv`. See [Icons](/docs/icons.md#favicons) for more info**`auth`** | `object` | _Optional_ | All settings relating to user authentication. See [`auth`](#appconfigauth-optional)**`defaultIcon`** | `string` | _Optional_ | An icon to be applied to any items, which don't already have an icon set. See [Icon Docs](/docs/icons.md#default-icon) for more info-**`layout`** | `enum` | _Optional_ | Layout for homepage, either `horizontal`, `vertical` or `auto`. Defaults to `auto`. This specifies the layout and direction of how sections are positioned on the home screen. This can also be modified and overridden from the UI.+**`layout`** | `enum` | _Optional_ | Layout for homepage, either `horizontal`, `vertical` or `auto`. Defaults to `auto`. This specifies the layout and direction of how sections are positioned on the home screen. `auto` uses a responsive masonry grid: sections flow into the next available slot so shorter ones fill the gaps left by taller neighbours; `section.displayData.cols` still controls width, but `rows` is ignored (heights are driven by content). This can also be modified and overridden from the UI.**`iconSize`** | `enum` | _Optional_ | The size of link items / icons. Can be either `small`, `medium,` or `large`. Defaults to `medium`. This can also be set directly from the UI.**`colCount`** | `number` | _Optional_ | The number of columns of sections displayed on the homepage, using the default view. Should be in integer between `1` and `8`. Note that by default this is applied responsively, based on current screen size, and specifying a value here will override this behavior, which may not be desirable.**`contentMaxWidth`** | `string` or `number` | _Optional_ | Sets the max width of the main sections area on the homepage, overriding the responsive default. Can be a percentage, or any CSS unit@@ -312,7 +312,7 @@ For more info, see the **[Authentication Docs](/docs/authentication.md)****`sortBy`** | `string` | _Optional_ | The sort order for items within the current section. By default items are displayed in the order in which they are listed in within the config. The following sort options are supported: `most-used` (most opened apps first), `last-used` (the most recently used apps), `alphabetical`, `reverse-alphabetical`, `random` and `default`**`collapsed`** | `boolean` | _Optional_ | If true, the section will be collapsed initially, and will need to be clicked to open. Useful for less regularly used, or very long sections. Defaults to `false`**`cutToHeight`** | `boolean` | _Optional_ | By default, sections will fill available space. Set this option to true to match section height with content height-**`rows`** | `number` | _Optional_ | Height of the section, specified as the number of rows it should span vertically, e.g. `2`. Defaults to `1`. Max is `5`.+**`rows`** | `number` | _Optional_ | _Deprecated._ Previously set a section's vertical row-span. The `auto` layout now uses masonry (heights follow content) and `horizontal`/`vertical` are flex-based, so this value is accepted for config compatibility but no longer applied.**`cols`** | `number` | _Optional_ | Width of the section, specified as the number of columns the section should span horizontally, e.g. `2`. Defaults to `1`. Max is `5`. Will be clamped to the page's active column count so that a section never exceeds the available grid width.**`itemSize`** | `string` | _Optional_ | Specify the size for items within this group, either `small`, `medium` or `large`. Note that this will override any settings specified through the UI**`color`** | `string` | _Optional_ | A custom accent color for the section, as a hex code or HTML color (e.g. `#fff`)diff --git a/src/components/InteractiveEditor/AddNewSectionLauncher.vue b/src/components/InteractiveEditor/AddNewSectionLauncher.vueindex 88d752ea..f4c93c66 100644--- a/src/components/InteractiveEditor/AddNewSectionLauncher.vue+++ b/src/components/InteractiveEditor/AddNewSectionLauncher.vue@@ -1,6 +1,6 @@<!-- Main homepage for default view --><template>- <div class="add-section">+ <div class="add-section" :style="dynamicStyle"><!-- When in edit mode, show Add New Section button --><div v-if="isEditMode" @click="openAddNewSectionMenu()" class="add-new-section"><p>β {{ $t('interactive-editor.edit-section.add-section-title') }}</p>@@ -17,11 +17,13 @@<script>import EditSectionMenu from '@/components/InteractiveEditor/EditSection.vue';+import MasonryItem from '@/mixins/MasonryItem';import StoreKeys from '@/utils/StoreMutations';import { modalNames } from '@/utils/config/defaults';export default {name: 'add-section-container',+ mixins: [MasonryItem],components: {EditSectionMenu,},@@ -32,6 +34,9 @@ export default {isEditMode() {return this.$store.state.editMode;},+ dynamicStyle() {+ return this.masonryStyle;+ },},methods: {openAddNewSectionMenu() {diff --git a/src/components/InteractiveEditor/EditSection.vue b/src/components/InteractiveEditor/EditSection.vueindex b8611c0e..51a979af 100644--- a/src/components/InteractiveEditor/EditSection.vue+++ b/src/components/InteractiveEditor/EditSection.vue@@ -41,7 +41,6 @@ const SECTION_SCHEMA = {description: sectionProps.displayData.description,properties: {sortBy: displayProps.sortBy,- rows: displayProps.rows,cols: displayProps.cols,collapsed: displayProps.collapsed,hideForGuests: displayProps.hideForGuests,diff --git a/src/components/LinkItems/Collapsable.vue b/src/components/LinkItems/Collapsable.vueindex a315e3ba..fffef580 100644--- a/src/components/LinkItems/Collapsable.vue+++ b/src/components/LinkItems/Collapsable.vue@@ -1,10 +1,10 @@<template><divv-bind:class="[- { 'is-open': isExpanded, 'full-height': cutToHeight },- `collapsable ${rowColSpanClass}`, sectionClassName+ { 'is-open': isExpanded, 'full-height': cutToHeight && !isMasonry },+ `collapsable ${colSpanClass}`, sectionClassName]"- :style="`${color ? 'background: '+color : ''}; ${sanitizeCustomStyles(customStyles)};`"+ :style="dynamicStyle"><input:id="sectionKey"@@ -37,6 +37,7 @@<script>import longPress from '@/directives/LongPress';+import MasonryItem from '@/mixins/MasonryItem';import { localStorageKeys } from '@/utils/config/defaults';import Icon from '@/components/LinkItems/ItemIcon.vue';import EditModeIcon from '@/assets/interface-icons/interactive-editor-edit-mode.svg';@@ -44,13 +45,13 @@ import EllipseIcon from '@/assets/interface-icons/ellipse.svg';export default {name: 'CollapsableContainer',+ mixins: [MasonryItem],props: {uniqueKey: String, // Generated unique IDtitle: String, // The section titleicon: String, // An optional section iconcollapsed: Boolean, // Optional override collapse statecols: Number, // Set section horizontal col span / width- rows: Number, // Set section vertical row span / heightcolor: String, // Optional color overridecustomStyles: String, // Optional custom stylingscutToHeight: Boolean, // To set section height with content height@@ -70,12 +71,16 @@ export default {sectionKey() {return `collapsible-${this.uniqueKey}`;},- collapseClass() {- return !this.isExpanded ? ' is-collapsed' : 'is-open';+ colSpanClass() {+ return this.checkSpanNum(this.cols, 'col');},- rowColSpanClass() {- const { rows, cols, checkSpanNum } = this;- return `${checkSpanNum(cols, 'col')} ${checkSpanNum(rows, 'row')}`;+ dynamicStyle() {+ const parts = [];+ if (this.color) parts.push(`background: ${this.color}`);+ const custom = this.sanitizeCustomStyles(this.customStyles);+ if (custom) parts.push(custom);+ if (this.masonryStyle) parts.push(this.masonryStyle);+ return parts.join('; ');},sectionClassName() {if (!this.title) return 'unnamed-section';@@ -128,7 +133,7 @@ export default {toggle() {this.checkboxState = !this.checkboxState;},- /* Check that row & column span is valid, and not over the max */+ /* Clamp a user-supplied column-span to a sane range, returning a CSS class name */checkSpanNum(span, classPrefix) {const maxSpan = 6;let numSpan = /^\d*$/.test(span) ? parseInt(span, 10) : 1;@@ -185,16 +190,10 @@ export default {box-shadow: var(--item-group-shadow);background: var(--item-group-outer-background);- /* Options allowing sections to SPAN multiple rows or columns */- grid-row-start: span 1;- &.row-2 { grid-row-start: span 2; }- &.row-3 { grid-row-start: span 3; }- &.row-4 { grid-row-start: span 4; }- &.row-5 { grid-row-start: span 5; }- &.row-6 { grid-row-start: span 6; }+ /* Section column spanning (heights are driven by masonry / content). */grid-column-start: span 1;@include tablet-up {- &.col-2, &.col-3, &.col-4, &.col-5, &.col-6 { grid-column-start: span 2; }+ &.col-2, &.col-3, &.col-4, &.col-5, &.col-6 { grid-column-start: span 2; }}@include laptop-up {&.col-2 { grid-column-start: span 2; }diff --git a/src/components/LinkItems/Section.vue b/src/components/LinkItems/Section.vueindex f5930970..413c81b5 100644--- a/src/components/LinkItems/Section.vue+++ b/src/components/LinkItems/Section.vue@@ -5,7 +5,6 @@:uniqueKey="groupId":collapsed="displayData.collapsed":cols="effectiveColsSpan"- :rows="displayData.rows":color="displayData.color":customStyles="displayData.customStyles":cutToHeight="displayData.cutToHeight"diff --git a/src/mixins/MasonryItem.js b/src/mixins/MasonryItem.jsnew file mode 100644index 00000000..5d508b42--- /dev/null+++ b/src/mixins/MasonryItem.js@@ -0,0 +1,53 @@+/**+ * Lets a direct child of `.item-group-container.orientation-auto` participate+ * in the masonry grid. Measures its root element's height + vertical margins,+ * converts to a `grid-row: span N` value against the container's+ * `grid-auto-rows` unit, and keeps it in sync via a ResizeObserver.+ *+ * Usage: add to a component's `mixins`, then bind `masonryStyle` (a string+ * of inline CSS, empty when the current layout isn't masonry) to the root+ * element's `:style` attribute.+ */+export default {+ data: () => ({+ masonryRowSpan: 0,+ masonryResizeObserver: null,+ }),+ computed: {+ isMasonry() {+ return this.$store.getters.layout === 'auto';+ },+ masonryStyle() {+ if (!this.isMasonry || !this.masonryRowSpan) return '';+ return `grid-row: span ${this.masonryRowSpan}`;+ },+ },+ mounted() {+ this.updateMasonrySpan();+ this.setupMasonryObserver();+ },+ beforeUnmount() {+ if (this.masonryResizeObserver) {+ this.masonryResizeObserver.disconnect();+ this.masonryResizeObserver = null;+ }+ },+ methods: {+ updateMasonrySpan() {+ const el = this.$el;+ if (!el || !el.parentElement) return;+ const parentStyle = getComputedStyle(el.parentElement);+ const rowUnit = parseFloat(parentStyle.gridAutoRows) || 8;+ const style = getComputedStyle(el);+ const marginY = (parseFloat(style.marginTop) || 0)+ + (parseFloat(style.marginBottom) || 0);+ const total = el.offsetHeight + marginY;+ this.masonryRowSpan = Math.max(1, Math.ceil(total / rowUnit));+ },+ setupMasonryObserver() {+ if (typeof ResizeObserver === 'undefined' || !this.$el) return;+ this.masonryResizeObserver = new ResizeObserver(() => this.updateMasonrySpan());+ this.masonryResizeObserver.observe(this.$el);+ },+ },+};diff --git a/src/utils/config/ConfigSchema.json b/src/utils/config/ConfigSchema.jsonindex 2799b6c4..bd27376d 100644--- a/src/utils/config/ConfigSchema.json+++ b/src/utils/config/ConfigSchema.json@@ -856,7 +856,8 @@"minimum": 1,"maximum": 5,"default": 1,- "description": "The amount of space that the section spans vertically"+ "deprecated": true,+ "description": "Deprecated. Section heights now follow content in the masonry layout; this value is accepted for backwards compatibility but has no effect."},"cols": {"title": "Num Cols",diff --git a/src/views/Home.vue b/src/views/Home.vueindex 62567664..bf3cd4df 100644--- a/src/views/Home.vue+++ b/src/views/Home.vue@@ -213,6 +213,14 @@ export default {max-width: var(--content-max-width, 85%);}+ /* Default layout - A masonry grid so sections are auto-positioned to make best use of space+ * Row span is computed per-section from content height against --masonry-row-unit */+ &.orientation-auto {+ grid-auto-rows: var(--masonry-row-unit, 8px);+ grid-auto-flow: row dense;+ row-gap: 0;+ }+/* Options for alternate layouts, triggered by buttons */&.orientation-horizontal {display: flex;