[refactor] improve state structure

This commit is contained in:
Kombie 2019-07-01 21:46:50 +01:00 committed by GitHub
parent 5fd7341b53
commit edd91ee5dd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 139 additions and 129 deletions

View File

@ -21,7 +21,7 @@ body {
transition: background-color var(--layout-transition-speed-fast) ease-in-out;
}
.is-layout-scroll-past-end body {
.is-layout-scrollpastend body {
margin-bottom: 40vh;
}

View File

@ -27,11 +27,11 @@
left: 0;
}
.is-layout-order-headerLink.is-link-show .header {
.is-layout-order-headerlink.is-link-show .header {
top: 0;
}
.is-layout-order-linkHeader.is-link-show .header {
.is-layout-order-linkheader.is-link-show .header {
bottom: 0;
}
@ -185,7 +185,7 @@
.is-header-search-show .header-search,
.is-header-date-show .header-date,
.is-header-clock-show .header-clock,
.is-header-button-edit-add-show .header-edit-add,
.is-header-button-editadd-show .header-edit-add,
.is-header-button-accent-show .header-accent,
.is-header-greeting-show .header-greeting,
.is-header-transitional-show .header-transitional,

View File

@ -3,10 +3,6 @@
width: var(--layout-width);
}
.is-layout-scroll-past-end body {
margin-bottom: 40vh;
}
.is-layout-alignment-horizontal-left body {
align-items: flex-start;
}

View File

@ -33,21 +33,21 @@
grid-template-columns: repeat(auto-fill, minmax(var(--link-item-width), 1fr));
}
.is-layout-order-headerLink .link-area {
.is-layout-order-headerlink .link-area {
padding-bottom: calc(var(--layout-gutter) * var(--layout-padding-multiplier));
}
.is-layout-order-headerLink.is-header-border-bottom .link-area,
.is-layout-order-headerLink.is-header-shade-style-always .link-area {
.is-layout-order-headerlink.is-header-border-bottom .link-area,
.is-layout-order-headerlink.is-header-shade-style-always .link-area {
padding-top: calc(var(--layout-gutter) * var(--layout-padding-multiplier));
}
.is-layout-order-linkHeader .link-area {
.is-layout-order-linkheader .link-area {
padding-top: calc(var(--layout-gutter) * var(--layout-padding-multiplier));
}
.is-layout-order-linkHeader.is-header-border-top .link-area,
.is-layout-order-linkHeader.is-header-shade-style-always .link-area {
.is-layout-order-linkheader.is-header-border-top .link-area,
.is-layout-order-linkheader.is-header-shade-style-always .link-area {
padding-bottom: calc(var(--layout-gutter) * var(--layout-padding-multiplier));
}
@ -105,7 +105,7 @@
transition: background-color var(--layout-transition-speed-fast) ease-in-out, height var(--layout-transition-speed-fast) ease-in-out, box-shadow var(--layout-transition-speed-fast) ease-in-out;
}
.is-link-item-line .link-panel-front {
.is-link-item-line-show .link-panel-front {
height: calc(100% - var(--layout-line-width));
}
@ -247,14 +247,14 @@
transition: height var(--layout-transition-speed-fast) ease-in-out, top var(--layout-transition-speed-fast) ease-in-out;
}
.is-link-item-line .link-panel-back {
.is-link-item-line-show .link-panel-back {
height: calc(100% - var(--layout-line-width));
}
.is-link-edit .link-panel-back,
.is-link-url-show:not(.is-link-item-line) .link-item:focus .link-panel-back,
.is-link-url-show:not(.is-link-item-line) .link-item:focus-within .link-panel-back,
.is-link-url-show:not(.is-link-item-line) .link-item:hover .link-panel-back {
.is-link-url-show:not(.is-link-item-line-show) .link-item:focus .link-panel-back,
.is-link-url-show:not(.is-link-item-line-show) .link-item:focus-within .link-panel-back,
.is-link-url-show:not(.is-link-item-line-show) .link-item:hover .link-panel-back {
height: 100%;
top: 0;
clip-path: polygon(0 var(--layout-line-width), 100% var(--layout-line-width), 100% 100%, 0 100%);

View File

@ -184,12 +184,12 @@
</div>
<div class="menu-item-form">
<div class="input-wrap">
<input id="control-layout-order-headerLink" class="control-layout-order-headerLink" type="radio" name="control-layout-order" value="headerLink" tabindex="1">
<label for="control-layout-order-headerLink">Header then Bookmarks</label>
<input id="control-layout-order-headerlink" class="control-layout-order-headerlink" type="radio" name="control-layout-order" value="headerlink" tabindex="1">
<label for="control-layout-order-headerlink">Header then Bookmarks</label>
</div>
<div class="input-wrap">
<input id="control-layout-order-linkHeader" class="control-layout-order-linkHeader" type="radio" name="control-layout-order" value="linkHeader" tabindex="1">
<label for="control-layout-order-linkHeader">Bookmarks then Header</label>
<input id="control-layout-order-linkheader" class="control-layout-order-linkheader" type="radio" name="control-layout-order" value="linkheader" tabindex="1">
<label for="control-layout-order-linkheader">Bookmarks then Header</label>
<p class="input-helper small muted">Only available when Bookmarks are shown.</p>
</div>
</div>
@ -227,8 +227,8 @@
</div>
<hr>
<div class="input-wrap">
<input id="control-layout-scroll-past-end" class="control-layout-scroll-past-end" type="checkbox" tabindex="1">
<label for="control-layout-scroll-past-end">Scroll past end</label>
<input id="control-layout-scrollpastend" class="control-layout-scrollpastend" type="checkbox" tabindex="1">
<label for="control-layout-scrollpastend">Scroll past end</label>
</div>
</div>
</div>
@ -618,7 +618,7 @@
<div class="input-wrap">
<input id="control-header-search-engine-bing" class="control-header-search-engine-bing" type="radio" name="control-header-search-engine" value="bing" tabindex="1">
<label for="control-header-search-engine-bing">Bing</label>
</div>
</div>
<div class="input-wrap">
<input id="control-header-search-engine-custom" class="control-header-search-engine-custom" type="radio" name="control-header-search-engine" value="custom" tabindex="1">
<label for="control-header-search-engine-custom">Custom</label>
@ -681,8 +681,8 @@
</div>
<hr>
<div class="input-wrap">
<input id="control-header-button-edit-add-show" class="control-header-button-edit-add-show" type="checkbox" tabindex="1">
<label for="control-header-button-edit-add-show">Show Edit/Add</label>
<input id="control-header-button-editadd-show" class="control-header-button-editadd-show" type="checkbox" tabindex="1">
<label for="control-header-button-editadd-show">Show Edit/Add</label>
</div>
<hr>
<div class="input-wrap">
@ -803,57 +803,6 @@
<button class="control-link-item-size-default button mb-0" tabindex="1">Default tile size</button>
</div>
<hr>
<div class="input-wrap">
<input id="control-link-item-display-show" class="control-link-item-display-show" type="checkbox" tabindex="1">
<label for="control-link-item-display-show">Letter/Icon</label>
</div>
<div class="form-indent">
<div class="input-wrap">
<label for="control-link-item-display-letter-size">Letter size</label>
<input id="control-link-item-display-letter-size" class="control-link-item-display-letter-size" type="range" min="1" max="3000" value="0" tabindex="1">
</div>
<div class="button-wrap">
<button class="control-link-item-display-letter-size-default button mb-0" tabindex="1">Default letter size</button>
</div>
<hr>
<div class="input-wrap">
<label for="control-link-item-display-icon-size">Icon size</label>
<input id="control-link-item-display-icon-size" class="control-link-item-display-icon-size" type="range" min="1" max="3000" value="0" tabindex="1">
</div>
<div class="button-wrap">
<button class="control-link-item-display-icon-size-default button mb-0" tabindex="1">Default icon size</button>
</div>
</div>
<hr>
<div class="input-wrap">
<input id="control-link-item-name-show" class="control-link-item-name-show" type="checkbox" tabindex="1">
<label for="control-link-item-name-show">Name</label>
<div class="form-indent">
<div class="input-wrap">
<label for="control-link-item-name-size">Name size</label>
<input id="control-link-item-name-size" class="control-link-item-name-size" type="range" min="1" max="1500" value="0" tabindex="1">
</div>
<div class="button-wrap">
<button class="control-link-item-name-size-default button mb-0" tabindex="1">Default icon size</button>
</div>
</div>
</div>
<hr>
<div class="input-wrap">
<input id="control-link-item-url-show" class="control-link-item-url-show" type="checkbox" tabindex="1">
<label for="control-link-item-url-show">URL on hover</label>
</div>
<hr>
<div class="input-wrap">
<input id="control-link-item-line" class="control-link-item-line" type="checkbox" tabindex="1">
<label for="control-link-item-line">Tile line</label>
</div>
<hr>
<div class="input-wrap">
<input id="control-link-item-hover-scale" class="control-link-item-hover-scale" type="checkbox" tabindex="1">
<label for="control-link-item-hover-scale">Grow on hover</label>
</div>
<hr>
<label class="control-link-item-display-alignment-label">Content Alignment</label>
<div class="form-grid-wrap">
<div class="form-grid form-grid-3x3 form-grid-square control-link-item-display-alignment-grid" tabindex="-1">
@ -895,17 +844,62 @@
</div>
</div>
</div>
</div>
</div>
</div>
<div class="menu-item">
<div class="menu-item-header">
<h1 class="menu-item-header-text">Open</h1>
</div>
<div class="menu-item-form">
<div class="input-wrap">
<input id="control-link-new-tab" class="control-link-new-tab" type="checkbox" tabindex="1">
<label for="control-link-new-tab">In a new tab</label>
<hr>
<div class="input-wrap">
<input id="control-link-item-display-show" class="control-link-item-display-show" type="checkbox" tabindex="1">
<label for="control-link-item-display-show">Letter/Icon</label>
</div>
<div class="form-indent">
<div class="input-wrap">
<label for="control-link-item-display-letter-size">Letter size</label>
<input id="control-link-item-display-letter-size" class="control-link-item-display-letter-size" type="range" min="1" max="3000" value="0" tabindex="1">
</div>
<div class="button-wrap">
<button class="control-link-item-display-letter-size-default button mb-0" tabindex="1">Default letter size</button>
</div>
<hr>
<div class="input-wrap">
<label for="control-link-item-display-icon-size">Icon size</label>
<input id="control-link-item-display-icon-size" class="control-link-item-display-icon-size" type="range" min="1" max="3000" value="0" tabindex="1">
</div>
<div class="button-wrap">
<button class="control-link-item-display-icon-size-default button mb-0" tabindex="1">Default icon size</button>
</div>
</div>
<hr>
<div class="input-wrap">
<input id="control-link-item-name-show" class="control-link-item-name-show" type="checkbox" tabindex="1">
<label for="control-link-item-name-show">Name</label>
<div class="form-indent">
<div class="input-wrap">
<label for="control-link-item-name-size">Name size</label>
<input id="control-link-item-name-size" class="control-link-item-name-size" type="range" min="1" max="1500" value="0" tabindex="1">
</div>
<div class="button-wrap">
<button class="control-link-item-name-size-default button mb-0" tabindex="1">Default icon size</button>
</div>
</div>
</div>
<hr>
<div class="input-wrap">
<input id="control-link-item-url-show" class="control-link-item-url-show" type="checkbox" tabindex="1">
<label for="control-link-item-url-show">URL on tile hover</label>
</div>
<hr>
<div class="input-wrap">
<input id="control-link-item-line-show" class="control-link-item-line-show" type="checkbox" tabindex="1">
<label for="control-link-item-line-show">Tile line</label>
</div>
<hr>
<div class="input-wrap">
<input id="control-link-item-hover-scale" class="control-link-item-hover-scale" type="checkbox" tabindex="1">
<label for="control-link-item-hover-scale">Grow tile on hover</label>
</div>
<hr>
<div class="input-wrap">
<input id="control-link-newtab" class="control-link-newtab" type="checkbox" tabindex="1">
<label for="control-link-newtab">Open Bookmarks in a new tab</label>
</div>
</div>
</div>
</div>

View File

@ -141,7 +141,7 @@ var control = (function() {
render();
}
}, {
element: helper.e(".control-layout-order-headerLink"),
element: helper.e(".control-layout-order-headerlink"),
path: "layout.order",
type: "radio",
func: function() {
@ -150,7 +150,7 @@ var control = (function() {
render();
}
}, {
element: helper.e(".control-layout-order-linkHeader"),
element: helper.e(".control-layout-order-linkheader"),
path: "layout.order",
type: "radio",
func: function() {
@ -258,7 +258,7 @@ var control = (function() {
title.render();
}
}, {
element: helper.e(".control-layout-scroll-past-end"),
element: helper.e(".control-layout-scrollpastend"),
path: "layout.scrollPastEnd",
type: "checkbox",
func: function() {
@ -1424,7 +1424,7 @@ var control = (function() {
header.render.button.style();
}
}, {
element: helper.e(".control-header-button-edit-add-show"),
element: helper.e(".control-header-button-editadd-show"),
path: "header.button.editAdd.show",
type: "checkbox",
func: function() {
@ -1817,15 +1817,15 @@ var control = (function() {
}
}, {
element: helper.e(".control-link-item-url-show"),
path: "link.item.url",
path: "link.item.url.show",
type: "checkbox",
func: function() {
render();
dependents();
}
}, {
element: helper.e(".control-link-item-line"),
path: "link.item.line",
element: helper.e(".control-link-item-line-show"),
path: "link.item.line.show",
type: "checkbox",
func: function() {
render();
@ -1901,7 +1901,7 @@ var control = (function() {
render();
}
}, {
element: helper.e(".control-link-new-tab"),
element: helper.e(".control-link-newtab"),
path: "link.newTab",
type: "checkbox",
func: function() {
@ -2286,14 +2286,12 @@ var control = (function() {
helper.e(".control-header-search-engine-custom-name").value = state.get().header.search.engine.custom.name;
helper.e(".control-header-search-engine-custom-url").value = state.get().header.search.engine.custom.url;
};
var _editAdd = function() {
var _button = function() {
if (state.get().header.button.editAdd.show) {
helper.addClass(html, "is-header-button-edit-add-show");
helper.addClass(html, "is-header-button-editadd-show");
} else {
helper.removeClass(html, "is-header-button-edit-add-show");
helper.removeClass(html, "is-header-button-editadd-show");
};
};
var _accent = function() {
if (state.get().header.button.accent.show) {
helper.addClass(html, "is-header-button-accent-show");
} else {
@ -2340,8 +2338,7 @@ var control = (function() {
_clock();
_date();
_search();
_editAdd();
_accent();
_button();
_shade();
_border();
_greeting();
@ -2364,7 +2361,7 @@ var control = (function() {
helper.removeClass(html, "is-link-display-alignment-bottomcenter");
helper.removeClass(html, "is-link-display-alignment-bottomright");
helper.removeClass(html, "is-link-url-show");
helper.removeClass(html, "is-link-item-line");
helper.removeClass(html, "is-link-item-line-show");
helper.removeClass(html, "is-link-item-hover-scale");
helper.removeClass(html, "is-link-item-alignment-left");
helper.removeClass(html, "is-link-item-alignment-center");
@ -2384,11 +2381,11 @@ var control = (function() {
if (state.get().link.item.display.show) {
helper.addClass(html, "is-link-display-show");
};
if (state.get().link.item.url) {
if (state.get().link.item.url.show) {
helper.addClass(html, "is-link-url-show");
};
if (state.get().link.item.line) {
helper.addClass(html, "is-link-item-line");
if (state.get().link.item.line.show) {
helper.addClass(html, "is-link-item-line-show");
};
if (state.get().link.item.hoverScale) {
helper.addClass(html, "is-link-item-hover-scale");
@ -2400,7 +2397,7 @@ var control = (function() {
};
};
var _layout = function() {
helper.removeClass(html, "is-layout-scroll-past-end");
helper.removeClass(html, "is-layout-scrollpastend");
helper.removeClass(html, "is-layout-alignment-topleft");
helper.removeClass(html, "is-layout-alignment-topcenter");
helper.removeClass(html, "is-layout-alignment-topright");
@ -2410,12 +2407,12 @@ var control = (function() {
helper.removeClass(html, "is-layout-alignment-bottomleft");
helper.removeClass(html, "is-layout-alignment-bottomcenter");
helper.removeClass(html, "is-layout-alignment-bottomright");
helper.removeClass(html, "is-layout-order-headerLink");
helper.removeClass(html, "is-layout-order-linkHeader");
helper.removeClass(html, "is-layout-order-headerlink");
helper.removeClass(html, "is-layout-order-linkheader");
helper.addClass(html, "is-layout-alignment-" + state.get().layout.alignment);
helper.addClass(html, "is-layout-order-" + state.get().layout.order);
if (state.get().layout.scrollPastEnd) {
helper.addClass(html, "is-layout-scroll-past-end");
helper.addClass(html, "is-layout-scrollpastend");
};
};
var _theme = function() {
@ -2725,8 +2722,8 @@ var control = (function() {
};
};
var _link = function() {
helper.e(".control-layout-order-headerLink").disabled = true;
helper.e(".control-layout-order-linkHeader").disabled = true;
helper.e(".control-layout-order-headerlink").disabled = true;
helper.e(".control-layout-order-linkheader").disabled = true;
helper.e("[for=control-link-area-width]").setAttribute("disabled", "");
helper.e(".control-link-area-width").disabled = true;
helper.e(".control-link-area-width-match").disabled = true;
@ -2750,7 +2747,7 @@ var control = (function() {
helper.e(".control-link-item-name-size").disabled = true;
helper.e(".control-link-item-name-size-default").disabled = true;
helper.e(".control-link-item-url-show").disabled = true;
helper.e(".control-link-item-line").disabled = true;
helper.e(".control-link-item-line-show").disabled = true;
helper.e(".control-link-item-hover-scale").disabled = true;
helper.e(".control-link-item-display-alignment-grid").setAttribute("disabled", "");
helper.e(".control-link-item-display-alignment-label").setAttribute("disabled", "");
@ -2763,7 +2760,7 @@ var control = (function() {
helper.e(".control-link-item-display-alignment-bottomleft").disabled = true;
helper.e(".control-link-item-display-alignment-bottomcenter").disabled = true;
helper.e(".control-link-item-display-alignment-bottomright").disabled = true;
helper.e(".control-link-new-tab").disabled = true;
helper.e(".control-link-newtab").disabled = true;
helper.e(".control-link-style-block").disabled = true;
helper.e(".control-link-style-list").disabled = true;
helper.e(".control-link-sort-name").disabled = true;
@ -2772,8 +2769,8 @@ var control = (function() {
helper.e(".control-link-accent-clear").disabled = true;
helper.e(".control-link-accent-set").disabled = true;
if (state.get().link.show) {
helper.e(".control-layout-order-headerLink").disabled = false;
helper.e(".control-layout-order-linkHeader").disabled = false;
helper.e(".control-layout-order-headerlink").disabled = false;
helper.e(".control-layout-order-linkheader").disabled = false;
helper.e("[for=control-link-area-width]").removeAttribute("disabled");
helper.e(".control-link-area-width").disabled = false;
helper.e(".control-link-area-width-match").disabled = false;
@ -2788,9 +2785,9 @@ var control = (function() {
helper.e(".control-link-item-display-show").disabled = false;
helper.e(".control-link-item-name-show").disabled = false;
helper.e(".control-link-item-url-show").disabled = false;
helper.e(".control-link-item-line").disabled = false;
helper.e(".control-link-item-line-show").disabled = false;
helper.e(".control-link-item-hover-scale").disabled = false;
helper.e(".control-link-new-tab").disabled = false;
helper.e(".control-link-newtab").disabled = false;
helper.e(".control-link-style-block").disabled = false;
helper.e(".control-link-style-list").disabled = false;
helper.e(".control-link-sort-name").disabled = false;

View File

@ -98,7 +98,7 @@ var header = (function() {
} else {
helper.removeClass(html, "is-header-shade-style-scroll");
};
} else if (state.get().layout.order == "linkHeader") {
} else if (state.get().layout.order == "linkheader") {
// check scroll position
if (scrollTop < (scrollHeight - innerHeight) - (fontSize * 2)) {
helper.addClass(html, "is-header-shade-style-scroll");

View File

@ -35,9 +35,9 @@ var layout = (function() {
var layout = helper.e(".layout");
var header = helper.e(".header");
var link = helper.e(".link");
if (state.get().layout.order == "headerLink") {
if (state.get().layout.order == "headerlink") {
layout.insertBefore(header, link);
} else if (state.get().layout.order == "linkHeader") {
} else if (state.get().layout.order == "linkheader") {
layout.insertBefore(link, header);
};
};

View File

@ -151,19 +151,25 @@ var state = (function() {
show: true,
size: 0.9,
},
url: true,
url: {
show: true
},
line: {
show: true
},
hoverScale: {
show: true
},
size: 1,
line: true,
hoverScale: true
newTab: false
},
show: true,
newTab: false,
edit: false,
style: "block"
},
layout: {
alignment: "centercenter",
order: "headerLink",
order: "headerlink",
padding: 4,
gutter: 2,
width: 80,

View File

@ -547,6 +547,23 @@ var update = (function() {
name: "Bing"
};
return data;
},
"3.29.0": function(data) {
// move new tab into link
data.state.link.item.newTab = data.state.link.newTab;
delete data.state.link.newTab;
// bring url and line inline with other show controls
data.state.link.item.url = {
show: data.state.link.item.url
};
data.state.link.item.line = {
show: data.state.link.item.line
};
data.state.link.item.hoverScale = {
show: data.state.link.item.hoverScale
};
data.state.layout.order = data.state.layout.order.toLowerCase();
return data;
}
};