Skip to content

Commit 355de61

Browse files
jordanvidrineyuriyaran
authored andcommitted
UX: Category header restyle (#34081)
1 parent 7ca1b13 commit 355de61

File tree

4 files changed

+67
-20
lines changed

4 files changed

+67
-20
lines changed

app/assets/javascripts/discourse/app/components/category-logo.gjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import LightDarkImg from "discourse/components/light-dark-img";
22

33
const CategoryLogo = <template>
4-
<div class="category-logo aspect-image">
4+
<div class="category-logo aspect-image" ...attributes>
55
<LightDarkImg
66
@lightImg={{@category.uploaded_logo}}
77
@darkImg={{@category.uploaded_logo_dark}}

app/assets/javascripts/discourse/app/components/discovery/navigation.gjs

Lines changed: 26 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,16 @@ import Component from "@glimmer/component";
22
import { array } from "@ember/helper";
33
import { action } from "@ember/object";
44
import { service } from "@ember/service";
5+
import { htmlSafe } from "@ember/template";
56
import AddCategoryTagClasses from "discourse/components/add-category-tag-classes";
67
import CategoryLogo from "discourse/components/category-logo";
78
import DNavigation from "discourse/components/d-navigation";
89
import AccessibleDiscoveryHeading from "discourse/components/discovery/accessible-discovery-heading";
910
import ReorderCategories from "discourse/components/modal/reorder-categories";
1011
import PluginOutlet from "discourse/components/plugin-outlet";
1112
import bodyClass from "discourse/helpers/body-class";
13+
import categoryBadge from "discourse/helpers/category-badge";
1214
import concatClass from "discourse/helpers/concat-class";
13-
import dirSpan from "discourse/helpers/dir-span";
1415
import lazyHash from "discourse/helpers/lazy-hash";
1516
import { calculateFilterMode } from "discourse/lib/filter-mode";
1617
import { TRACKED_QUERY_PARAM_VALUE } from "discourse/lib/topic-list-tracked-filter";
@@ -70,6 +71,13 @@ export default class DiscoveryNavigation extends Component {
7071
this.modal.show(ReorderCategories);
7172
}
7273

74+
get headingClasses() {
75+
return concatClass(
76+
"category-heading",
77+
this.args.category?.uploaded_logo?.url ? "--has-logo" : null
78+
);
79+
}
80+
7381
<template>
7482
<AddCategoryTagClasses
7583
@category={{@category}}
@@ -89,21 +97,28 @@ export default class DiscoveryNavigation extends Component {
8997
@outletArgs={{lazyHash category=@category tag=@tag}}
9098
/>
9199

92-
<section class="category-heading">
100+
<section class={{this.headingClasses}}>
93101
{{#if @category.uploaded_logo.url}}
94-
<CategoryLogo @category={{@category}} />
102+
<CategoryLogo
103+
@category={{@category}}
104+
class="category-heading__logo"
105+
/>
95106
{{#if @category.description}}
96-
<p>{{dirSpan @category.description htmlSafe="true"}}</p>
107+
<div class="category-heading__content">
108+
{{categoryBadge @category class="category-heading__badge"}}
109+
<p class="category-heading__description">
110+
{{htmlSafe @category.description}}
111+
</p>
112+
</div>
97113
{{/if}}
98114
{{/if}}
99115

100-
<span>
101-
<PluginOutlet
102-
@name="category-heading"
103-
@connectorTagName="div"
104-
@outletArgs={{lazyHash category=@category tag=@tag}}
105-
/>
106-
</span>
116+
<PluginOutlet
117+
@name="category-heading"
118+
@connectorTagName="div"
119+
@outletArgs={{lazyHash category=@category tag=@tag}}
120+
/>
121+
107122
</section>
108123
{{/if}}
109124

app/assets/stylesheets/common/base/_topic-list.scss

Lines changed: 40 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
@use "lib/viewport";
22

3+
:root {
4+
--category-header-logo-size: 3rem;
5+
--category-description-width: 760px;
6+
--category-header-border: 1px solid var(--content-border-color);
7+
}
8+
39
#navigation-bar {
410
display: flex;
511
flex-wrap: wrap;
@@ -46,11 +52,42 @@
4652

4753
.category-heading {
4854
max-width: 100%;
49-
font-size: var(--font-up-3);
5055

51-
p {
52-
margin-top: 0;
56+
&.--has-logo {
57+
display: flex;
58+
gap: var(--space-4);
59+
margin-bottom: var(--space-6);
60+
border: var(--category-header-border);
61+
padding: var(--space-4);
62+
border-radius: var(--d-border-radius);
63+
}
64+
65+
&__logo.category-logo.aspect-image {
66+
height: var(--category-header-logo-size);
67+
width: var(--category-header-logo-size);
68+
margin-top: calc(1rem - 1cap);
69+
flex-shrink: 0;
70+
}
71+
72+
&__description {
73+
margin: 0;
5374
line-height: var(--line-height-large);
75+
font-size: var(--font-0);
76+
color: var(--category-boxes-description-text-color);
77+
max-width: var(--category-description-width);
78+
}
79+
80+
&__content {
81+
flex-grow: 1;
82+
}
83+
84+
&__content .badge-category__wrapper {
85+
font-size: var(--font-up-3);
86+
}
87+
88+
&__content .badge-category__name {
89+
font-weight: bold;
90+
color: var(--primary);
5491
}
5592
}
5693

app/assets/stylesheets/desktop/topic-list.scss

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -247,11 +247,6 @@
247247
}
248248
}
249249

250-
.category-logo.aspect-image {
251-
float: left;
252-
margin: var(--space-1) var(--space-8) var(--space-8) 0;
253-
}
254-
255250
/* Tablet (portrait) ----------- */
256251

257252
// These styles kick in a little earlier when the sidebar appears

0 commit comments

Comments
 (0)