A platform for community discussion. Free, open, simple.
UX: Add high context topic card layout option to Horizon theme (#36902)
Régis Hanolbb235b554068
diff --git a/app/assets/stylesheets/common/base/discourse.scss b/app/assets/stylesheets/common/base/discourse.scssindex fefdadf61f5..435c49f9c16 100644--- a/app/assets/stylesheets/common/base/discourse.scss+++ b/app/assets/stylesheets/common/base/discourse.scss@@ -1048,7 +1048,7 @@ form {}}- .topic-status-warning .d-icon-envelope {+ .topic-status.--warning .d-icon-envelope {color: var(--danger);}}diff --git a/frontend/discourse/app/components/topic-list/bulk-select-checkbox.gjs b/frontend/discourse/app/components/topic-list/bulk-select-checkbox.gjsnew file mode 100644index 00000000000..bf9bcbfafd1--- /dev/null+++ b/frontend/discourse/app/components/topic-list/bulk-select-checkbox.gjs@@ -0,0 +1,15 @@+import { on } from "@ember/modifier";++const BulkSelectCheckbox = <template>+ <label for="bulk-select-{{@topic.id}}" ...attributes>+ <input+ {{on "click" @onToggle}}+ checked={{@isSelected}}+ type="checkbox"+ id="bulk-select-{{@topic.id}}"+ class="bulk-select"+ />+ </label>+</template>;++export default BulkSelectCheckbox;diff --git a/frontend/discourse/app/components/topic-list/item.gjs b/frontend/discourse/app/components/topic-list/item.gjsindex d3c15df1602..d304a15fe27 100644--- a/frontend/discourse/app/components/topic-list/item.gjs+++ b/frontend/discourse/app/components/topic-list/item.gjs@@ -7,6 +7,7 @@ import { service } from "@ember/service";import { htmlSafe, isHTMLSafe } from "@ember/template";import { modifier } from "ember-modifier";import PluginOutlet from "discourse/components/plugin-outlet";+import BulkSelectCheckbox from "discourse/components/topic-list/bulk-select-checkbox";import PostCountOrBadges from "discourse/components/topic-list/post-count-or-badges";import TopicExcerpt from "discourse/components/topic-list/topic-excerpt";import TopicLink from "discourse/components/topic-list/topic-link";@@ -323,15 +324,11 @@ export default class Item extends Component {><div class="pull-left">{{#if @bulkSelectEnabled}}- <label for="bulk-select-{{@topic.id}}">- <input- {{on "click" this.onBulkSelectToggle}}- checked={{this.isSelected}}- type="checkbox"- id="bulk-select-{{@topic.id}}"- class="bulk-select"- />- </label>+ <BulkSelectCheckbox+ @topic={{@topic}}+ @isSelected={{this.isSelected}}+ @onToggle={{this.onBulkSelectToggle}}+ />{{else}}<PluginOutlet@name="topic-list-item-mobile-avatar"diff --git a/frontend/discourse/app/components/topic-list/item/bulk-select-cell.gjs b/frontend/discourse/app/components/topic-list/item/bulk-select-cell.gjsindex fcc9a5380bc..df348c45643 100644--- a/frontend/discourse/app/components/topic-list/item/bulk-select-cell.gjs+++ b/frontend/discourse/app/components/topic-list/item/bulk-select-cell.gjs@@ -1,16 +1,12 @@-import { on } from "@ember/modifier";+import BulkSelectCheckbox from "discourse/components/topic-list/bulk-select-checkbox";const BulkSelectCell = <template><td class="bulk-select topic-list-data">- <label for="bulk-select-{{@topic.id}}">- <input- {{on "click" @onBulkSelectToggle}}- checked={{@isSelected}}- type="checkbox"- id="bulk-select-{{@topic.id}}"- class="bulk-select"- />- </label>+ <BulkSelectCheckbox+ @topic={{@topic}}+ @isSelected={{@isSelected}}+ @onToggle={{@onBulkSelectToggle}}+ /></td></template>;diff --git a/frontend/discourse/app/components/topic-list/item/topic-cell.gjs b/frontend/discourse/app/components/topic-list/item/topic-cell.gjsindex 8f0735e2685..95196298ba2 100644--- a/frontend/discourse/app/components/topic-list/item/topic-cell.gjs+++ b/frontend/discourse/app/components/topic-list/item/topic-cell.gjs@@ -1,7 +1,6 @@import Component from "@glimmer/component";import { on } from "@ember/modifier";import { action } from "@ember/object";-import { service } from "@ember/service";import PluginOutlet from "discourse/components/plugin-outlet";import ActionList from "discourse/components/topic-list/action-list";import ParticipantGroups from "discourse/components/topic-list/participant-groups";@@ -15,17 +14,8 @@ import discourseTags from "discourse/helpers/discourse-tags";import lazyHash from "discourse/helpers/lazy-hash";import topicFeaturedLink from "discourse/helpers/topic-featured-link";import { groupPath } from "discourse/lib/url";-import { i18n } from "discourse-i18n";export default class TopicCell extends Component {- @service currentUser;-- get newDotText() {- return this.currentUser?.trust_level > 0- ? ""- : i18n("filters.new.lower_title");- }-get participantGroups() {if (!this.args.topic.get("participant_groups")) {return [];@@ -88,7 +78,6 @@ export default class TopicCell extends Component {<TopicPostBadges@unreadPosts={{@topic.unread_posts}}@unseen={{@topic.unseen}}- @newDotText={{this.newDotText}}@url={{@topic.lastUnreadUrl}}/>{{~/if~}}diff --git a/frontend/discourse/app/components/topic-reply-choice-dialog.gjs b/frontend/discourse/app/components/topic-reply-choice-dialog.gjsindex ee7c6700a59..797e9eb14dd 100644--- a/frontend/discourse/app/components/topic-reply-choice-dialog.gjs+++ b/frontend/discourse/app/components/topic-reply-choice-dialog.gjs@@ -13,25 +13,25 @@ const TopicLabelButton = <template><div class="topic-title__top-line"><span class="topic-statuses">{{#if (eq @topic.archetype "private_message")}}- <span class="topic-status">+ <span class="topic-status --private-message">{{icon "envelope"}}</span>{{/if}}{{#if @topic.bookmarked}}- <span class="topic-status">+ <span class="topic-status --bookmarked">{{icon "bookmark"}}</span>{{/if}}{{#if @topic.closed}}- <span class="topic-status">+ <span class="topic-status --closed">{{icon "topic.closed"}}</span>{{/if}}{{#if @topic.pinned}}- <span class="topic-status">+ <span class="topic-status --pinned">{{icon "thumbtack"}}</span>{{/if}}diff --git a/frontend/discourse/app/components/topic-status.gjs b/frontend/discourse/app/components/topic-status.gjsindex 0d5d1e41707..36810fa190d 100644--- a/frontend/discourse/app/components/topic-status.gjs+++ b/frontend/discourse/app/components/topic-status.gjs@@ -34,36 +34,36 @@ export default class TopicStatus extends Component {<ahref={{@topic.url}}title={{i18n "topic_statuses.bookmarked.help"}}- class="topic-status"+ class="topic-status --bookmarked">{{icon "bookmark"}}</a>{{~/if~}}{{~#if (and @topic.closed @topic.archived)~}}<spantitle={{i18n "topic_statuses.locked_and_archived.help"}}- class="topic-status"+ class="topic-status --closed --archived">{{icon "topic.closed"}}</span>{{~else if @topic.closed~}}<spantitle={{i18n "topic_statuses.locked.help"}}- class="topic-status"+ class="topic-status --closed">{{icon "topic.closed"}}</span>{{~else if @topic.archived~}}<spantitle={{i18n "topic_statuses.archived.help"}}- class="topic-status"+ class="topic-status --archived">{{icon "topic.closed"}}</span>{{~/if~}}{{~#if @topic.is_warning~}}<spantitle={{i18n "topic_statuses.warning.help"}}- class="topic-status topic-status-warning"+ class="topic-status --warning topic-status-warning">{{icon "envelope"}}</span>{{~else if (and @showPrivateMessageIcon @topic.isPrivateMessage)~}}<spantitle={{i18n "topic_statuses.personal_message.help"}}- class="topic-status"+ class="topic-status --personal-message">{{icon "envelope"}}</span>{{~/if~}}@@ -73,12 +73,12 @@ export default class TopicStatus extends Component {{{on "click" this.togglePinned}}hreftitle={{i18n "topic_statuses.pinned.help"}}- class="topic-status pinned pin-toggle-button"+ class="topic-status --pinned pin-toggle-button">{{icon "thumbtack"}}</a>{{~else~}}<spantitle={{i18n "topic_statuses.pinned.help"}}- class="topic-status pinned"+ class="topic-status --pinned">{{icon "thumbtack"}}</span>{{~/if~}}{{~else if @topic.unpinned~}}@@ -87,12 +87,12 @@ export default class TopicStatus extends Component {{{on "click" this.togglePinned}}hreftitle={{i18n "topic_statuses.unpinned.help"}}- class="topic-status unpinned pin-toggle-button"+ class="topic-status --unpinned pin-toggle-button">{{icon "thumbtack" class="unpinned"}}</a>{{~else~}}<spantitle={{i18n "topic_statuses.unpinned.help"}}- class="topic-status unpinned"+ class="topic-status --unpinned">{{icon "thumbtack" class="unpinned"}}</span>{{~/if~}}{{~/if~}}@@ -103,7 +103,7 @@ export default class TopicStatus extends Component {"topic_statuses.unlisted.help"}}- class="topic-status"+ class="topic-status --invisible">{{icon "far-eye-slash"}}</span>{{~/if~}}<PluginOutletdiff --git a/frontend/discourse/app/lib/render-tags.js b/frontend/discourse/app/lib/render-tags.jsindex bfa2484c20c..5217dbf8448 100644--- a/frontend/discourse/app/lib/render-tags.js+++ b/frontend/discourse/app/lib/render-tags.js@@ -71,9 +71,13 @@ export default function (topic, params) {const hasContent = (tags && tags.length > 0) || callbackResults.length > 0;if (hasContent) {- buffer = `<div class='discourse-tags'- role='list'- aria-label=${i18n("tagging.tags")}>`;+ const classNames = ["discourse-tags"];++ if (params?.className) {+ classNames.push(params.className);+ }++ buffer = `<div class='${classNames.join(" ")}' role='list' aria-label=${i18n("tagging.tags")}>`;let currentIndex = 0;diff --git a/plugins/discourse-solved/assets/javascripts/discourse/connectors/after-topic-status/solved-status.gjs b/plugins/discourse-solved/assets/javascripts/discourse/connectors/after-topic-status/solved-status.gjsindex 18307da3ff9..d8c332e9909 100644--- a/plugins/discourse-solved/assets/javascripts/discourse/connectors/after-topic-status/solved-status.gjs+++ b/plugins/discourse-solved/assets/javascripts/discourse/connectors/after-topic-status/solved-status.gjs@@ -8,7 +8,7 @@ const SolvedStatus = <template>~}}<spantitle={{i18n "topic_statuses.solved.help"}}- class="topic-status solved"+ class="topic-status --solved">{{icon "far-square-check"}}</span>{{~else if(and@@ -17,7 +17,7 @@ const SolvedStatus = <template>~}}<spantitle={{i18n "solved.has_no_accepted_answer"}}- class="topic-status"+ class="topic-status --unsolved">{{icon "far-square"}}</span>{{~/if~}}</template>;diff --git a/plugins/discourse-solved/assets/stylesheets/solutions.scss b/plugins/discourse-solved/assets/stylesheets/solutions.scssindex 81f77bcf9a1..f5b7443f50a 100644--- a/plugins/discourse-solved/assets/stylesheets/solutions.scss+++ b/plugins/discourse-solved/assets/stylesheets/solutions.scss@@ -113,7 +113,7 @@ aside.quote.accepted-answer {display: block;}-.topic-statuses .topic-status.solved {+.topic-statuses .topic-status.--solved {.d-icon {color: $solved-color;}diff --git a/plugins/discourse-solved/test/javascripts/acceptance/discourse-solved-test.js b/plugins/discourse-solved/test/javascripts/acceptance/discourse-solved-test.jsindex c409d70a059..18468a7b0aa 100644--- a/plugins/discourse-solved/test/javascripts/acceptance/discourse-solved-test.js+++ b/plugins/discourse-solved/test/javascripts/acceptance/discourse-solved-test.js@@ -45,6 +45,6 @@ acceptance(`Discourse Solved Plugin`, function (needs) {await click(".search-cta");assert.dom(".fps-topic").exists({ count: 1 }, "has one post");- assert.dom(".topic-statuses .solved").exists("shows the right icon");+ assert.dom(".topic-statuses .--solved").exists("shows the right icon");});});diff --git a/themes/horizon/about.json b/themes/horizon/about.jsonindex 7cb2ff96100..40415f0f9eb 100644--- a/themes/horizon/about.json+++ b/themes/horizon/about.json@@ -4,7 +4,13 @@"theme_version": "1.0.0","modifiers": {"svg_icons": [- "fire"+ "fire",+ "far-square-check",+ "far-square",+ "thumbtack",+ "reply",+ "heart",+ "user-plus"],"serialize_topic_is_hot": true},@@ -136,6 +142,7 @@],"theme_site_settings": {"enable_welcome_banner": true,- "search_experience": "search_field"+ "search_experience": "search_field",+ "topic_card_context": "simple"}}diff --git a/themes/horizon/common/common.scss b/themes/horizon/common/common.scssindex 99cdf02f827..ec15384ae4e 100644--- a/themes/horizon/common/common.scss+++ b/themes/horizon/common/common.scss@@ -18,6 +18,7 @@@import "sidebar-new-topic-button";@import "topic";@import "topic-cards";+@import "high-context-cards";@import "variables";:root {diff --git a/themes/horizon/javascripts/discourse/components/card/high-context-topic-card.gjs b/themes/horizon/javascripts/discourse/components/card/high-context-topic-card.gjsnew file mode 100644index 00000000000..5d5c99c03fd--- /dev/null+++ b/themes/horizon/javascripts/discourse/components/card/high-context-topic-card.gjs@@ -0,0 +1,319 @@+import Component from "@glimmer/component";+import { on } from "@ember/modifier";+import { action } from "@ember/object";+import { service } from "@ember/service";+import { themePrefix } from "virtual:theme";+import BulkSelectCheckbox from "discourse/components/topic-list/bulk-select-checkbox";+import TopicExcerpt from "discourse/components/topic-list/topic-excerpt";+import TopicLink from "discourse/components/topic-list/topic-link";+import UnreadIndicator from "discourse/components/topic-list/unread-indicator";+import TopicPostBadges from "discourse/components/topic-post-badges";+import TopicStatus from "discourse/components/topic-status";+import avatar from "discourse/helpers/avatar";+import { categoryLinkHTML } from "discourse/helpers/category-link";+import concatClass from "discourse/helpers/concat-class";+import icon from "discourse/helpers/d-icon";+import discourseTags from "discourse/helpers/discourse-tags";+import formatDate from "discourse/helpers/format-date";+import number from "discourse/helpers/number";+import topicFeaturedLink from "discourse/helpers/topic-featured-link";+import { shortDateNoYear } from "discourse/lib/formatter";+import { or } from "discourse/truth-helpers";+import { i18n } from "discourse-i18n";++export default class HighContextTopicCard extends Component {+ @service capabilities;++ get hasSolved() {+ return (+ this.args.topic.has_accepted_answer || this.args.topic.accepted_answer+ );+ }++ get hasVotes() {+ return this.args.topic.can_vote && this.args.topic.vote_count > 0;+ }++ get voteCountLabel() {+ return i18n(themePrefix("vote_count"), {+ count: this.args.topic.vote_count,+ });+ }++ get hasAssigned() {+ return this.args.topic.assigned_to_user || this.hasIndirectAssignments;+ }++ get assignedUser() {+ return this.args.topic.assigned_to_user;+ }++ get hasIndirectAssignments() {+ const indirect = this.args.topic.indirectly_assigned_to;+ return indirect && Object.keys(indirect).length > 0;+ }++ get indirectAssignees() {+ const indirect = this.args.topic.indirectly_assigned_to;+ if (!indirect) {+ return [];+ }+ return Object.values(indirect).map((assignment) => ({+ user: assignment.assigned_to,+ postNumber: assignment.post_number,+ }));+ }++ get hasTags() {+ return this.args.topic.tags?.length > 0;+ }++ get hasReplies() {+ return this.args.topic.posts_count > 1;+ }++ get hasLikes() {+ return this.args.topic.like_count > 0;+ }++ get replyCountLabel() {+ return i18n(themePrefix("reply_count"), {+ count: this.args.topic.replyCount,+ });+ }++ get likeCountLabel() {+ return i18n(themePrefix("like_count"), {+ count: this.args.topic.like_count,+ });+ }++ get hasExcerpt() {+ return this.args.topic.excerpt || this.args.topic.hasExcerpt;+ }++ get statusBadge() {+ if (this.args.topic.is_hot) {+ return {+ icon: "fire",+ text: "topic_statuses.hot.title",+ className: "--hot",+ };+ }+ if (this.args.topic.pinned || this.args.topic.pinned_globally) {+ return {+ icon: "thumbtack",+ text: "topic_statuses.pinned.title",+ className: "--pinned",+ };+ }+ return null;+ }++ get topicCreator() {+ return this.args.topic.creator;+ }++ get lastPoster() {+ return {+ user: this.args.topic.lastPosterUser,+ username: this.args.topic.last_poster_username,+ };+ }++ get topicTimestamp() {+ return shortDateNoYear(new Date(this.args.topic.created_at));+ }++ @action+ onTitleFocus(event) {+ event.target.closest(".topic-list-item").classList.add("selected");+ }++ @action+ onTitleBlur(event) {+ event.target.closest(".topic-list-item").classList.remove("selected");+ }++ <template>+ <td class="hc-topic-card">+ {{! ROW 1: Creator info + Category + Status }}+ <div class="hc-topic-card__header">+ <div class="hc-topic-card__op">+ <div class="hc-topic-card__avatar">+ {{avatar this.topicCreator imageSize="medium"}}+ </div>+ <div class="hc-topic-card__op-info">+ <span class="hc-topic-card__op-timestamp">+ {{i18n (themePrefix "posted")}}+ {{this.topicTimestamp}}+ </span>+ <span class="hc-topic-card__op-name">+ {{i18n+ (themePrefix "by_username")+ username=this.topicCreator.username+ }}</span>+ </div>++ </div>+ <div class="hc-topic-card__status-tags">+ {{#if this.hasSolved}}+ <span class="hc-topic-card__status --solved">+ {{#if this.capabilities.viewport.sm}}+ {{i18n (themePrefix "solved")}}+ {{/if}}+ {{icon "square-check"}}+ </span>+ {{/if}}++ {{#if this.statusBadge}}+ <span+ class={{concatClass+ "hc-topic-card__status"+ this.statusBadge.className+ }}+ >+ {{icon this.statusBadge.icon}}++ {{#if this.capabilities.viewport.sm}}+ <span class="hc-topic-card__status-text">{{i18n+ this.statusBadge.text+ }}</span>+ {{/if}}+ </span>+ {{/if}}+ </div>+ </div>++ {{! ROW 2: Title + Excerpt }}+ <div class="hc-topic-card__content">+ <div class="hc-topic-card__title">+ {{#if @bulkSelectEnabled}}+ <BulkSelectCheckbox+ @topic={{@topic}}+ @isSelected={{@isSelected}}+ @onToggle={{@onBulkSelectToggle}}+ class="hc-topic-card__bulk-select"+ />+ {{/if}}+ <TopicStatus @topic={{@topic}} @context="topic-list" />+ <TopicLink+ {{on "focus" this.onTitleFocus}}+ {{on "blur" this.onTitleBlur}}+ @topic={{@topic}}+ class="hc-topic-card__title raw-link raw-topic-link"+ />+ {{~#if @topic.featured_link~}}+ {{topicFeaturedLink @topic}}+ {{~/if~}}+ <UnreadIndicator @topic={{@topic}} />+ <TopicPostBadges+ @unreadPosts={{@topic.unread_posts}}+ @unseen={{@topic.unseen}}+ @url={{@topic.lastUnreadUrl}}+ />+ </div>++ {{#if this.hasExcerpt}}+ <TopicExcerpt @topic={{@topic}} class="hc-topic-card__excerpt" />+ {{/if}}+ </div>++ {{! ROW 3: Last Reply + Assigned }}++ {{#if (or this.hasReplies this.hasAssigned)}}+ <div class="hc-topic-card__context">+ {{#if this.hasReplies}}+ <div class="hc-topic-card__last-reply">+ {{avatar this.lastPoster.user imageSize="tiny"}}+ <span+ class="hc-topic-card__last-reply-name"+ >{{this.lastPoster.username}}</span>+ <span>{{i18n (themePrefix "replied")}}</span>+ <span class="hc-topic-card__time">+ {{formatDate @topic.bumpedAt leaveAgo="true"}}+ </span>+ </div>+ {{/if}}+ {{#if this.hasAssigned}}+ {{#if this.assignedUser}}+ <div class="hc-topic-card__assigned">+ {{icon "user-plus"}}+ <span+ class="hc-topic-card__assigned-name"+ >{{this.assignedUser.username}}</span>+ </div>+ {{/if}}+ {{#each this.indirectAssignees as |assignment|}}+ <div class="hc-topic-card__assigned">+ {{icon "user-plus"}}+ <span+ class="hc-topic-card__assigned-name"+ >{{assignment.user.username}}</span>+ <span+ class="hc-topic-card__assigned-post"+ >#{{assignment.postNumber}}</span>+ </div>+ {{/each}}+ {{/if}}+ </div>+ {{/if}}++ {{! ROW 4: Stats + Last Reply }}+ <div class="hc-topic-card__footer">+ <div class="hc-topic-card__category-tags">+ {{#unless @hideCategory}}+ <div class="hc-topic-card__category">+ {{categoryLinkHTML @topic.category}}+ </div>+ {{/unless}}++ {{#if this.hasTags}}+ {{discourseTags @topic mode="list" className="hc-topic-card__tags"}}+ {{/if}}+ </div>++ <div class="hc-topic-card__stats">+ {{#if this.hasVotes}}+ <span+ class="hc-topic-card__votes"+ aria-label={{this.voteCountLabel}}+ title={{this.voteCountLabel}}+ >+ {{icon "stamp" skipTitle=true}}+ <span class="hc-topic-card__votes-count">{{number+ @topic.vote_count+ }}</span>+ </span>+ {{/if}}++ {{#if this.hasReplies}}+ <span+ class="hc-topic-card__replies"+ aria-label={{this.replyCountLabel}}+ title={{this.replyCountLabel}}+ >+ {{icon "reply" skipTitle=true}}+ <span class="hc-topic-card__count">{{number+ @topic.replyCount+ }}</span>+ </span>+ {{/if}}++ {{#if this.hasLikes}}+ <span+ class="hc-topic-card__likes"+ aria-label={{this.likeCountLabel}}+ title={{this.likeCountLabel}}+ >+ {{icon "heart" skipTitle=true}}+ <span class="hc-topic-card__count">{{number+ @topic.like_count+ }}</span>+ </span>+ {{/if}}+ </div>+ </div>+ </td>+ </template>+}diff --git a/themes/horizon/javascripts/discourse/initializers/topic-list-columns.gjs b/themes/horizon/javascripts/discourse/initializers/topic-list-columns.gjsindex 6f7400e7378..2cc1a4f9390 100644--- a/themes/horizon/javascripts/discourse/initializers/topic-list-columns.gjs+++ b/themes/horizon/javascripts/discourse/initializers/topic-list-columns.gjs@@ -1,4 +1,6 @@+import { settings } from "virtual:theme";import { withPluginApi } from "discourse/lib/plugin-api";+import HighContextTopicCard from "../components/card/high-context-topic-card";import TopicActivityColumn from "../components/card/topic-activity-column";import TopicCategoryColumn from "../components/card/topic-category-column";import TopicCreatorColumn from "../components/card/topic-creator-column";@@ -35,41 +37,93 @@ const TopicCreator = <template></td></template>;+function isHighContextRoute(routeName) {+ if (!routeName) {+ return false;+ }++ // Only show high context cards on public topic list routes+ // Discovery routes: /latest, /new, /unread, /top, /hot, /c/:category+ if (routeName.startsWith("discovery")) {+ return true;+ }++ // Tag routes: /tag/:tag_name+ if (routeName.startsWith("tag")) {+ return true;+ }++ return false;+}++const HighContextCard = <template>+ <HighContextTopicCard+ @topic={{@topic}}+ @hideCategory={{@hideCategory}}+ @bulkSelectEnabled={{@bulkSelectEnabled}}+ @isSelected={{@isSelected}}+ @onBulkSelectToggle={{@onBulkSelectToggle}}+ />+</template>;+export default {name: "topic-list-customizations",initialize(container) {+ const isHighContext = settings.topic_card_context === "high_context";const router = container.lookup("service:router");++ function applySimpleLayout(columns) {+ columns.add("topic-status", {+ item: TopicStatus,+ after: "topic-author",+ });+ columns.add("topic-category", {+ item: TopicCategory,+ after: "topic-status",+ });+ columns.add("topic-likes-replies", {+ item: TopicReplies,+ after: "topic-author-avatar",+ });+ columns.add("topic-creator", {+ item: TopicCreator,+ after: "topic-author-avatar",+ });++ columns.delete("views");+ columns.delete("replies");++ if (!router.currentRouteName.includes("userPrivateMessages")) {+ columns.add("topic-activity", {+ item: TopicActivity,+ after: "title",+ });+ columns.delete("posters");+ columns.delete("activity");+ }+ }++ function applyHighContextLayout(columns) {+ columns.delete("bulk-select");+ columns.delete("topic");+ columns.delete("posters");+ columns.delete("replies");+ columns.delete("views");+ columns.delete("activity");+ columns.add("high-context-card", {+ item: HighContextCard,+ });+ }+withPluginApi((api) => {api.registerValueTransformer("topic-list-columns",({ value: columns }) => {- columns.add("topic-status", {- item: TopicStatus,- after: "topic-author",- });- columns.add("topic-category", {- item: TopicCategory,- after: "topic-status",- });-- columns.add("topic-likes-replies", {- item: TopicReplies,- after: "topic-author-avatar",- });- columns.add("topic-creator", {- item: TopicCreator,- after: "topic-author-avatar",- });- columns.delete("views");- columns.delete("replies");- if (!router.currentRouteName.includes("userPrivateMessages")) {- columns.add("topic-activity", {- item: TopicActivity,- after: "title",- });- columns.delete("posters");- columns.delete("activity");+ if (isHighContext && isHighContextRoute(router.currentRouteName)) {+ applyHighContextLayout(columns);+ } else {+ applySimpleLayout(columns);}return columns;}@@ -78,6 +132,20 @@ export default {api.registerValueTransformer("topic-list-item-class",({ value: classes, context }) => {+ // has-replies is needed for grid layout on all routes (including PMs)+ if (context.topic.replyCount > 1) {+ classes.push("has-replies");+ }++ // The rest only applies to public topic list routes+ if (!isHighContextRoute(router.currentRouteName)) {+ return classes;+ }++ if (isHighContext) {+ classes.push("--high-context");+ }+if (context.topic.is_hot ||context.topic.pinned ||@@ -85,20 +153,26 @@ export default {) {classes.push("--has-status-card");}- if (context.topic.replyCount > 1) {- classes.push("has-replies");- }+return classes;});+ // Force desktop layout on public topic lists for Horizon card styling.+ // Return undefined on other routes to preserve default mobile/desktop behavior.api.registerValueTransformer("topic-list-item-mobile-layout", () => {- return false;+ if (isHighContextRoute(router.currentRouteName)) {+ return false;+ }});api.registerBehaviorTransformer("topic-list-item-click",({ context: { event }, next }) => {+ if (!isHighContextRoute(router.currentRouteName)) {+ return next(); // Use default behavior on non-public routes+ }+if (event.target.closest("a, button, input")) {return next();}@@ -110,7 +184,7 @@ export default {.closest("tr").querySelector("a.raw-topic-link");- // Redespatch the click on the topic link, so that all key-handing is sorted+ // Redispatch the click on the topic link, so that all key-handing is sortedtopicLink.dispatchEvent(new MouseEvent("click", {ctrlKey: event.ctrlKey,diff --git a/themes/horizon/locales/en.yml b/themes/horizon/locales/en.ymlindex 4f27b34a032..f64b4161280 100644--- a/themes/horizon/locales/en.yml+++ b/themes/horizon/locales/en.yml@@ -1,3 +1,23 @@en:+ solved: "Solved"+ unsolved: "Unsolved"+ posted: "posted"+ by_username: "by @%{username}"+ replied: "replied"+ vote_count:+ one: "%{count} vote"+ other: "%{count} votes"+ like_count:+ one: "%{count} like"+ other: "%{count} likes"+ reply_count:+ one: "%{count} reply"+ other: "%{count} replies"theme_metadata:description: "A simple, beautiful theme that improves the out of the box experience for Discourse sites."+ settings:+ topic_card_context:+ description: "Amount of information displayed on topic cards. 'Simple' shows minimal info. 'High Context' includes tags, solved status, assigned users, and vote counts."+ choices:+ simple: "Simple"+ high_context: "High Context (experimental)"diff --git a/themes/horizon/scss/high-context-cards.scss b/themes/horizon/scss/high-context-cards.scssnew file mode 100644index 00000000000..5036da7f3f3--- /dev/null+++ b/themes/horizon/scss/high-context-cards.scss@@ -0,0 +1,356 @@+@use "lib/viewport";++:root {+ --topic-card-shadow: rgb(var(--tertiary-rgb), 0.1);+ --title-color--read: var(--primary-medium);+ --topic-title-font-weight--visited: 700;+}++$padding-pills-small: var(--space-half) var(--space-2);++.topic-list-data {+ display: none;+}++.topic-list-body:has(.--high-context) {+ @include viewport.from(sm) {+ gap: var(--space-4);+ }+}++.topic-list-item.--high-context {+ display: block;+ background: var(--secondary);+ padding: 0;++ &.closed {+ opacity: 0.9;+ }++ &.bulk-selected {+ background: var(--tertiary-low);+ border-color: var(--tertiary);++ &:hover {+ background: var(--tertiary-medium);+ }+ }++ @include viewport.from(sm) {+ border: 1px solid var(--primary-low);+ border-radius: var(--d-border-radius-large);+ }++ @include viewport.until(sm) {+ border-bottom: 1px solid var(--primary-low);+ }++ .bulk-select-enabled & {+ &.bulk-selected {+ background: var(--secondary);+ }++ > .bulk-select {+ display: none;+ }+ }+}++.hc-topic-card {+ display: flex;+ flex-direction: column;+ gap: var(--space-3);+ padding: var(--space-4) var(--space-5);+ width: 100%;+ box-sizing: border-box;++ @include viewport.until(sm) {+ padding: var(--space-4) 0;++ > *:not(.hc-topic-card__footer) {+ padding-inline: var(--space-4);+ }+ }++ @include viewport.from(sm) {+ padding: var(--space-4);+ }++ &__header {+ display: flex;+ justify-content: space-between;+ align-items: flex-start;++ @include viewport.until(sm) {+ align-items: center;+ }+ }++ &__op {+ display: flex;+ align-items: center;+ gap: var(--space-2);+ color: var(--primary-medium);+ font-size: var(--font-down-1-rem);+ }++ &__op-info {+ display: flex;+ flex-direction: column;+ }++ &__avatar {+ flex-shrink: 0;++ .avatar {+ border-radius: var(--d-border-radius);+ height: 32px;+ width: 32px;+ }+ }++ &__status {+ position: relative;+ display: inline-flex;+ align-items: center;+ gap: var(--space-1);+ border-radius: var(--d-border-radius);+ white-space: nowrap;+ background: var(--secondary);+ border: 1px solid var(--primary-low-mid);+ font-weight: 700;++ @include viewport.from(sm) {+ padding: $padding-pills-small;+ }++ @include viewport.until(sm) {+ padding: var(--space-1);+ border-radius: calc(var(--d-border-radius) / 2);+ }++ &.--solved {+ color: var(--success);+ font-weight: 700;+ border-color: var(--success);+ }++ &.--pinned {+ font-weight: 700;+ }++ &.--hot {+ border: 1px solid var(--danger);+ color: var(--danger);+ }+ }++ &__category .badge-category__wrapper {+ padding: var(--space-half) var(--space-2) !important;+ font-size: var(--font-down-1-rem);+ border-radius: var(--d-border-radius-small) !important;+ }++ &__status-tags {+ display: inline-flex;+ align-items: center;+ gap: var(--space-3);++ @include viewport.from(sm) {+ font-size: var(--font-down-2-rem);+ }++ @include viewport.until(sm) {+ font-size: var(--font-0);+ }+ }++ &__content {+ display: flex;+ flex-direction: column;+ gap: var(--space-2);+ }++ &__bulk-select {+ display: inline-flex;+ align-items: center;+ margin-right: var(--space-2);+ cursor: pointer;+ }++ &__title {+ font-weight: 700;+ font-size: var(--font-up-1-rem);+ color: var(--primary);+ text-decoration: none;+ line-height: 1.3;++ a {+ color: var(--primary);+ word-break: break-word;+ }++ .topic-status.--pinned,+ .topic-status.--unpinned,+ .topic-status.--solved,+ .topic-status.--unsolved {+ display: none;+ }+ }++ .topic-excerpt {+ span {+ word-break: break-word;+ }++ .--high-context & {+ color: var(--primary-high);+ line-height: 1.25;+ display: -webkit-box;+ -webkit-line-clamp: 2;+ -webkit-box-orient: vertical;+ overflow: hidden;+ font-size: var(--font-0);+ }+ }++ &__context {+ display: flex;+ gap: var(--space-3);+ flex-wrap: wrap;+ }++ &__assigned {+ display: inline-flex;+ align-items: center;+ gap: var(--space-1);+ padding: $padding-pills-small;+ border-radius: var(--d-border-radius-small);+ background: var(--primary-very-low);+ color: var(--primary-medium);+ font-size: var(--font-down-2-rem);+ }++ &__tags {+ flex-shrink: 0;+ display: flex;+ gap: var(--space-2);+ flex-wrap: wrap;++ .discourse-tags__tag-separator {+ display: none;+ }++ .discourse-tag {+ padding: var(--space-half) var(--space-2);+ border-radius: var(--d-border-radius-small);+ border: 1px solid var(--primary-low);+ background: var(--secondary);+ color: var(--primary-high);+ white-space: nowrap;+ font-size: var(--font-down-2-rem);++ &.assigned-to,+ &.list-vote-count {+ display: none;+ }+ }+ }++ &__footer {+ position: relative;+ display: flex;+ flex-wrap: wrap;+ align-items: center;+ gap: var(--space-3);++ @include viewport.from(sm) {+ border-top: 1px solid var(--primary-low);+ padding-top: var(--space-3);+ }++ @include viewport.until(sm) {+ &::after {+ content: "";+ position: absolute;+ inset: 0;+ pointer-events: none;+ background: linear-gradient(+ to right,+ var(--secondary) 0,+ transparent 1rem,+ transparent calc(100% - 1rem),+ var(--secondary) 100%+ );+ }+ }+ }++ &__category-tags {+ display: flex;+ gap: var(--space-2);+ overflow: auto;++ @include viewport.until(sm) {+ padding-inline: var(--space-4);+ }++ &::-webkit-scrollbar {+ display: none; // Chrome/Safari+ }+ }++ &__category {+ flex-shrink: 0;+ }++ &__stats {+ display: flex;+ align-items: center;+ gap: var(--space-4);+ margin-left: auto;+ flex-shrink: 0;++ @include viewport.until(sm) {+ padding-inline: var(--space-4);+ }+ }++ &__replies,+ &__likes,+ &__votes {+ display: inline-flex;+ align-items: center;+ gap: var(--space-1);+ color: var(--primary-medium);+ font-size: var(--font-down-1-rem);+ }++ &__last-reply {+ display: inline-flex;+ align-items: center;+ gap: var(--space-1);+ padding: $padding-pills-small;+ border-radius: var(--d-border-radius-small);+ background: var(--primary-very-low);+ font-size: var(--font-down-2-rem);+ color: var(--primary-medium);++ .avatar {+ border-radius: 50%;+ height: 1rem;+ width: 1rem;+ }++ @include viewport.until(sm) {+ .avatar {+ width: 1rem;+ height: 1rem;+ }+ }+ }++ &__time {+ color: var(--primary-medium);+ }+}diff --git a/themes/horizon/scss/nav-pills.scss b/themes/horizon/scss/nav-pills.scssindex e30bcd85471..8edabff779e 100644--- a/themes/horizon/scss/nav-pills.scss+++ b/themes/horizon/scss/nav-pills.scss@@ -3,7 +3,7 @@top: var(--header-offset);background: var(--d-content-background);z-index: z("base") + 1;- padding: 1.5rem 0 1rem 0;+ padding: 1rem 0 0 0;max-width: unset;border-top-left-radius: var(--d-border-radius-large);border-top-right-radius: var(--d-border-radius-large);diff --git a/themes/horizon/scss/topic-cards.scss b/themes/horizon/scss/topic-cards.scssindex db342fdeaf3..af3a9152336 100644--- a/themes/horizon/scss/topic-cards.scss+++ b/themes/horizon/scss/topic-cards.scss@@ -4,6 +4,7 @@--d-border-radius-small: calc(var(--d-border-radius) * 0.5);--topic-list-item-background-color: var(--d-content-background);--topic-list-item-background-color--visited: var(--d-content-background);+ --topic-card-shadow: rgb(var(--tertiary-rgb), 0.1);}.topic-list .topic-list-item-separator {@@ -144,15 +145,14 @@&:hover {.discourse-no-touch & {- border-color: var(--accent-color);+ box-shadow: 1px 1px 12px 2px var(--topic-card-shadow);background: var(--d-content-background);}}&.selected {- box-shadow:- 0 0 0 2px var(--accent-color),- 0 0 12px 1px var(--topic-card-shadow);+ border: 1px solid var(--accent-color);+ box-shadow: 0 0 12px 1px var(--topic-card-shadow);.user-messages-page & {box-shadow: inset 0 0 0 2px var(--accent-color);@@ -244,7 +244,6 @@@include viewport.until(md) {padding: 0.25em 0.5rem;- font-size: var(--font-down-2);}.badge-category {diff --git a/themes/horizon/settings.yml b/themes/horizon/settings.ymlnew file mode 100644index 00000000000..bbe534ec261--- /dev/null+++ b/themes/horizon/settings.yml@@ -0,0 +1,6 @@+topic_card_context:+ type: enum+ default: simple+ choices:+ - simple+ - high_context