Skip to content

A platform for community discussion. Free, open, simple.

UX: badge page styling update (#20373)

chapoib50a581c5d6c
diff --git a/app/assets/javascripts/discourse/app/components/badge-card.hbs b/app/assets/javascripts/discourse/app/components/badge-card.hbs
index ce72346d191..4a6fe7a13c3 100644
--- a/app/assets/javascripts/discourse/app/components/badge-card.hbs
+++ b/app/assets/javascripts/discourse/app/components/badge-card.hbs
@@ -1,10 +1,3 @@
-{{#if this.displayCount}}
- <a
- href={{this.url}}
- title={{i18n "badges.granted" count=this.displayCount}}
- class="grant-count"
- >{{this.displayCount}}</a>
-{{/if}}
{{#if this.badge.has_badge}}
<a href={{this.url}} class="check-display status-checked">{{d-icon
"check"
@@ -46,6 +39,18 @@
<div class="badge-info-item">
<h3><a href={{this.url}} class="badge-link">{{this.badge.name}}</a></h3>
<div class="badge-summary">{{html-safe this.summary}}</div>
+
+ {{#if this.displayCount}}
+ <div class="badge-granted">
+ {{html-safe
+ (i18n
+ "badges.granted_with_count"
+ count=this.displayCount
+ badgeUrl=this.url
+ )
+ }}
+ </div>
+ {{/if}}
</div>
</div>
</div>
\ No newline at end of file
diff --git a/app/assets/stylesheets/common/base/discourse.scss b/app/assets/stylesheets/common/base/discourse.scss
index e875d3accd8..0d1e38e3e9c 100644
--- a/app/assets/stylesheets/common/base/discourse.scss
+++ b/app/assets/stylesheets/common/base/discourse.scss
@@ -552,6 +552,7 @@ table {
&.active {
font-weight: bold;
color: var(--primary);
+ background: var(--d-selected);
}
}
}
diff --git a/app/assets/stylesheets/common/base/user-badges.scss b/app/assets/stylesheets/common/base/user-badges.scss
index 32886dc0ca2..acc9f026310 100644
--- a/app/assets/stylesheets/common/base/user-badges.scss
+++ b/app/assets/stylesheets/common/base/user-badges.scss
@@ -127,17 +127,23 @@
.check-display {
position: absolute;
- left: 5px;
+ right: 5px;
top: 5px;
}
+ .badge-granted {
+ margin-top: 0.5em;
+ }
+
.grant-count {
- position: absolute;
- right: 5px;
- top: 5px;
font-weight: bold;
color: var(--primary-medium);
- font-size: var(--font-up-2);
+ line-height: 1;
+ }
+
+ .grant-text {
+ color: var(--primary-medium);
+ font-size: var(--font-down-1);
}
.favorite-btn {
@@ -145,11 +151,11 @@
right: 0;
bottom: 0;
}
-
.badge-contents {
display: flex;
- min-height: 8em;
- padding: 0 1.5em;
+ align-items: flex-start;
+ gap: 1rem;
+ padding: 1.5em 1.5em;
.badge-link {
color: var(--primary);
@@ -158,10 +164,8 @@
.badge-icon {
display: flex;
flex-shrink: 0;
- margin-right: 1.5em;
align-items: center;
justify-content: center;
- width: 64px;
svg {
font-size: 3.5em;
@@ -190,7 +194,6 @@
display: flex;
flex: 1 1 auto;
align-items: center;
- padding: 1em 0;
color: var(--primary);
h3 {
@@ -245,19 +248,11 @@
.badge-group-list {
display: grid;
- grid: auto-flow / repeat(3, 1fr);
+ grid-template-columns: repeat(auto-fit, minmax(18em, 1fr));
grid-gap: 1em;
width: 100%;
margin-bottom: 1.5em;
- @include breakpoint(medium) {
- grid: auto-flow / repeat(2, 1fr);
- }
-
- @include breakpoint(mobile-extra-large) {
- grid: auto-flow / 1fr;
- }
-
.title {
font-size: var(--font-up-1);
}
diff --git a/config/locales/client.en.yml b/config/locales/client.en.yml
index b2c7ed75611..f1c8d8c88bb 100644
--- a/config/locales/client.en.yml
+++ b/config/locales/client.en.yml
@@ -4121,6 +4121,9 @@ en:
granted:
one: "%{count} granted"
other: "%{count} granted"
+ granted_with_count:
+ one: '<a href="%{badgeUrl}" title="%{count} granted" class="grant-count">%{count}x</a> <span class="grant-text">granted</span>'
+ other: '<a href="%{badgeUrl}" title="%{count} granted" class="grant-count">%{count}x</a> <span class="grant-text">granted</span>'
select_badge_for_title: Select a badge to use as your title
none: "(none)"
successfully_granted: "Successfully granted %{badge} to %{username}"