live-preview of selected theme on profile-page

This commit is contained in:
Felix Hamann 2018-07-01 09:43:44 +02:00
parent cb25009493
commit f1806ffed2
3 changed files with 28 additions and 12 deletions

View File

@ -31,7 +31,7 @@ makeSettingForm template = identForm FIDsettings $ \html -> do
<$> areq (natFieldI $ MsgNatField "Favoriten") -- TODO: natFieldI not working here <$> areq (natFieldI $ MsgNatField "Favoriten") -- TODO: natFieldI not working here
(fslpI MsgFavoriten "Anzahl Favoriten") (stgMaxFavourties <$> template) (fslpI MsgFavoriten "Anzahl Favoriten") (stgMaxFavourties <$> template)
<*> areq (selectFieldList themeList) <*> areq (selectFieldList themeList)
(fslI MsgTheme ) (stgTheme <$> template) (fslpI MsgTheme "theme-select" ) (stgTheme <$> template) -- TODO: pass theme-select as id-attribute or similar.
<* submitButton <* submitButton
return (result, widget) -- no validation required here return (result, widget) -- no validation required here

View File

@ -232,6 +232,7 @@ derivePersistField "StudyFieldType"
-- Skins / Themes -- Skins / Themes
data Theme --Simply add Themes to this type only. CamelCase will be converted to "-lower" data Theme --Simply add Themes to this type only. CamelCase will be converted to "-lower"
= Default = Default
| Lavender
| NeutralBlue | NeutralBlue
| AberdeenReds | AberdeenReds
| MintGreen | MintGreen
@ -258,5 +259,3 @@ instance Default Theme where
-} -}
derivePersistField "Theme" derivePersistField "Theme"

17
templates/profile.julius Normal file
View File

@ -0,0 +1,17 @@
document.addEventListener('DOMContentLoaded', function () {
var themeSelector = document.querySelector('[placeholder="theme-select"]');
themeSelector.addEventListener('change', function() {
// get rid of old themes on body
var options = Array.from(themeSelector.options)
.forEach(function (option) {
document.body.classList.remove(optionToTheme(option));
});
// add newly selected theme
document.body.classList.add(optionToTheme(themeSelector.options[themeSelector.value - 1]));
});
function optionToTheme(option) {
return optionValue = 'theme--' + option.innerText.toLowerCase().trim().replace(/\s/g, '-');
}
});