Refactor on App

pull/104/head
mertsincan 2019-10-22 15:38:18 +03:00
parent ff1dcbabfc
commit b7fafa647c
2 changed files with 37 additions and 8 deletions

View File

@ -56,23 +56,38 @@ export default {
let themeElement = document.getElementById('theme-link'); let themeElement = document.getElementById('theme-link');
themeElement.setAttribute('href', themeElement.getAttribute('href').replace(this.theme, theme)); themeElement.setAttribute('href', themeElement.getAttribute('href').replace(this.theme, theme));
this.theme = theme; this.theme = theme;
const hasBodyDarkTheme = this.hasClass(document.body, 'dark-theme');
if (dark) { if (dark) {
if (!this.darkDemoStyle) { if (!hasBodyDarkTheme) {
this.darkDemoStyle = document.createElement('style'); this.addClass(document.body, 'dark-theme');
this.darkDemoStyle.type = 'text/css';
this.darkDemoStyle.innerHTML = '.implementation { background-color: #3f3f3f !important; color: #dedede !important} .implementation > h3, .implementation > h4{ color: #dedede !important}';
document.body.appendChild(this.darkDemoStyle);
} }
} }
else if(this.darkDemoStyle) { else if(hasBodyDarkTheme) {
document.body.removeChild(this.darkDemoStyle); this.removeClass(document.body, 'dark-theme');
this.darkDemoStyle = null;
} }
this.hideThemesMenu(); this.hideThemesMenu();
event.preventDefault(); event.preventDefault();
}, },
addClass(element, className) {
if (element.classList)
element.classList.add(className);
else
element.className += ' ' + className;
},
removeClass(element, className) {
if (element.classList)
element.classList.remove(className);
else
element.className = element.className.replace(new RegExp('(^|\\b)' + className.split(' ').join('|') + '(\\b|$)', 'gi'), ' ');
},
hasClass(element, className) {
if (element.classList)
return element.classList.contains(className);
else
return new RegExp('(^| )' + className + '( |$)', 'gi').test(element.className);
},
toggleThemesMenu(event) { toggleThemesMenu(event) {
this.themesMenuVisible = !this.themesMenuVisible; this.themesMenuVisible = !this.themesMenuVisible;
event.preventDefault(); event.preventDefault();

View File

@ -649,6 +649,7 @@ body {
.p-tabview-panels { .p-tabview-panels {
background: transparent; background: transparent;
border: 0 none; border: 0 none;
color: #484848;
} }
} }
} }
@ -1134,3 +1135,16 @@ pre[class*="language-"] code {
.p-toast.p-toast-topleft { .p-toast.p-toast-topleft {
top: 100px; top: 100px;
} }
/* Dark Theme such as luna-amber, luna-blue, luna-green and luna-pink */
.dark-theme {
.implementation {
background-color: #3f3f3f !important;
color: #dedede !important;
> h3,
> h4 {
color: #dedede !important
}
}
}