mirror of https://github.com/Lissy93/dashy.git
🐛 Fix layout and item size buttons
This commit is contained in:
parent
3416615d30
commit
9d683dcbf0
|
@ -37,8 +37,10 @@ export default {
|
||||||
input: '',
|
input: '',
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
props: {
|
computed: {
|
||||||
iconSize: String,
|
iconSize() {
|
||||||
|
return this.$store.getters.iconSize;
|
||||||
|
},
|
||||||
},
|
},
|
||||||
components: {
|
components: {
|
||||||
IconSmall,
|
IconSmall,
|
||||||
|
|
|
@ -5,19 +5,19 @@
|
||||||
<IconDeafault
|
<IconDeafault
|
||||||
@click="updateDisplayLayout('auto')"
|
@click="updateDisplayLayout('auto')"
|
||||||
v-tooltip="tooltip($t('settings.layout-auto'))"
|
v-tooltip="tooltip($t('settings.layout-auto'))"
|
||||||
:class="`layout-icon ${displayLayout === 'auto' ? 'selected' : ''}`"
|
:class="`layout-icon ${layout === 'auto' ? 'selected' : ''}`"
|
||||||
tabindex="-2"
|
tabindex="-2"
|
||||||
/>
|
/>
|
||||||
<IconHorizontal
|
<IconHorizontal
|
||||||
@click="updateDisplayLayout('horizontal')"
|
@click="updateDisplayLayout('horizontal')"
|
||||||
v-tooltip="tooltip($t('settings.layout-horizontal'))"
|
v-tooltip="tooltip($t('settings.layout-horizontal'))"
|
||||||
:class="`layout-icon ${displayLayout === 'horizontal' ? 'selected' : ''}`"
|
:class="`layout-icon ${layout === 'horizontal' ? 'selected' : ''}`"
|
||||||
tabindex="-2"
|
tabindex="-2"
|
||||||
/>
|
/>
|
||||||
<IconVertical
|
<IconVertical
|
||||||
@click="updateDisplayLayout('vertical')"
|
@click="updateDisplayLayout('vertical')"
|
||||||
v-tooltip="tooltip($t('settings.layout-vertical'))"
|
v-tooltip="tooltip($t('settings.layout-vertical'))"
|
||||||
:class="`layout-icon ${displayLayout === 'vertical' ? 'selected' : ''}`"
|
:class="`layout-icon ${layout === 'vertical' ? 'selected' : ''}`"
|
||||||
tabindex="-2"
|
tabindex="-2"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
@ -40,6 +40,11 @@ export default {
|
||||||
IconHorizontal,
|
IconHorizontal,
|
||||||
IconVertical,
|
IconVertical,
|
||||||
},
|
},
|
||||||
|
computed: {
|
||||||
|
layout() {
|
||||||
|
return this.$store.getters.layout;
|
||||||
|
},
|
||||||
|
},
|
||||||
methods: {
|
methods: {
|
||||||
updateDisplayLayout(layout) {
|
updateDisplayLayout(layout) {
|
||||||
this.$store.commit(StoreKeys.SET_ITEM_LAYOUT, layout);
|
this.$store.commit(StoreKeys.SET_ITEM_LAYOUT, layout);
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
<div class="options-outer">
|
<div class="options-outer">
|
||||||
<div :class="`options-container ${!settingsVisible ? 'hide' : ''}`">
|
<div :class="`options-container ${!settingsVisible ? 'hide' : ''}`">
|
||||||
<ThemeSelector />
|
<ThemeSelector />
|
||||||
<LayoutSelector :displayLayout="displayLayout" />
|
<LayoutSelector :displayLayout="$store.getters.layout" />
|
||||||
<ItemSizeSelector :iconSize="iconSize" />
|
<ItemSizeSelector :iconSize="iconSize" />
|
||||||
<ConfigLauncher />
|
<ConfigLauncher />
|
||||||
<AuthButtons v-if="userState !== 0" :userType="userState" />
|
<AuthButtons v-if="userState !== 0" :userType="userState" />
|
||||||
|
|
28
src/store.js
28
src/store.js
|
@ -145,10 +145,18 @@ const store = new Vuex.Store({
|
||||||
return foundSection;
|
return foundSection;
|
||||||
},
|
},
|
||||||
layout(state) {
|
layout(state) {
|
||||||
return state.config.appConfig.layout || 'auto';
|
const pageId = state.currentConfigInfo.confId;
|
||||||
|
const layoutStoreKey = pageId
|
||||||
|
? `${localStorageKeys.LAYOUT_ORIENTATION}-${pageId}` : localStorageKeys.LAYOUT_ORIENTATION;
|
||||||
|
const appConfigLayout = state.config.appConfig.layout;
|
||||||
|
return localStorage.getItem(layoutStoreKey) || appConfigLayout || 'auto';
|
||||||
},
|
},
|
||||||
iconSize(state) {
|
iconSize(state) {
|
||||||
return state.config.appConfig.iconSize || 'medium';
|
const pageId = state.currentConfigInfo.confId;
|
||||||
|
const sizeStoreKey = pageId
|
||||||
|
? `${localStorageKeys.ICON_SIZE}-${pageId}` : localStorageKeys.ICON_SIZE;
|
||||||
|
const appConfigSize = state.config.appConfig.iconSize;
|
||||||
|
return localStorage.getItem(sizeStoreKey) || appConfigSize || 'medium';
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
mutations: {
|
mutations: {
|
||||||
|
@ -310,11 +318,23 @@ const store = new Vuex.Store({
|
||||||
InfoHandler('Color palette updated', InfoKeys.VISUAL);
|
InfoHandler('Color palette updated', InfoKeys.VISUAL);
|
||||||
},
|
},
|
||||||
[SET_ITEM_LAYOUT](state, layout) {
|
[SET_ITEM_LAYOUT](state, layout) {
|
||||||
state.config.appConfig.layout = layout;
|
const newConfig = { ...state.config };
|
||||||
|
newConfig.appConfig.layout = layout;
|
||||||
|
state.config = newConfig;
|
||||||
|
const pageId = state.currentConfigInfo.confId;
|
||||||
|
const layoutStoreKey = pageId
|
||||||
|
? `${localStorageKeys.LAYOUT_ORIENTATION}-${pageId}` : localStorageKeys.LAYOUT_ORIENTATION;
|
||||||
|
localStorage.setItem(layoutStoreKey, layout);
|
||||||
InfoHandler('Layout updated', InfoKeys.VISUAL);
|
InfoHandler('Layout updated', InfoKeys.VISUAL);
|
||||||
},
|
},
|
||||||
[SET_ITEM_SIZE](state, iconSize) {
|
[SET_ITEM_SIZE](state, iconSize) {
|
||||||
state.config.appConfig.iconSize = iconSize;
|
const newConfig = { ...state.config };
|
||||||
|
newConfig.appConfig.iconSize = iconSize;
|
||||||
|
state.config = newConfig;
|
||||||
|
const pageId = state.currentConfigInfo.confId;
|
||||||
|
const sizeStoreKey = pageId
|
||||||
|
? `${localStorageKeys.ICON_SIZE}-${pageId}` : localStorageKeys.ICON_SIZE;
|
||||||
|
localStorage.setItem(sizeStoreKey, iconSize);
|
||||||
InfoHandler('Item size updated', InfoKeys.VISUAL);
|
InfoHandler('Item size updated', InfoKeys.VISUAL);
|
||||||
},
|
},
|
||||||
[UPDATE_CUSTOM_CSS](state, customCss) {
|
[UPDATE_CUSTOM_CSS](state, customCss) {
|
||||||
|
|
|
@ -19,14 +19,7 @@
|
||||||
</router-link>
|
</router-link>
|
||||||
</div>
|
</div>
|
||||||
<!-- Main content, section for each group of items -->
|
<!-- Main content, section for each group of items -->
|
||||||
<div v-if="checkTheresData(sections) || isEditMode"
|
<div v-if="checkTheresData(sections) || isEditMode" :class="computedClass">
|
||||||
:class="`item-group-container `
|
|
||||||
+ `orientation-${layout} `
|
|
||||||
+ `item-size-${itemSizeBound} `
|
|
||||||
+ (isEditMode ? 'edit-mode ' : '')
|
|
||||||
+ (singleSectionView ? 'single-section-view ' : '')
|
|
||||||
+ (this.colCount ? `col-count-${this.colCount} ` : '')"
|
|
||||||
>
|
|
||||||
<template v-for="(section, index) in filteredSections">
|
<template v-for="(section, index) in filteredSections">
|
||||||
<Section
|
<Section
|
||||||
:key="index"
|
:key="index"
|
||||||
|
@ -70,7 +63,7 @@ import ExportConfigMenu from '@/components/InteractiveEditor/ExportConfigMenu.vu
|
||||||
import AddNewSection from '@/components/InteractiveEditor/AddNewSectionLauncher.vue';
|
import AddNewSection from '@/components/InteractiveEditor/AddNewSectionLauncher.vue';
|
||||||
import NotificationThing from '@/components/Settings/LocalConfigWarning.vue';
|
import NotificationThing from '@/components/Settings/LocalConfigWarning.vue';
|
||||||
import StoreKeys from '@/utils/StoreMutations';
|
import StoreKeys from '@/utils/StoreMutations';
|
||||||
import { localStorageKeys, modalNames } from '@/utils/defaults';
|
import { modalNames } from '@/utils/defaults';
|
||||||
import ErrorHandler from '@/utils/ErrorHandler';
|
import ErrorHandler from '@/utils/ErrorHandler';
|
||||||
import BackIcon from '@/assets/interface-icons/back-arrow.svg';
|
import BackIcon from '@/assets/interface-icons/back-arrow.svg';
|
||||||
|
|
||||||
|
@ -120,19 +113,13 @@ export default {
|
||||||
iconSize() {
|
iconSize() {
|
||||||
return this.$store.getters.iconSize;
|
return this.$store.getters.iconSize;
|
||||||
},
|
},
|
||||||
},
|
computedClass() {
|
||||||
watch: {
|
let classes = 'item-group-container '
|
||||||
layoutOrientation(layout) {
|
+ ` orientation-${this.$store.getters.layout} item-size-${this.itemSizeBound}`;
|
||||||
if (layout) {
|
if (this.isEditMode) classes += ' edit-mode';
|
||||||
localStorage.setItem(localStorageKeys.LAYOUT_ORIENTATION, layout);
|
if (this.singleSectionView) classes += ' single-section-view';
|
||||||
this.layout = layout;
|
if (this.colCount) classes += ` col-count-${this.colCount}`;
|
||||||
}
|
return classes;
|
||||||
},
|
|
||||||
iconSize(size) {
|
|
||||||
if (size) {
|
|
||||||
localStorage.setItem(localStorageKeys.ICON_SIZE, size);
|
|
||||||
this.itemSizeBound = size;
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
|
Loading…
Reference in New Issue