Improve rendering banner about sleeping in the inn

See #10695
This commit is contained in:
Phillip Thelen
2018-09-19 16:38:40 +02:00
parent 33a8072d23
commit b953519e2d
2 changed files with 50 additions and 17 deletions

View File

@@ -17,8 +17,9 @@ div
template(v-if="isUserLoaded") template(v-if="isUserLoaded")
div.resting-banner(v-if="showRestingBanner") div.resting-banner(v-if="showRestingBanner")
span.content span.content
span.label {{ $t('innCheckOutBanner') }} span.label(v-if="!isNarrowScreen") {{ $t('innCheckOutBanner') }}
span.separator | span.label(v-if="isNarrowScreen") {{ $t('innCheckOutBannerShort') }}
span.separator |
span.resume(@click="resumeDamage()") {{ $t('resumeDamage') }} span.resume(@click="resumeDamage()") {{ $t('resumeDamage') }}
div.closepadding(@click="hideBanner()") div.closepadding(@click="hideBanner()")
span.svg-icon.inline.icon-10(aria-hidden="true", v-html="icons.close") span.svg-icon.inline.icon-10(aria-hidden="true", v-html="icons.close")
@@ -118,20 +119,9 @@ div
z-index: 1600 !important; /* Must stay above nav bar */ z-index: 1600 !important; /* Must stay above nav bar */
} }
.restingInn {
.navbar {
top: 40px;
}
#app-header {
margin-top: 40px !important;
}
}
.resting-banner { .resting-banner {
width: 100%; width: 100%;
height: 40px; min-height: 40px;
background-color: $blue-10; background-color: $blue-10;
position: fixed; position: fixed;
top: 0; top: 0;
@@ -139,11 +129,10 @@ div
display: flex; display: flex;
.content { .content {
height: 24px;
line-height: 1.71; line-height: 1.71;
text-align: center; text-align: center;
color: $white; color: $white;
padding: 8px 38px 8px 8px;
margin: auto; margin: auto;
} }
@@ -160,6 +149,13 @@ div
} }
} }
@media only screen and (max-width: 600px) {
.content {
font-size: 12px;
line-height: 1.4;
}
}
.separator { .separator {
color: $blue-100; color: $blue-100;
margin: 0px 15px; margin: 0px 15px;
@@ -168,6 +164,7 @@ div
.resume { .resume {
font-weight: bold; font-weight: bold;
cursor: pointer; cursor: pointer;
white-space:nowrap;
} }
} }
</style> </style>
@@ -246,6 +243,9 @@ export default {
showRestingBanner () { showRestingBanner () {
return !this.bannerHidden && this.user.preferences.sleep; return !this.bannerHidden && this.user.preferences.sleep;
}, },
isNarrowScreen () {
return screen.width <= 600;
},
}, },
created () { created () {
this.$root.$on('playSound', (sound) => { this.$root.$on('playSound', (sound) => {
@@ -414,6 +414,10 @@ export default {
document.title = title; document.title = title;
}); });
this.$store.watch(state => state.isUserLoaded, () => {
this.setBannerOffset();
});
this.$nextTick(() => { this.$nextTick(() => {
// Load external scripts after the app has been rendered // Load external scripts after the app has been rendered
Analytics.load(); Analytics.load();
@@ -442,6 +446,8 @@ export default {
// Load external scripts after the app has been rendered // Load external scripts after the app has been rendered
setupPayments(); setupPayments();
}); });
this.setBannerOffset();
}).catch((err) => { }).catch((err) => {
console.error('Impossible to fetch user. Clean up localStorage and refresh.', err); // eslint-disable-line no-console console.error('Impossible to fetch user. Clean up localStorage and refresh.', err); // eslint-disable-line no-console
}); });
@@ -463,6 +469,9 @@ export default {
const loadingScreen = document.getElementById('loading-screen'); const loadingScreen = document.getElementById('loading-screen');
if (loadingScreen) document.body.removeChild(loadingScreen); if (loadingScreen) document.body.removeChild(loadingScreen);
}, },
updated () {
this.setBannerOffset();
},
methods: { methods: {
checkForBannedUser (error) { checkForBannedUser (error) {
const AUTH_SETTINGS = localStorage.getItem('habit-mobile-settings'); const AUTH_SETTINGS = localStorage.getItem('habit-mobile-settings');
@@ -615,10 +624,33 @@ export default {
}, },
hideBanner () { hideBanner () {
this.bannerHidden = true; this.bannerHidden = true;
this.setBannerOffset();
}, },
resumeDamage () { resumeDamage () {
this.$store.dispatch('user:sleep'); this.$store.dispatch('user:sleep');
}, },
setBannerOffset () {
let restingBanner = document.getElementsByClassName('resting-banner')[0];
let contentPlacement = '0px';
if (!this.bannerHidden && restingBanner !== undefined) {
contentPlacement = `${restingBanner.clientHeight }px`;
}
let topMenu = document.getElementsByClassName('restingInn')[0];
if (topMenu !== undefined) {
let navbar = topMenu.getElementsByClassName('navbar')[0];
if (navbar !== undefined) {
navbar.style.top = contentPlacement;
}
}
let appHeader = document.getElementById('app-header');
if (appHeader !== undefined) {
appHeader.style.marginTop = contentPlacement;
}
let smartBanner = document.getElementsByClassName('smartbanner')[0];
if (smartBanner !== undefined) {
smartBanner.style.top = contentPlacement;
}
},
}, },
}; };
</script> </script>

View File

@@ -6,6 +6,7 @@
"innText": "You're resting in the Inn! While checked-in, your Dailies won't hurt you at the day's end, but they will still refresh every day. Be warned: If you are participating in a Boss Quest, the Boss will still damage you for your Party mates' missed Dailies unless they are also in the Inn! Also, your own damage to the Boss (or items collected) will not be applied until you check out of the Inn.", "innText": "You're resting in the Inn! While checked-in, your Dailies won't hurt you at the day's end, but they will still refresh every day. Be warned: If you are participating in a Boss Quest, the Boss will still damage you for your Party mates' missed Dailies unless they are also in the Inn! Also, your own damage to the Boss (or items collected) will not be applied until you check out of the Inn.",
"innTextBroken": "You're resting in the Inn, I guess... While checked-in, your Dailies won't hurt you at the day's end, but they will still refresh every day... If you are participating in a Boss Quest, the Boss will still damage you for your Party mates' missed Dailies... unless they are also in the Inn... Also, your own damage to the Boss (or items collected) will not be applied until you check out of the Inn... so tired...", "innTextBroken": "You're resting in the Inn, I guess... While checked-in, your Dailies won't hurt you at the day's end, but they will still refresh every day... If you are participating in a Boss Quest, the Boss will still damage you for your Party mates' missed Dailies... unless they are also in the Inn... Also, your own damage to the Boss (or items collected) will not be applied until you check out of the Inn... so tired...",
"innCheckOutBanner": "You are currently checked into the Inn. Your Dailies won't damage you and you won't make progress towards Quests.", "innCheckOutBanner": "You are currently checked into the Inn. Your Dailies won't damage you and you won't make progress towards Quests.",
"innCheckOutBannerShort": "You are checked into the Inn.",
"resumeDamage": "Resume Damage", "resumeDamage": "Resume Damage",
"helpfulLinks": "Helpful Links", "helpfulLinks": "Helpful Links",
"communityGuidelinesLink": "Community Guidelines", "communityGuidelinesLink": "Community Guidelines",