mirror of
https://github.com/monkeytypegame/monkeytype.git
synced 2025-09-18 20:49:38 +08:00
Added functionality to add background image and background size
This commit is contained in:
parent
ed8eab4c66
commit
643ecf6a00
3 changed files with 43 additions and 1 deletions
|
@ -113,6 +113,8 @@ let defaultConfig = {
|
|||
monkey: false,
|
||||
repeatQuotes: "off",
|
||||
oppositeShiftMode: "off",
|
||||
customBackground: "https://i.imgur.com/OWbWz6i.jpg",
|
||||
customBackgroundSize: "cover",
|
||||
};
|
||||
|
||||
function isConfigKeyValid(name) {
|
||||
|
@ -1343,6 +1345,24 @@ export function setFontSize(fontSize, nosave) {
|
|||
if (!nosave) saveToCookie();
|
||||
}
|
||||
|
||||
export function setCustomBackground(value, nosave) {
|
||||
if (value == null || value == undefined) {
|
||||
value = "";
|
||||
}
|
||||
config.customBackground = value;
|
||||
ThemeController.applyCustomBackground();
|
||||
if (!nosave) saveToCookie();
|
||||
}
|
||||
|
||||
export function setCustomBackgroundSize(value, nosave) {
|
||||
if (value != "cover" && value != "contain"){
|
||||
value = "cover";
|
||||
}
|
||||
config.customBackgroundSize = value;
|
||||
ThemeController.applyCustomBackgroundSize();
|
||||
if (!nosave) saveToCookie();
|
||||
}
|
||||
|
||||
export function apply(configObj) {
|
||||
if (configObj == null || configObj == undefined) {
|
||||
Notifications.add("Could not apply config", -1, 3);
|
||||
|
@ -1357,6 +1377,8 @@ export function apply(configObj) {
|
|||
setTheme(configObj.theme, true);
|
||||
setCustomThemeColors(configObj.customThemeColors, true);
|
||||
setCustomTheme(configObj.customTheme, true, true);
|
||||
setCustomBackground(configObj.customBackground, true);
|
||||
setCustomBackgroundSize(configObj.customBackgroundSize, true);
|
||||
setQuickTabMode(configObj.quickTab, true);
|
||||
setKeyTips(configObj.showKeyTips, true);
|
||||
setTimeConfig(configObj.time, true);
|
||||
|
|
|
@ -4,6 +4,7 @@ import * as Misc from "./misc";
|
|||
import * as Notifications from "./notifications";
|
||||
import Config from "./config";
|
||||
import * as UI from "./ui";
|
||||
import config from "./config";
|
||||
|
||||
let isPreviewingTheme = false;
|
||||
let randomTheme = null;
|
||||
|
@ -149,3 +150,22 @@ export function randomiseTheme() {
|
|||
export function clearRandom() {
|
||||
randomTheme = null;
|
||||
}
|
||||
|
||||
export function applyCustomBackground(){
|
||||
if (Config.customBackground != ""){
|
||||
$("body").css({
|
||||
backgroundImage: `url(${Config.customBackground})`,
|
||||
backgroundRepeat: "no-repeat",
|
||||
backgroundPosition: "center center",
|
||||
backgroundAttachment: "fixed",
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
export function applyCustomBackgroundSize(){
|
||||
if (Config.customBackgroundSize != ""){
|
||||
$("body").css({
|
||||
backgroundSize: Config.customBackgroundSize,
|
||||
})
|
||||
}
|
||||
}
|
|
@ -107,10 +107,10 @@ body {
|
|||
margin: 0;
|
||||
padding: 0;
|
||||
min-height: 100vh;
|
||||
background: var(--bg-color);
|
||||
font-family: var(--font);
|
||||
color: var(--main-color);
|
||||
overflow-x: hidden;
|
||||
background: var(--bg-color);
|
||||
}
|
||||
|
||||
html {
|
||||
|
|
Loading…
Add table
Reference in a new issue