Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: refresh the background image at an interval #416

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/component/customThemeTile/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ export const CustomThemeTile = function({

theme.font.ui.load();

theme.background.image.render();
theme.background.image.load();

theme.background.video.clear();

Expand Down
31 changes: 29 additions & 2 deletions src/component/menuContent/themeSetting/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ themeSetting.disable = () => {
themeSetting.control.background.image.opacity.disable();
themeSetting.control.background.image.vignette.opacity.disable();
themeSetting.control.background.image.vignette.range.disable();
themeSetting.control.background.image.refresh.disable();
themeSetting.control.background.video.url.disable();
themeSetting.control.background.video.urlHelper.disable();
themeSetting.control.background.video.blur.disable();
Expand All @@ -136,6 +137,7 @@ themeSetting.disable = () => {
themeSetting.control.background.image.opacity.disable();
themeSetting.control.background.image.vignette.opacity.disable();
themeSetting.control.background.image.vignette.range.disable();
themeSetting.control.background.image.refresh.disable();
themeSetting.control.background.video.url.disable();
themeSetting.control.background.video.urlHelper.disable();
themeSetting.control.background.video.blur.disable();
Expand All @@ -161,6 +163,7 @@ themeSetting.disable = () => {
themeSetting.control.background.image.opacity.disable();
themeSetting.control.background.image.vignette.opacity.disable();
themeSetting.control.background.image.vignette.range.disable();
themeSetting.control.background.image.refresh.disable();
themeSetting.control.background.video.url.disable();
themeSetting.control.background.video.urlHelper.disable();
themeSetting.control.background.video.blur.disable();
Expand All @@ -186,6 +189,7 @@ themeSetting.disable = () => {
themeSetting.control.background.image.opacity.enable();
themeSetting.control.background.image.vignette.opacity.enable();
themeSetting.control.background.image.vignette.range.enable();
themeSetting.control.background.image.refresh.enable();
themeSetting.control.background.video.url.disable();
themeSetting.control.background.video.urlHelper.disable();
themeSetting.control.background.video.blur.disable();
Expand All @@ -211,6 +215,7 @@ themeSetting.disable = () => {
themeSetting.control.background.image.opacity.disable();
themeSetting.control.background.image.vignette.opacity.disable();
themeSetting.control.background.image.vignette.range.disable();
themeSetting.control.background.image.refresh.disable();
themeSetting.control.background.video.url.enable();
themeSetting.control.background.video.urlHelper.enable();
themeSetting.control.background.video.blur.enable();
Expand Down Expand Up @@ -1517,7 +1522,27 @@ themeSetting.background = (parent) => {
}
}
})
}
},
refresh: new Control_sliderSlim({
object: state.get.current(),
path: 'theme.background.image.refresh',
id: 'theme-background-image-refresh',
labelText: message.get('menuContentThemeBackgroundImageRefresh'),
value: state.get.current().theme.background.image.refresh,
defaultValue: state.get.default().theme.background.image.refresh,
min: state.get.minMax().theme.background.image.refresh.min,
max: state.get.minMax().theme.background.image.refresh.max,
action: () => {
theme.background.image.delay();
applyCSSVar('theme.background.image.refresh');
data.save();
}
}),
refreshHelper: new Control_helperText({
text: [
message.get('menuContentThemeBackgroundImageRefreshHelperPara1')
]
})
},
video: {
alert: new Alert({
Expand Down Expand Up @@ -1695,7 +1720,9 @@ themeSetting.background = (parent) => {
]
})
]
})
}),
themeSetting.control.background.image.refresh.wrap(),
themeSetting.control.background.image.refreshHelper.wrap()
]);

