Skip to content

Commit

Permalink
FEATURE: Allows display topic thumbnails in kanban cards (#55)
Browse files Browse the repository at this point in the history
* FEATURE: Allows display topic thumbnails in kanban cards

This commit adds an optional setting to allow showing topic thumbnails on board cards.
  • Loading branch information
Lhcfl committed Jul 5, 2024
1 parent 8f2bd84 commit b3c36ce
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 0 deletions.
9 changes: 9 additions & 0 deletions common/common.scss
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,10 @@ html:has(body.kanban-active) {
}
}

&__thumbnail-row {
margin-top: 5px;
}

.last-post-by,
.topic-title {
flex-grow: 1;
Expand All @@ -162,6 +166,11 @@ html:has(body.kanban-active) {
}
}

.thumbnail {
overflow: hidden;
width: 100%;
}

.last-post-by {
text-align: left;
font-size: $font-down-2;
Expand Down
14 changes: 14 additions & 0 deletions javascripts/discourse/components/kanban/card.gjs
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,14 @@ export default class KanbanCard extends Component {
.map((t) => renderTag(t));
}

get showImage() {
return settings.show_topic_thumbnail && this.imageUrl;
}

get imageUrl() {
return this.args.topic.image_url;
}

get showCategory() {
const definitionCategory = this.args.definition.params.category;
const discoveryCategory = this.kanbanManager.discoveryCategory;
Expand Down Expand Up @@ -176,6 +184,12 @@ export default class KanbanCard extends Component {
</div>
{{/if}}

{{#if this.showImage}}
<div class="card-row card-row__thumbnail-row">
<img class="thumbnail" src={{this.imageUrl}} />
</div>
{{/if}}

<PluginOutlet
@name="kanban-card-bottom"
@outletArgs={{hash topic=@topic}}
Expand Down
4 changes: 4 additions & 0 deletions settings.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,7 @@ card_style:
choices:
- simple
- detailed
show_topic_thumbnail:
default: false
description:
en: Display the topic thumbnail at the bottom of the card

0 comments on commit b3c36ce

Please sign in to comment.