From 361787b0b1e6d3f5e7c5153479c403cdd31d9175 Mon Sep 17 00:00:00 2001 From: David Taylor Date: Wed, 15 Jan 2025 17:08:26 +0000 Subject: [PATCH] DEV: Refactor to remove topic-list template overrides --- common/common.scss | 74 ++++++----------- desktop/desktop.scss | 29 +++++++ .../discourse/api-initializers/init-ghost.js | 14 ++-- .../ghost-additions.gjs | 25 ++++++ .../raw-templates/list/activity-column.hbr | 4 - .../raw-templates/list/post-column-count.hbr | 7 -- .../raw-templates/list/posters-column.hbr | 3 - .../raw-templates/list/topic-list-item.hbr | 51 ------------ .../raw-templates/list/visited-line.hbr | 3 - .../mobile/list/topic-list-item.hbr | 31 ------- .../raw-templates/topic-list-header.hbr | 1 - .../templates/components/topic-list.hbs | 31 ------- mobile/mobile.scss | 83 ++++++++++++++----- 13 files changed, 148 insertions(+), 208 deletions(-) create mode 100644 javascripts/discourse/connectors/topic-list-after-category/ghost-additions.gjs delete mode 100644 javascripts/discourse/raw-templates/list/activity-column.hbr delete mode 100644 javascripts/discourse/raw-templates/list/post-column-count.hbr delete mode 100644 javascripts/discourse/raw-templates/list/posters-column.hbr delete mode 100644 javascripts/discourse/raw-templates/list/topic-list-item.hbr delete mode 100644 javascripts/discourse/raw-templates/list/visited-line.hbr delete mode 100644 javascripts/discourse/raw-templates/mobile/list/topic-list-item.hbr delete mode 100644 javascripts/discourse/raw-templates/topic-list-header.hbr delete mode 100644 javascripts/discourse/templates/components/topic-list.hbs diff --git a/common/common.scss b/common/common.scss index 25460da..4922d5f 100644 --- a/common/common.scss +++ b/common/common.scss @@ -1120,10 +1120,10 @@ aside.quote .title { } .topic-list { - display: flex; - flex-direction: column; - list-style-type: none; - padding-left: 0; + thead { + display: none; + } + .badge-notification.new-topic { top: -3px; padding-left: 0; @@ -1152,18 +1152,10 @@ aside.quote .title { background: $separtor-background; } .topic-list-item { - display: flex; - flex-direction: row; - align-items: center; - margin-left: 0; background-color: #000; - padding: 4px 8px; margin-bottom: 8px; border-radius: 0; border-bottom: 1px solid $bios; - .topic-list-data { - padding: 0; - } &:hover { background-color: rgba(33, 36, 36, 1); @@ -1173,48 +1165,34 @@ aside.quote .title { animation-duration: 100ms; } - .main-link { + .num { display: flex; - flex-direction: column; - .link-top-line { + width: auto; + align-items: center; + margin-right: 8px; + a { + padding: 0; + } + .d-icon { + padding-right: 4px; } - .link-bottom-line { + &[href] { color: #5f6368; - line-height: 1; - .num { - display: flex; - width: auto; - margin-right: 8px; - a { - padding: 0; - } - .d-icon { - padding-right: 4px; - } - &[href] { - color: #5f6368; - } - } - .views { - width: auto; - margin-right: 8px; - } - .discourse-tag { - margin-right: 4px; - } - .discourse-tag.simple { - color: #5f6368; - } - .discourse-tag:before { - content: "#"; - color: #c4c7ca; - } } } - .fill { - flex: 1; + .ghost-views { + width: auto; + margin-right: 8px; } - .secondary { + .discourse-tag { + margin-right: 4px; + } + .discourse-tag.simple { + color: #5f6368; + } + .discourse-tag:before { + content: "#"; + color: #c4c7ca; } } } diff --git a/desktop/desktop.scss b/desktop/desktop.scss index d4f3b57..a1c69eb 100644 --- a/desktop/desktop.scss +++ b/desktop/desktop.scss @@ -1,5 +1,34 @@ @import "variables"; +.topic-list { + .topic-list-item { + display: flex; + flex-direction: row; + align-items: center; + } + .topic-list-data { + padding: 0; + } + .main-link { + padding: 4px 8px; + + flex-grow: 1; + display: flex; + flex-direction: column; + + .link-bottom-line { + color: #5f6368; + line-height: var(--line-height-large); + align-items: center; + } + } + .posters { + flex-grow: 0; + width: auto; + margin-right: 8px; + } +} + // admin:dashboard .dashboard-next { &.admin-contents { diff --git a/javascripts/discourse/api-initializers/init-ghost.js b/javascripts/discourse/api-initializers/init-ghost.js index fb08aca..023b4ae 100644 --- a/javascripts/discourse/api-initializers/init-ghost.js +++ b/javascripts/discourse/api-initializers/init-ghost.js @@ -2,14 +2,12 @@ import $ from "jquery"; import { apiInitializer } from "discourse/lib/api"; export default apiInitializer("0.8.0", (api) => { - api.modifyClass("component:topic-list", { - pluginId: "ghost", - tagName: "ul", - }); - - api.modifyClass("component:topic-list-item", { - pluginId: "ghost", - tagName: "li", + api.registerValueTransformer("topic-list-columns", ({ value: columns }) => { + columns.delete("views"); + columns.delete("likes"); + columns.delete("activity"); + columns.delete("replies"); + return columns; }); if (api.container.lookup("service:site").mobileView) { diff --git a/javascripts/discourse/connectors/topic-list-after-category/ghost-additions.gjs b/javascripts/discourse/connectors/topic-list-after-category/ghost-additions.gjs new file mode 100644 index 0000000..5a3d035 --- /dev/null +++ b/javascripts/discourse/connectors/topic-list-after-category/ghost-additions.gjs @@ -0,0 +1,25 @@ +import Component from "@glimmer/component"; +import { service } from "@ember/service"; +import icon from "discourse/helpers/d-icon"; +import formatDate from "discourse/helpers/format-date"; +import number from "discourse/helpers/number"; + +export default class GhostAdditionsComponent extends Component { + @service site; + + +} diff --git a/javascripts/discourse/raw-templates/list/activity-column.hbr b/javascripts/discourse/raw-templates/list/activity-column.hbr deleted file mode 100644 index 7a68d74..0000000 --- a/javascripts/discourse/raw-templates/list/activity-column.hbr +++ /dev/null @@ -1,4 +0,0 @@ -<{{tagName}} class="{{class}} {{cold-age-class topic.createdAt startDate=topic.bumpedAt class=""}} activity post-activity topic-list-data" href="{{topic.lastPostUrl}}" title="{{{topic.bumpedAtTitle}}}"> - {{~raw-plugin-outlet name="topic-list-before-relative-date"~}} - {{~format-date topic.bumpedAt format="tiny" noTitle="true"~}} - \ No newline at end of file diff --git a/javascripts/discourse/raw-templates/list/post-column-count.hbr b/javascripts/discourse/raw-templates/list/post-column-count.hbr deleted file mode 100644 index e6689f4..0000000 --- a/javascripts/discourse/raw-templates/list/post-column-count.hbr +++ /dev/null @@ -1,7 +0,0 @@ -<{{view.tagName}} class='posts-map posts {{view.likesHeat}} topic-list-data' title='{{view.title}}'> - - {{d-icon "far-comment"}} - {{raw-plugin-outlet name="topic-list-before-reply-count"}} - {{number topic.replyCount noTitle="true"}} - - \ No newline at end of file diff --git a/javascripts/discourse/raw-templates/list/posters-column.hbr b/javascripts/discourse/raw-templates/list/posters-column.hbr deleted file mode 100644 index c9f544c..0000000 --- a/javascripts/discourse/raw-templates/list/posters-column.hbr +++ /dev/null @@ -1,3 +0,0 @@ -{{#each posters as |poster|}} - {{avatar poster avatarTemplatePath="user.avatar_template" usernamePath="user.username" namePath="user.name" imageSize="small"}} -{{/each}} \ No newline at end of file diff --git a/javascripts/discourse/raw-templates/list/topic-list-item.hbr b/javascripts/discourse/raw-templates/list/topic-list-item.hbr deleted file mode 100644 index 8f0a19c..0000000 --- a/javascripts/discourse/raw-templates/list/topic-list-item.hbr +++ /dev/null @@ -1,51 +0,0 @@ -{{#if bulkSelectEnabled}} - - - -{{/if}} - -{{!-- - The `~` syntax strip spaces between the elements, making it produce - `Some text`, - with no space between them. - This causes the topic-post-badge to be considered the same word as "text" - at the end of the link, preventing it from line wrapping onto its own line. ---}} - - - {{~raw-plugin-outlet name="topic-list-before-status"}} - {{~raw "topic-status" topic=topic}} - {{~topic-link topic class="raw-link raw-topic-link"}} - {{~#if topic.featured_link}} - {{~topic-featured-link topic}} - {{~/if}} - {{~raw-plugin-outlet name="topic-list-after-title"}} - {{~#if showTopicPostBadges}} - {{~raw "topic-post-badges" unread=topic.unread unseen=topic.unseen url=topic.lastUnreadUrl newDotText=newDotText}} - {{~/if}} - - - {{#unless hideCategory}} - {{#unless topic.isPinnedUncategorized}} - {{category-link topic.category}} - {{/unless}} - {{/unless}} - {{raw "list/activity-column" topic=topic class="num" tagName="a"}} - {{raw "list/posts-count-column" topic=topic}} - - {{d-icon "far-eye"}} - {{number topic.views numberKey="views_long"}} - - {{discourse-tags topic mode="list" tagsForUser=tagsForUser}} - {{raw "list/action-list" topic=topic postNumbers=topic.liked_post_numbers className="likes" icon="heart"}} - - {{#if expandPinned}} - {{raw "list/topic-excerpt" topic=topic}} - {{/if}} - - - - {{#if showPosters}} - {{raw "list/posters-column" posters=topic.featuredUsers}} - {{/if}} - \ No newline at end of file diff --git a/javascripts/discourse/raw-templates/list/visited-line.hbr b/javascripts/discourse/raw-templates/list/visited-line.hbr deleted file mode 100644 index 5118e14..0000000 --- a/javascripts/discourse/raw-templates/list/visited-line.hbr +++ /dev/null @@ -1,3 +0,0 @@ -{{#if view.isLastVisited}} -
-{{/if}} \ No newline at end of file diff --git a/javascripts/discourse/raw-templates/mobile/list/topic-list-item.hbr b/javascripts/discourse/raw-templates/mobile/list/topic-list-item.hbr deleted file mode 100644 index b79c9dc..0000000 --- a/javascripts/discourse/raw-templates/mobile/list/topic-list-item.hbr +++ /dev/null @@ -1,31 +0,0 @@ -{{~#unless expandPinned}} - {{avatar topic.lastPosterUser imageSize="large"}} -{{/unless~}} - \ No newline at end of file diff --git a/javascripts/discourse/raw-templates/topic-list-header.hbr b/javascripts/discourse/raw-templates/topic-list-header.hbr deleted file mode 100644 index 3456590..0000000 --- a/javascripts/discourse/raw-templates/topic-list-header.hbr +++ /dev/null @@ -1 +0,0 @@ -{{! remove topic list header }} \ No newline at end of file diff --git a/javascripts/discourse/templates/components/topic-list.hbs b/javascripts/discourse/templates/components/topic-list.hbs deleted file mode 100644 index a537451..0000000 --- a/javascripts/discourse/templates/components/topic-list.hbs +++ /dev/null @@ -1,31 +0,0 @@ -{{plugin-outlet - name="before-topic-list-body" - args=(hash - topics=this.topics - selected=this.selected - bulkSelectEnabled=this.bulkSelectEnabled - lastVisitedTopic=this.lastVisitedTopic - discoveryList=this.discoveryList - hideCategory=this.hideCategory - ) - tagName="" - connectorTagName="" -}} - -{{#each this.filteredTopics as |topic|}} - {{topic-list-item - topic=topic - bulkSelectEnabled=this.bulkSelectEnabled - showTopicPostBadges=this.showTopicPostBadges - hideCategory=this.hideCategory - showPosters=this.showPosters - showLikes=this.showLikes - showOpLikes=this.showOpLikes - expandGloballyPinned=this.expandGloballyPinned - expandAllPinned=this.expandAllPinned - lastVisitedTopic=this.lastVisitedTopic - selected=this.selected - tagsForUser=this.tagsForUser - }} - {{raw "list/visited-line" lastVisitedTopic=this.lastVisitedTopic topic=topic}} -{{/each}} \ No newline at end of file diff --git a/mobile/mobile.scss b/mobile/mobile.scss index c718efd..1295a7b 100644 --- a/mobile/mobile.scss +++ b/mobile/mobile.scss @@ -155,31 +155,72 @@ } } -// base:topic-list -.topic-list { - margin-left: 0; - .topic-list-item { - align-items: start; - padding: 8px; - img.avatar { - margin-right: 8px; - } - .main-link { - line-height: 1.5; - } - .posts-map { - font-size: 1em; - display: flex; - } - .num.posts a { - font-weight: 400; - } +.topic-list .topic-list-item { + display: flex; + flex-direction: row; + align-items: center; + + padding: 4px 8px; + + .activity, + .pull-right { + display: none; + } + + .topic-list-data { + display: contents; } - .topic-excerpt { - width: auto; + + .topic-item-metadata { + margin-left: 8px; + flex-grow: 1; + } + + .pull-left { + float: unset; + } + + .topic-item-stats { + margin-top: 4px; + } + + .topic-item-stats__category-tags { + display: flex; + flex-direction: row; + flex-wrap: wrap; + align-items: center; + + .discourse-tags .discourse-tag { + margin-right: 4px; + } } } +// base:topic-list +// .topic-list { +// margin-left: 0; +// .topic-list-item { +// align-items: start; +// padding: 8px; +// img.avatar { +// margin-right: 8px; +// } +// .main-link { +// line-height: 1.5; +// } +// .posts-map { +// font-size: 1em; +// display: flex; +// } +// .num.posts a { +// font-weight: 400; +// } +// } +// .topic-excerpt { +// width: auto; +// } +// } + tr.category-topic-link { margin-top: 8px; border-bottom: 0;