const themeBackgroundVideoArea = node('div', [
Expand Down
2 changes: 1 addition & 1 deletion src/component/presetThemeTile/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ export const PresetThemeTile = function ({

theme.font.ui.load();

theme.background.image.render();
theme.background.image.load();

theme.background.video.clear();

Expand Down
4 changes: 2 additions & 2 deletions src/component/state/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ state.default = {
start: { hsl: { h: 206, s: 16, l: 40 }, rgb: { r: 86, g: 104, b: 118 } },
end: { hsl: { h: 219, s: 28, l: 12 }, rgb: { r: 22, g: 28, b: 39 } }
},
image: { url: '', blur: 0, grayscale: 0, scale: 100, accent: 0, opacity: 100, vignette: { opacity: 0, start: 90, end: 70 } },
image: { url: '', blur: 0, grayscale: 0, scale: 100, accent: 0, opacity: 100, vignette: { opacity: 0, start: 90, end: 70 }, refresh: 0 },
video: { url: '', blur: 0, grayscale: 0, scale: 100, accent: 0, opacity: 100, vignette: { opacity: 0, start: 90, end: 70 } }
},
opacity: { general: 100 },
Expand Down Expand Up @@ -202,7 +202,7 @@ state.minMax = {
rgb: { r: { min: 0, max: 255 }, g: { min: 0, max: 255 }, b: { min: 0, max: 255 } }
},
},
image: { blur: { min: 0, max: 200 }, grayscale: { min: 0, max: 100 }, scale: { min: 100, max: 400 }, accent: { min: 0, max: 100 }, opacity: { min: 0, max: 100 }, vignette: { opacity: { min: 0, max: 100 }, start: { min: 0, max: 100 }, end: { min: 0, max: 100 } } },
image: { blur: { min: 0, max: 200 }, grayscale: { min: 0, max: 100 }, scale: { min: 100, max: 400 }, accent: { min: 0, max: 100 }, opacity: { min: 0, max: 100 }, vignette: { opacity: { min: 0, max: 100 }, start: { min: 0, max: 100 }, end: { min: 0, max: 100 } }, refresh: { min: 0, max: 1440 } },
video: { blur: { min: 0, max: 200 }, grayscale: { min: 0, max: 100 }, scale: { min: 100, max: 400 }, accent: { min: 0, max: 100 }, opacity: { min: 0, max: 100 }, vignette: { opacity: { min: 0, max: 100 }, start: { min: 0, max: 100 }, end: { min: 0, max: 100 } } }
},
radius: { min: 0, max: 500 },
Expand Down
26 changes: 25 additions & 1 deletion src/component/theme/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -383,6 +383,30 @@ theme.background.area = {
};

theme.background.image = {
timer: false,
delay: () => {

if (theme.background.image.timer) {
clearTimeout(theme.background.image.timer);

theme.background.image.timer = false;
}

const timeout = state.get.current().theme.background.image.refresh;

if (timeout) {
theme.background.image.timer = setInterval(() => {
theme.background.image.render();
}, timeout * 1000 * 60);
}

},
load: () => {

theme.background.image.delay();
theme.background.image.render();

},
render: () => {

const html = document.querySelector('html');
Expand Down Expand Up @@ -448,7 +472,7 @@ theme.init = () => {
theme.font.display.load();
theme.font.ui.load();
theme.background.area.render();
theme.background.image.render();
theme.background.image.load();
theme.background.video.render();
applyCSSVar([
'theme.accent.rgb.r',
Expand Down
8 changes: 8 additions & 0 deletions src/component/update/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -627,6 +627,14 @@ update.mod['7.5.0'] = function(data) {

};

update.mod['7.6.0'] = function(data) {

data.state.theme.background.image.refresh = 0;

return data;

};

update.run = (data) => {

// loop over all updates in mod.all object
Expand Down
2 changes: 1 addition & 1 deletion src/component/version/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
export const version = {};

version.number = '7.5.0';
version.number = '7.6.0';

version.name = 'Delightful Komodo Dragon';

Expand Down
8 changes: 8 additions & 0 deletions src/locale/en_GB/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -707,6 +707,14 @@
"message": "Shade start",
"description": "Range for image vignette right."
},
"menuContentThemeBackgroundImageRefresh": {
"message": "Refresh",
"description": "Range background image refresh."
},
"menuContentThemeBackgroundImageRefreshHelperPara1": {
"message": "Load a random background image upon every refresh (in minutes).",
"description": "Helper text for background image refresh."
},
"menuContentThemeBackgroundVideoAlertPara1": {
"message": "YouTube page URLs can not be used.",
"description": "Alert for video background."
Expand Down
2 changes: 1 addition & 1 deletion src/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "__MSG_appName__",
"short_name": "__MSG_appShortName__",
"description": "__MSG_appDescription__",
"version": "7.5.0",
"version": "7.6.0",
"manifest_version": 2,
"default_locale": "en_GB",
"chrome_url_overrides": {
Expand Down