UX: Styling changes to global banner (#16191)

This commit is contained in:
Penar Musaraj 2022-03-15 16:19:55 +01:00 committed by GitHub
parent dec68d780c
commit 593f3e5dd8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 63 additions and 46 deletions

View File

@ -1,15 +1,18 @@
import Component from "@ember/component"; import Component from "@ember/component";
import discourseComputed from "discourse-common/utils/decorators"; import discourseComputed from "discourse-common/utils/decorators";
import { action } from "@ember/object";
export default Component.extend({ export default Component.extend({
hide: false, hide: false,
@discourseComputed("banner.html") @discourseComputed("banner.html")
content(bannerHtml) { content(bannerHtml) {
const $div = $("<div>"); const newDiv = document.createElement("div");
$div.append(bannerHtml); newDiv.innerHTML = bannerHtml;
$div.find("[id^='heading--']").removeAttr("id"); newDiv.querySelectorAll("[id^='heading--']").forEach((el) => {
return $div.html(); el.removeAttribute("id");
});
return newDiv.innerHTML;
}, },
@discourseComputed("user.dismissed_banner_key", "banner.key", "hide") @discourseComputed("user.dismissed_banner_key", "banner.key", "hide")
@ -27,7 +30,7 @@ export default Component.extend({
return !hide && bannerKey && dismissedBannerKey !== bannerKey; return !hide && bannerKey && dismissedBannerKey !== bannerKey;
}, },
actions: { @action
dismiss() { dismiss() {
if (this.user) { if (this.user) {
this.user.dismissBanner(this.get("banner.key")); this.user.dismissBanner(this.get("banner.key"));
@ -39,5 +42,4 @@ export default Component.extend({
}); });
} }
}, },
},
}); });

View File

@ -1,12 +1,20 @@
{{#if visible}} {{#if visible}}
<div class="row"> <div class="row">
<div id="banner" class={{overlay}}> <div id="banner" class={{overlay}}>
<div class="floated-buttons">
{{#if currentUser.staff}}
<a href={{banner.url}} class="btn btn-flat edit-banner">
{{d-icon "pencil-alt"}}
{{#unless site.mobileView}}
{{html-safe (i18n "banner.edit")}}
{{/unless}}
</a>
{{/if}}
{{d-button icon="times" action=(action "dismiss") class="btn btn-flat close" title="banner.close"}} {{d-button icon="times" action=(action "dismiss") class="btn btn-flat close" title="banner.close"}}
</div>
<div id="banner-content"> <div id="banner-content">
{{html-safe content}} {{html-safe content}}
{{#if currentUser.staff}}
<p><a href={{banner.url}}>{{html-safe (i18n "banner.edit")}}</a></p>
{{/if}}
</div> </div>
</div> </div>
</div> </div>

View File

@ -3,29 +3,37 @@
// -------------------------------------------------- // --------------------------------------------------
#banner { #banner {
padding: 0.5em 1em; padding: 1em;
background: var(--tertiary-low); background: var(--tertiary-low);
color: var(--primary); color: var(--primary);
z-index: z("base") + 1; z-index: z("base") + 1;
margin-bottom: 1em; margin-bottom: 1em;
max-height: 250px; max-height: 20vh;
overflow: auto; overflow: auto;
&.overlay { .floated-buttons {
position: fixed;
}
.close {
color: var(--primary-low-mid);
padding-left: 5px;
float: right; float: right;
display: flex;
> .btn {
padding-top: 0em;
padding-bottom: 0em;
color: var(--primary-high);
.d-icon { .d-icon {
color: var(--primary-medium); color: var(--primary-medium);
} }
&:hover {
color: var(--primary);
.d-icon {
color: var(--primary-high);
}
}
} }
.meta { .desktop-view & .btn.close {
display: none; margin-left: 0.25em;
}
} }
} }
@ -33,4 +41,12 @@
hr { hr {
border-color: var(--primary-medium); border-color: var(--primary-medium);
} }
> p:first-child {
margin-top: 0;
}
> p:last-of-type {
margin-bottom: 0;
}
} }

View File

@ -1,4 +1,3 @@
@import "banner";
@import "topic-footer-mobile-dropdown"; @import "topic-footer-mobile-dropdown";
@import "user-card"; @import "user-card";
@import "user-stream-item"; @import "user-stream-item";

View File

@ -1,8 +0,0 @@
// --------------------------------------------------
// Banner
// --------------------------------------------------
#banner {
max-height: 180px;
height: 20vh;
}

View File

@ -411,8 +411,8 @@ en:
switch_from_anon: "Exit Anonymous Mode" switch_from_anon: "Exit Anonymous Mode"
banner: banner:
close: "Dismiss this banner." close: "Dismiss this banner"
edit: "Edit this banner >>" edit: "Edit"
pwa: pwa:
install_banner: "Do you want to <a href>install %{title} on this device?</a>" install_banner: "Do you want to <a href>install %{title} on this device?</a>"