Skip to content

armgit / dashy

Public Imported from GitHub
0

πŸš€ A self-hostable personal dashboard built for you. Includes status-checking, widgets, themes, icon packs, a UI editor and tons more!

πŸ“± New responsive item layout within sections

Alicia Sykes8f2240895c45
diff --git a/docs/configuring.md b/docs/configuring.md
index 835f366b..c23e119f 100644
--- a/docs/configuring.md
+++ b/docs/configuring.md
@@ -317,9 +317,9 @@ For more info, see the **[Authentication Docs](/docs/authentication.md)**
**`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`)
**`customStyles`** | `string` | _Optional_ | Custom CSS properties that should be applied to that section, e.g. `border: 2px dashed #ff0000;`
-**`sectionLayout`** | `string` | _Optional_ | Specify which CSS layout will be used to responsively place items. Can be either `auto` (which uses flex layout), or `grid`. If `grid` is selected, then `itemCountX` and `itemCountY` may also be set. Defaults to `auto`
-**`itemCountX`** | `number` | _Optional_ | The number of items to display per row / horizontally. If not set, it will be calculated automatically based on available space. Can only be set if `sectionLayout` is set to `grid`. Must be a whole number between `1` and `12`
-**`itemCountY`** | `number` | _Optional_ | The number of items to display per column / vertically. If not set, it will be calculated automatically based on available space. If `itemCountX` is set, then `itemCountY` can be calculated automatically. Can only be set if `sectionLayout` is set to `grid`. Must be a whole number between `1` and `12`
+**`sectionLayout`** | `string` | _Optional_ | Specify which CSS layout will be used to responsively place items. Can be either `auto` (which uses flex layout), or `grid`. Defaults to `auto`. Setting `itemCountX` or `itemCountY` below will also switch the section to grid layout automatically
+**`itemCountX`** | `number` | _Optional_ | Number of items per row / horizontally. If not set, it will be calculated automatically based on available space. Setting this switches the section to grid layout. Must be a whole number between `1` and `12`; values above `8` rely on the grid's responsive column sizing (no explicit minimum-width rule)
+**`itemCountY`** | `number` | _Optional_ | Number of explicit rows before items flow into implicit rows. Setting this switches the section to grid layout. Must be a whole number between `1` and `12`. Row heights size to their content (section heights follow content in the masonry layout)
**`hideForUsers`** | `string[]` | _Optional_ | Current section will be visible to all users, except for those specified in this list
**`showForUsers`** | `string[]` | _Optional_ | Current section will be hidden from all users, except for those specified in this list
**`hideForGuests`** | `boolean` | _Optional_ | Current section will be visible for logged in users, but not for guests (see `appConfig.enableGuestAccess`). Defaults to `false`
diff --git a/docs/pages-and-sections.md b/docs/pages-and-sections.md
index 7b6cfbdb..32b75587 100644
--- a/docs/pages-and-sections.md
+++ b/docs/pages-and-sections.md
@@ -18,6 +18,8 @@ If you have multiple configs/pages, then these values swap automatically as you
The only caveat being, if you install Dashy as a PWA, the installed app's name, icon, and splash-screen colour come from the bundled `manifest.webmanifest` (baked at build time) rather than `pageInfo`. Runtime values only apply when browsing in a regular tab or browser.
+---
+
## Multi-Page Support
You can have additional pages within your dashboard, with each having it's own config file. The config files for sub-pages can either be stored locally, or hosted separately. A link to each additional page will be displayed in the navigation bar.
@@ -111,7 +113,43 @@ Examples:
The view switcher, sub-page nav links, and section deep-links all preserve your current view and sub-page β€” so clicking through a single-section view and then hitting "back to all" returns you to the same sub-page you came from.
-## Sub-Items
+---
+
+## Layout
+
+`appConfig.layout` controls how your sections sit on the page:
+
+- `auto` (default): masonry grid, shorter sections fill the gaps under taller ones
+- `horizontal`: sections stacked top to bottom, each full width
+- `vertical`: sections side by side in columns
+
+You can also switch between these from the settings menu. Add `appConfig.colCount` to force a specific number of columns.
+
+### Making a section wider
+
+Use `displayData.cols` (1 to 5) to make a section span extra columns:
+
+```yaml
+- name: Important Links
+ displayData:
+ cols: 2
+ collapsed: false
+ items: [...]
+```
+
+Section heights follow their content, so there's no `rows` option.
+
+### Items inside a section
+
+Items wrap responsively by default. The useful knobs on `displayData`:
+
+- `itemSize`: `small`, `medium` (default), or `large` (large tiles also show a description)
+- `sortBy`: `alphabetical`, `reverse-alphabetical`, `most-used`, `last-used`, `random`
+- `sectionLayout: grid` plus `itemCountX` and/or `itemCountY` if you want a fixed grid instead of auto wrapping
+
+See [configuring.md](./configuring.md#sectiondisplaydata-optional) for the full list of options.
+
+### Sub-Items
A normal section will contain zero or more items, for example:
diff --git a/src/components/LinkItems/Item.vue b/src/components/LinkItems/Item.vue
index 7d5232cf..dd3401d6 100644
--- a/src/components/LinkItems/Item.vue
+++ b/src/components/LinkItems/Item.vue
@@ -212,8 +212,10 @@ export default {
<style lang="scss">
.item-wrapper {
+ display: flex;
flex-grow: 1;
flex-basis: 6rem;
+ min-width: 0;
&.wrap-size-large {
flex-basis: 12rem;
}
@@ -235,6 +237,7 @@ export default {
.item {
flex-grow: 1;
+ min-width: 0;
color: var(--item-text-color);
vertical-align: middle;
margin: 0.5rem;
@@ -261,7 +264,7 @@ export default {
border: 2px dashed var(--primary) !important;
}
&.short:not(.size-large) {
- height: 2rem;
+ min-height: 2rem;
}
}
@@ -269,7 +272,8 @@ export default {
.tile-title {
white-space: nowrap;
text-overflow: ellipsis;
- min-width: 120px;
+ min-width: 0;
+ flex: 1 1 auto;
height: 30px;
position: relative;
padding: 0;
@@ -371,8 +375,8 @@ p.description {
margin-bottom: 0.25rem;
}
.tile-title {
- min-width: 100px;
- max-width: 160px;
+ min-width: 0;
+ max-width: min(160px, 100%);
&.no-icon {
text-align: left;
width: 100%;
diff --git a/src/components/LinkItems/Section.vue b/src/components/LinkItems/Section.vue
index 413c81b5..2483fa29 100644
--- a/src/components/LinkItems/Section.vue
+++ b/src/components/LinkItems/Section.vue
@@ -200,12 +200,10 @@ export default {
},
gridStyle() {
let styles = '';
- if (document.body.clientWidth > 600) { // Only proceed if not on tiny screen
- styles += this.displayData.itemCountX
- ? `grid-template-columns: repeat(${this.displayData.itemCountX}, minmax(0, 1fr));` : '';
- styles += this.displayData.itemCountY
- ? `grid-template-rows: repeat(${this.displayData.itemCountY}, minmax(0, 1fr));` : '';
- }
+ styles += this.displayData.itemCountX
+ ? `grid-template-columns: repeat(${this.displayData.itemCountX}, minmax(0, 1fr));` : '';
+ styles += this.displayData.itemCountY
+ ? `grid-template-rows: repeat(${this.displayData.itemCountY}, auto);` : '';
return styles;
},
effectiveColsSpan() {
@@ -244,8 +242,7 @@ export default {
.sort((a, b) => a.sort - b.sort)
.map(({ value }) => value);
},
- /* Navigate to the section's single-section view. Uses loaded confId from state
- * (not the URL) so clicks recover cleanly if the current URL is mid-error. */
+ /* Navigate to the section's single-section view */
navigateToSection() {
if (!this.title) {
ErrorHandler('Cannot open section without a valid name');
@@ -341,10 +338,15 @@ export default {
.there-are-items {
height: 100%;
- display: flex;
- flex-wrap: wrap;
+ display: grid;
+ grid-template-columns: repeat(auto-fill, minmax(min(8rem, 100%), 1fr));
+ &.inner-size-small {
+ grid-template-columns: repeat(auto-fill, minmax(min(10rem, 100%), 1fr));
+ }
+ &.inner-size-large {
+ grid-template-columns: repeat(auto-fill, minmax(min(14rem, 100%), 1fr));
+ }
&.item-group-grid {
- display: grid;
overflow: auto;
@extend .scroll-bar;
@include phone { --item-col-count: 1; }
diff --git a/src/components/LinkItems/SubItem.vue b/src/components/LinkItems/SubItem.vue
index 8a80dbdf..a2b73967 100644
--- a/src/components/LinkItems/SubItem.vue
+++ b/src/components/LinkItems/SubItem.vue
@@ -12,9 +12,10 @@
:id="`link-${id}`"
class="sub-item-link item"
>
- <!-- Item Icon -->
- <Icon :icon="item.icon" :url="item.url"
+ <!-- Item Icon (shows title as fallback when no icon) -->
+ <Icon v-if="item.icon" :icon="item.icon" :url="item.url"
size="small" v-bind:style="customStyles" class="sub-icon-img bounce" />
+ <span v-else class="sub-item-text">{{ item.title }}</span>
</a>
<!-- Right-click context menu -->
<ContextMenu
@@ -67,6 +68,16 @@ export default {
.sub-icon-img {
margin: 0;
}
+ .sub-item-text {
+ display: block;
+ padding: 0.3rem 0.5rem;
+ font-size: 0.75rem;
+ text-align: center;
+ overflow: hidden;
+ text-overflow: ellipsis;
+ white-space: nowrap;
+ color: var(--item-text-color);
+ }
}
&.wrap-size-large {
flex-basis: 12rem;
diff --git a/src/components/LinkItems/SubItemGroup.vue b/src/components/LinkItems/SubItemGroup.vue
index 2b4a2fbd..0184e02f 100644
--- a/src/components/LinkItems/SubItemGroup.vue
+++ b/src/components/LinkItems/SubItemGroup.vue
@@ -48,7 +48,7 @@ export default {
<style scoped lang="scss">
.sub-items-group {
display: grid;
- margin: 0.5rem;
+ margin: 0.25rem;
padding: 0.1rem;
flex-grow: 1;
flex-basis: 6rem;