🚧 Working on section selection functionality

This commit is contained in:
Alicia Sykes 2021-08-06 21:11:40 +01:00
parent 992a18cf1b
commit a8ac255649
2 changed files with 64 additions and 50 deletions

View File

@ -1,26 +1,30 @@
<template> <template>
<div class="minimal-section-inner"> <div :class="`minimal-section-inner ${selected ? 'selected' : ''}`">
<Item <div class="section-title" @click="selectSection(index)">
v-for="(item, index) in items" <h3>{{ title }}</h3>
:id="`${index}_${makeId(item.title)}`" </div>
:key="`${index}_${makeId(item.title)}`" <div class="section-items" v-if="selected">
:url="item.url" <Item
:title="item.title" v-for="(item, index) in items"
:description="item.description" :id="`${index}_${makeId(item.title)}`"
:icon="item.icon" :key="`${index}_${makeId(item.title)}`"
:target="item.target" :url="item.url"
:color="item.color" :title="item.title"
:backgroundColor="item.backgroundColor" :description="item.description"
:statusCheckUrl="item.statusCheckUrl" :icon="item.icon"
:statusCheckHeaders="item.statusCheckHeaders" :target="item.target"
:itemSize="itemSize" :color="item.color"
:hotkey="item.hotkey" :backgroundColor="item.backgroundColor"
:enableStatusCheck="shouldEnableStatusCheck(item.statusCheck)" :statusCheckUrl="item.statusCheckUrl"
:statusCheckInterval="getStatusCheckInterval()" :statusCheckHeaders="item.statusCheckHeaders"
@itemClicked="$emit('itemClicked')" :itemSize="itemSize"
@triggerModal="triggerModal" :hotkey="item.hotkey"
/> :enableStatusCheck="shouldEnableStatusCheck(item.statusCheck)"
<div ref="modalContainer"></div> :statusCheckInterval="getStatusCheckInterval()"
@itemClicked="$emit('itemClicked')"
@triggerModal="triggerModal"
/>
</div>
<IframeModal <IframeModal
:ref="`iframeModal-${groupId}`" :ref="`iframeModal-${groupId}`"
:name="`iframeModal-${groupId}`" :name="`iframeModal-${groupId}`"
@ -45,12 +49,17 @@ export default {
items: Array, items: Array,
itemSize: String, itemSize: String,
modalOpen: Boolean, modalOpen: Boolean,
index: Number,
selected: Boolean,
}, },
components: { components: {
Item, Item,
IframeModal, IframeModal,
}, },
methods: { methods: {
selectSection(index) {
this.$emit('sectionSelected', index);
},
/* Returns a unique lowercase string, based on name, for section ID */ /* Returns a unique lowercase string, based on name, for section ID */
makeId(str) { makeId(str) {
return str.replace(/\s+/g, '-').replace(/[^a-zA-Z ]/g, '').toLowerCase(); return str.replace(/\s+/g, '-').replace(/[^a-zA-Z ]/g, '').toLowerCase();
@ -85,31 +94,28 @@ export default {
height: 100%; height: 100%;
display: flex; display: flex;
flex-wrap: wrap; flex-wrap: wrap;
&.item-group-grid {
display: grid;
overflow: auto;
@extend .scroll-bar;
@include phone { grid-template-columns: repeat(1, 1fr); }
@include tablet { grid-template-columns: repeat(2, 1fr); }
@include laptop { grid-template-columns: repeat(2, 1fr); }
@include monitor { grid-template-columns: repeat(3, 1fr); }
@include big-screen { grid-template-columns: repeat(4, 1fr); }
@include big-screen-up { grid-template-columns: repeat(5, 1fr); }
}
}
.orientation-horizontal {
display: flex;
flex-direction: column; flex-direction: column;
.there-are-items { .section-items {
display: grid; display: flex;
grid-template-columns: repeat(5, 1fr); flex-direction: column;
@include phone { grid-template-columns: repeat(2, 1fr); }
@include tablet { grid-template-columns: repeat(4, 1fr); }
@include laptop { grid-template-columns: repeat(6, 1fr); }
@include monitor { grid-template-columns: repeat(8, 1fr); }
@include big-screen { grid-template-columns: repeat(10, 1fr); }
@include big-screen-up { grid-template-columns: repeat(12, 1fr); }
} }
.section-title {
cursor: pointer;
padding: 0.5rem 0.25rem;
border-radius: var(--curve-factor);
h3 {
margin: 0;
color: var(--primary);
}
}
&.selected {
.section-title {
background: var(--primary);
h3 {
color: var(--background);
}
}
}
} }
</style> </style>

View File

@ -2,15 +2,18 @@
<div class="minimal-home" :style="getBackgroundImage()"> <div class="minimal-home" :style="getBackgroundImage()">
<!-- Main content, section for each group of items --> <!-- Main content, section for each group of items -->
<div v-if="checkTheresData(sections)" <div v-if="checkTheresData(sections)"
:class="`item-group-container orientation-${layout} item-size-${itemSizeBound}`"> :class="`item-group-container item-size-small`">
<MinimalSection <MinimalSection
v-for="(section, index) in getSections(sections)" v-for="(section, index) in getSections(sections)"
:key="index" :key="index"
:index="index"
:title="section.name" :title="section.name"
:icon="section.icon || undefined" :icon="section.icon || undefined"
:groupId="`section-${index}`" :groupId="`section-${index}`"
:items="filterTiles(section.items)" :items="filterTiles(section.items)"
:selected="selectedSection === index"
itemSize="small" itemSize="small"
@sectionSelected="sectionSelected"
@itemClicked="finishedSearching()" @itemClicked="finishedSearching()"
@change-modal-visibility="updateModalVisibility" @change-modal-visibility="updateModalVisibility"
:class="(filterTiles(section.items).length === 0 && searchValue) ? 'no-results' : ''" :class="(filterTiles(section.items).length === 0 && searchValue) ? 'no-results' : ''"
@ -36,10 +39,13 @@ export default {
data: () => ({ data: () => ({
searchValue: '', searchValue: '',
layout: '', layout: '',
itemSizeBound: '',
modalOpen: false, // When true, keybindings are disabled modalOpen: false, // When true, keybindings are disabled
selectedSection: 0, // The index of currently selected section
}), }),
methods: { methods: {
sectionSelected(index) {
this.selectedSection = index;
},
/* Returns true if there is one or more sections in the config */ /* Returns true if there is one or more sections in the config */
checkTheresData(sections) { checkTheresData(sections) {
const localSections = localStorage[localStorageKeys.CONF_SECTIONS]; const localSections = localStorage[localStorageKeys.CONF_SECTIONS];
@ -138,11 +144,13 @@ export default {
@import '@/styles/media-queries.scss'; @import '@/styles/media-queries.scss';
@import '@/styles/style-helpers.scss'; @import '@/styles/style-helpers.scss';
.home { .minimal-home {
padding-bottom: 1px; padding-bottom: 1px;
background: var(--background); background: var(--background);
// min-height: calc(100vh - 126px); min-height: calc(99.9vh - var(--footer-height));
min-height: calc(100vh - var(--footer-height)); width: 90%;
max-width: 1000px;
margin: 1rem auto;
} }
/* Outside container wrapping the item groups*/ /* Outside container wrapping the item groups*/