mirror of https://github.com/Lissy93/dashy.git
⚡ Item size and layout are now managed by store
This commit is contained in:
parent
513b1cd955
commit
168e52c251
|
@ -47,7 +47,6 @@ export default {
|
|||
},
|
||||
methods: {
|
||||
updateIconSize(iconSize) {
|
||||
this.$emit('iconSizeUpdated', iconSize);
|
||||
this.$store.commit(StoreKeys.SET_ITEM_SIZE, iconSize);
|
||||
},
|
||||
tooltip(content) {
|
||||
|
|
|
@ -32,11 +32,6 @@ import IconVertical from '@/assets/interface-icons/layout-vertical.svg';
|
|||
|
||||
export default {
|
||||
name: 'LayoutSelector',
|
||||
data() {
|
||||
return {
|
||||
input: '',
|
||||
};
|
||||
},
|
||||
props: {
|
||||
displayLayout: String,
|
||||
},
|
||||
|
@ -47,7 +42,6 @@ export default {
|
|||
},
|
||||
methods: {
|
||||
updateDisplayLayout(layout) {
|
||||
this.$emit('layoutUpdated', layout);
|
||||
this.$store.commit(StoreKeys.SET_ITEM_LAYOUT, layout);
|
||||
},
|
||||
tooltip(content) {
|
||||
|
|
|
@ -7,8 +7,8 @@
|
|||
<div class="options-outer">
|
||||
<div :class="`options-container ${!settingsVisible ? 'hide' : ''}`">
|
||||
<ThemeSelector />
|
||||
<LayoutSelector :displayLayout="displayLayout" @layoutUpdated="updateDisplayLayout"/>
|
||||
<ItemSizeSelector :iconSize="iconSize" @iconSizeUpdated="updateIconSize" />
|
||||
<LayoutSelector :displayLayout="displayLayout" />
|
||||
<ItemSizeSelector :iconSize="iconSize" />
|
||||
<ConfigLauncher />
|
||||
<AuthButtons v-if="userState != 'noone'" :userType="userState" />
|
||||
</div>
|
||||
|
@ -106,12 +106,6 @@ export default {
|
|||
clearFilterInput() {
|
||||
this.$refs.SearchBar.clearFilterInput();
|
||||
},
|
||||
updateDisplayLayout(layout) {
|
||||
this.$emit('change-display-layout', layout);
|
||||
},
|
||||
updateIconSize(iconSize) {
|
||||
this.$emit('change-icon-size', iconSize);
|
||||
},
|
||||
getInitialTheme() {
|
||||
return this.appConfig.theme || '';
|
||||
},
|
||||
|
|
|
@ -86,6 +86,12 @@ const store = new Vuex.Store({
|
|||
});
|
||||
return foundSection;
|
||||
},
|
||||
layout(state) {
|
||||
return state.config.appConfig.layout || 'auto';
|
||||
},
|
||||
iconSize(state) {
|
||||
return state.config.appConfig.iconSize || 'medium';
|
||||
},
|
||||
},
|
||||
mutations: {
|
||||
[SET_CONFIG](state, config) {
|
||||
|
@ -217,12 +223,15 @@ const store = new Vuex.Store({
|
|||
},
|
||||
[SET_ITEM_LAYOUT](state, layout) {
|
||||
state.config.appConfig.layout = layout;
|
||||
InfoHandler('Layout updated', InfoKeys.VISUAL);
|
||||
},
|
||||
[SET_ITEM_SIZE](state, iconSize) {
|
||||
state.config.appConfig.iconSize = iconSize;
|
||||
InfoHandler('Item size updated', InfoKeys.VISUAL);
|
||||
},
|
||||
[UPDATE_CUSTOM_CSS](state, customCss) {
|
||||
state.config.appConfig.customCss = customCss;
|
||||
InfoHandler('Custom colors updated', InfoKeys.VISUAL);
|
||||
},
|
||||
},
|
||||
actions: {
|
||||
|
|
|
@ -4,8 +4,6 @@
|
|||
<!-- Search bar, layout options and settings -->
|
||||
<SettingsContainer ref="filterComp"
|
||||
@user-is-searchin="searching"
|
||||
@change-display-layout="setLayoutOrientation"
|
||||
@change-icon-size="setItemSize"
|
||||
@change-modal-visibility="updateModalVisibility"
|
||||
:displayLayout="layout"
|
||||
:iconSize="itemSizeBound"
|
||||
|
@ -120,20 +118,22 @@ export default {
|
|||
return sections.filter((section) => this.filterTiles(section.items, this.searchValue));
|
||||
},
|
||||
/* Updates layout (when button clicked), and saves in local storage */
|
||||
layoutOrientation: {
|
||||
get() { return this.appConfig.layout || Defaults.layout; },
|
||||
set: function setLayout(layout) {
|
||||
localStorage.setItem(localStorageKeys.LAYOUT_ORIENTATION, layout);
|
||||
this.layout = layout;
|
||||
},
|
||||
layoutOrientation() {
|
||||
return this.$store.getters.layout;
|
||||
},
|
||||
/* Updates icon size (when button clicked), and saves in local storage */
|
||||
iconSize: {
|
||||
get() { return this.appConfig.iconSize || Defaults.iconSize; },
|
||||
set: function setIconSize(iconSize) {
|
||||
localStorage.setItem(localStorageKeys.ICON_SIZE, iconSize);
|
||||
this.itemSizeBound = iconSize;
|
||||
},
|
||||
iconSize() {
|
||||
return this.$store.getters.iconSize;
|
||||
},
|
||||
},
|
||||
watch: {
|
||||
layoutOrientation(layout) {
|
||||
localStorage.setItem(localStorageKeys.LAYOUT_ORIENTATION, layout);
|
||||
this.layout = layout;
|
||||
},
|
||||
iconSize(size) {
|
||||
localStorage.setItem(localStorageKeys.ICON_SIZE, size);
|
||||
this.itemSizeBound = size;
|
||||
},
|
||||
},
|
||||
methods: {
|
||||
|
@ -158,14 +158,6 @@ export default {
|
|||
getDisplayData(section) {
|
||||
return !section.displayData ? {} : section.displayData;
|
||||
},
|
||||
/* Sets layout attribute, which is used by Section */
|
||||
setLayoutOrientation(layout) {
|
||||
this.layoutOrientation = layout;
|
||||
},
|
||||
/* Sets item size attribute, which is used by Section */
|
||||
setItemSize(itemSize) {
|
||||
this.iconSize = itemSize;
|
||||
},
|
||||
/* Update data when modal is open (so that key bindings can be disabled) */
|
||||
updateModalVisibility(modalState) {
|
||||
this.$store.commit('SET_MODAL_OPEN', modalState);
|
||||
|
|
Loading…
Reference in New Issue