add favicon control

This commit is contained in:
zombieFox 2021-09-16 22:25:50 +01:00
parent d87b87d19e
commit e3dbf21e5e
5 changed files with 43 additions and 1 deletions

View File

@ -196,6 +196,24 @@ layout.title = {
}
};
layout.favicon = {
render: () => {
const favicon = document.querySelector('.favicon');
if (isValidString(state.get.current().layout.favicon)) {
favicon.href = trimString(state.get.current().layout.favicon);
} else {
favicon.href = trimString('icon/favicon.svg');
};
}
};
layout.init = () => {
applyCSSVar([
'layout.size',
@ -218,6 +236,7 @@ layout.init = () => {
]);
layout.area.render();
layout.title.render();
layout.favicon.render();
};
export { layout };

View File

@ -447,6 +447,24 @@ layoutSetting.page = (parent) => {
}
});
layoutSetting.control.page.favicon = new Control_textReset({
object: state.get.current(),
path: 'layout.favicon',
id: 'layout-favicon',
value: state.get.current().layout.favicon,
defaultValue: state.get.default().layout.favicon,
placeholder: 'https://www.example.com/favicon.svg',
labelText: 'Favicon URL',
action: () => {
layout.favicon.render();
data.save();
}
});
layoutSetting.control.page.faviconHelper = new Control_helperText({
text: ['Not supported by all browsers.']
});
layoutSetting.control.page.scrollbar = new Control_radio({
object: state.get.current(),
label: 'Scrollbar',
@ -481,6 +499,8 @@ layoutSetting.page = (parent) => {
parent.appendChild(
node('div', [
layoutSetting.control.page.title.wrap(),
layoutSetting.control.page.favicon.wrap(),
layoutSetting.control.page.faviconHelper.wrap(),
node('hr'),
layoutSetting.control.page.scrollbar.inline(),
layoutSetting.control.page.scrollbarHelper.wrap(),

View File

@ -18,6 +18,7 @@ state.default = {
breakpoint: 'xs',
scrollbar: 'auto',
title: '',
favicon: '',
overscroll: false
},
header: {

View File

@ -575,6 +575,8 @@ update.mod['7.0.0'] = function(data) {
update.mod['7.1.0'] = function(data) {
data.state.layout.favicon = '';
data.state.group.toolbar = data.state.group.openAll;
delete data.state.group.openAll;

View File

@ -9,7 +9,7 @@
<title>New Tab</title>
<link rel="icon" type="image/svg+xml" href="icon/favicon.svg" />
<link rel="icon" type="image/svg+xml" class="favicon" href="icon/favicon.svg" />
<style media="screen" type="text/css">html,body {background-color: rgb(0, 0, 0);}@media (prefers-color-scheme: dark) {html,body {background-color: rgb(0, 0, 0);}}@media (prefers-color-scheme: light) {html,body {background-color: rgb(255, 255, 255);}}</style>