Skip to content

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

UX: dashboard > redesign who is posting (#40647)

chapoi743aa215fd6a
diff --git a/app/assets/stylesheets/admin/admin_dashboard.scss b/app/assets/stylesheets/admin/admin_dashboard.scss
index 79d147191ec..ffaee85170b 100644
--- a/app/assets/stylesheets/admin/admin_dashboard.scss
+++ b/app/assets/stylesheets/admin/admin_dashboard.scss
@@ -349,6 +349,7 @@
color: var(--primary);
font-weight: bold;
font-size: var(--font-down-1-rem);
+ white-space: nowrap;
&:hover,
&:focus,
@@ -496,6 +497,15 @@
display: flex;
flex-direction: column;
gap: var(--space-3);
+ container-type: inline-size;
+ container-name: db-whos-posting;
+
+ .db-section__row-block-header {
+ @container db-whos-posting (width < 22rem) {
+ flex-direction: column;
+ align-items: flex-start;
+ }
+ }
&__filter {
display: flex;
@@ -503,6 +513,15 @@
align-items: flex-end;
gap: var(--space-1);
flex-grow: 1;
+ min-width: 0;
+
+ @container db-whos-posting (width < 22rem) {
+ width: 100%;
+
+ .select-kit.combo-box.category-chooser {
+ max-width: none;
+ }
+ }
}
&__subcategories {
@@ -514,53 +533,47 @@
cursor: pointer;
}
- &__bar {
- display: flex;
- width: 100%;
- height: 12px;
- border-radius: 6px;
- overflow: hidden;
- background: var(--primary-low);
- }
-
- &__segment {
- display: block;
- height: 100%;
+ &__bars {
+ display: grid;
+ grid-template-columns: minmax(0, auto) minmax(200px, 1fr) 2.5rem;
+ gap: var(--space-2);
- &.--new-members {
- background: var(--tertiary);
+ @container db-whos-posting (width < 22rem) {
+ grid-template-columns: 1fr;
+ gap: var(--space-3);
}
+ }
- &.--returning {
- background: var(--tertiary-medium);
- }
+ &__bar-row {
+ display: grid;
+ grid-column: 1 / -1;
+ grid-template-columns: subgrid;
+ align-items: center;
- &.--staff {
- background: var(--primary-medium);
+ @container db-whos-posting (width < 22rem) {
+ grid-template-columns: 1fr auto;
+ gap: 0 var(--space-2);
}
}
- &__legend {
- list-style: none;
- margin: 0;
- padding: 0;
- display: flex;
- flex-direction: column;
- gap: var(--space-1);
+ &__bar-label {
+ @include ellipsis;
+
+ @container db-whos-posting (width < 22rem) {
+ grid-column: 1 / -1;
+ }
}
- &__legend-item {
- display: flex;
- align-items: center;
- gap: var(--space-2);
- font-size: var(--font-down-1-rem);
+ &__bar-track {
+ height: var(--space-3);
+ border-radius: 1em;
+ background: var(--primary-low);
}
- &__legend-dot {
- width: 8px;
- height: 8px;
- border-radius: 50%;
- flex: 0 0 auto;
+ &__bar-fill {
+ display: block;
+ height: 100%;
+ border-radius: 1em;
&.--new-members {
background: var(--tertiary);
@@ -575,14 +588,11 @@
}
}
- &__legend-label {
- flex: 1 1 auto;
- color: var(--primary);
- }
-
- &__legend-share {
+ &__bar-share {
color: var(--primary-medium);
font-variant-numeric: tabular-nums;
+ text-align: right;
+ line-height: 1;
}
&__empty {
@@ -624,7 +634,6 @@
}
&__name {
- font-weight: bold;
color: var(--primary);
}
diff --git a/frontend/discourse/admin/components/dashboard/engagement/whos-posting.gjs b/frontend/discourse/admin/components/dashboard/engagement/whos-posting.gjs
index 873ef1eb1be..c633c5fe7a8 100644
--- a/frontend/discourse/admin/components/dashboard/engagement/whos-posting.gjs
+++ b/frontend/discourse/admin/components/dashboard/engagement/whos-posting.gjs
@@ -53,7 +53,7 @@ export default class WhosPosting extends Component {
get rows() {
const rows = this.posters?.rows ?? [];
const byType = Object.fromEntries(rows.map((r) => [r.type, r]));
- return ROW_ORDER.map((type, index) => {
+ return ROW_ORDER.map((type) => {
const row = byType[type] ?? { type, count: 0, share: 0 };
return {
type,
@@ -62,7 +62,6 @@ export default class WhosPosting extends Component {
shareFormatted: `${Math.round(row.share)}%`,
segmentStyle: trustHTML(`width: ${row.share}%`),
segmentClass: `--${type.replace("_", "-")}`,
- legendIndex: index,
};
});
}
@@ -170,34 +169,25 @@ export default class WhosPosting extends Component {
{{#if this.hasData}}
<div
- class="db-whos-posting__bar"
+ class="db-whos-posting__bars"
role="img"
aria-label={{this.ariaLabel}}
>
{{#each this.rows as |row|}}
- {{#if row.share}}
+ <div class="db-whos-posting__bar-row">
+ <span class="db-whos-posting__bar-label">{{row.label}}</span>
+ <span class="db-whos-posting__bar-track">
+ <span
+ class="db-whos-posting__bar-fill {{row.segmentClass}}"
+ style={{row.segmentStyle}}
+ ></span>
+ </span>
<span
- class="db-whos-posting__segment {{row.segmentClass}}"
- style={{row.segmentStyle}}
- ></span>
- {{/if}}
- {{/each}}
- </div>
-
- <ul class="db-whos-posting__legend">
- {{#each this.rows as |row|}}
- <li class="db-whos-posting__legend-item">
- <span
- class="db-whos-posting__legend-dot {{row.segmentClass}}"
- aria-hidden="true"
- ></span>
- <span class="db-whos-posting__legend-label">{{row.label}}</span>
- <span
- class="db-whos-posting__legend-share"
+ class="db-whos-posting__bar-share"
>{{row.shareFormatted}}</span>
- </li>
+ </div>
{{/each}}
- </ul>
+ </div>
{{else}}
<p class="db-whos-posting__empty">
{{i18n "admin.dashboard.sections.engagement.whos_posting.empty"}}
diff --git a/frontend/discourse/tests/integration/components/dashboard/whos-posting-test.gjs b/frontend/discourse/tests/integration/components/dashboard/whos-posting-test.gjs
index 8725fb2480a..7a169141307 100644
--- a/frontend/discourse/tests/integration/components/dashboard/whos-posting-test.gjs
+++ b/frontend/discourse/tests/integration/components/dashboard/whos-posting-test.gjs
@@ -18,7 +18,7 @@ module("Integration | Component | Dashboard | WhosPosting", function (hooks) {
],
};
- test("renders the stacked bar segments and legend rows", async function (assert) {
+ test("renders a bar row with label, fill and share for each bucket", async function (assert) {
await render(
<template>
<WhosPosting
@@ -29,18 +29,14 @@ module("Integration | Component | Dashboard | WhosPosting", function (hooks) {
</template>
);
- assert.dom(".db-whos-posting__bar").exists();
- assert.dom(".db-whos-posting__segment").exists({ count: 3 });
- assert.dom(".db-whos-posting__legend-item").exists({ count: 3 });
+ assert.dom(".db-whos-posting__bars").exists();
+ assert.dom(".db-whos-posting__bar-row").exists({ count: 3 });
+ assert.dom(".db-whos-posting__bar-fill").exists({ count: 3 });
assert
- .dom(
- ".db-whos-posting__legend-item:nth-child(1) .db-whos-posting__legend-label"
- )
+ .dom(".db-whos-posting__bar-row:nth-child(1) .db-whos-posting__bar-label")
.hasText("New members");
assert
- .dom(
- ".db-whos-posting__legend-item:nth-child(2) .db-whos-posting__legend-share"
- )
+ .dom(".db-whos-posting__bar-row:nth-child(2) .db-whos-posting__bar-share")
.hasText("51%");
});
@@ -71,12 +67,11 @@ module("Integration | Component | Dashboard | WhosPosting", function (hooks) {
</template>
);
- assert.dom(".db-whos-posting__bar").doesNotExist();
- assert.dom(".db-whos-posting__legend").doesNotExist();
+ assert.dom(".db-whos-posting__bars").doesNotExist();
assert.dom(".db-whos-posting__empty").exists();
});
- test("omits the bar segment for a bucket with zero share", async function (assert) {
+ test("renders a zero-share bucket with a 0% share", async function (assert) {
const noStaff = {
total: 85,
rows: [
@@ -96,7 +91,9 @@ module("Integration | Component | Dashboard | WhosPosting", function (hooks) {
</template>
);
- assert.dom(".db-whos-posting__segment").exists({ count: 2 });
- assert.dom(".db-whos-posting__legend-item").exists({ count: 3 });
+ assert.dom(".db-whos-posting__bar-row").exists({ count: 3 });
+ assert
+ .dom(".db-whos-posting__bar-row:nth-child(3) .db-whos-posting__bar-share")
+ .hasText("0%");
});
});