Skip to content

Commit d6deb26

Browse files
committed
first commit
1 parent 2ecadba commit d6deb26

File tree

13 files changed

+199
-11
lines changed

13 files changed

+199
-11
lines changed

README.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,8 @@
22

33
**Theme Summary**
44

5-
For more information, please see: **url to meta topic**
5+
Shows a tooltip containing excerpts or AI gists on topic list title hover.
6+
7+
Replaces the functionality of the [Discourse Tooltips](https://github.com/discourse/discourse-tooltips/) plugin using a theme component.
8+
9+
![Topic List Tooltips](screenshots/light-screenshot.jpg)

about.json

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,12 @@
44
"authors": "Discourse",
55
"about_url": "TODO: Put your theme's public repo or Meta topic URL here",
66
"license_url": "TODO: Put your theme's LICENSE URL here",
7-
"learn_more": "TODO",
87
"theme_version": "0.0.1",
9-
"minimum_discourse_version": null,
10-
"maximum_discourse_version": null,
11-
"assets": {},
12-
"modifiers": {}
13-
}
8+
"modifiers": {
9+
"serialize_topic_excerpts": true
10+
},
11+
"screenshots": [
12+
"screenshots/light-screenshot.jpg",
13+
"screenshots/dark-screenshot.jpg"
14+
]
15+
}

common/common.scss

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
.topic-list-body .link-top-line {
2+
.fk-d-tooltip__trigger,
3+
.fk-d-tooltip__trigger-container {
4+
display: inline;
5+
}
6+
}

javascripts/.gitkeep

Whitespace-only changes.
Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
import Component from "@glimmer/component";
2+
import { getOwner } from "@ember/owner";
3+
import { htmlSafe } from "@ember/template";
4+
import replaceEmoji from "discourse/helpers/replace-emoji";
5+
import DTooltip from "float-kit/components/d-tooltip";
6+
7+
const triggers = {
8+
mobile: ["hover"],
9+
desktop: ["hover"],
10+
};
11+
12+
let TABLE_AI_LAYOUT = "table-ai";
13+
import("discourse/plugins/discourse-ai/discourse/services/gists")
14+
.then((module) => {
15+
TABLE_AI_LAYOUT = module.TABLE_AI_LAYOUT;
16+
})
17+
.catch(() => {
18+
// use fallback
19+
});
20+
21+
export default class TopicListTooltip extends Component {
22+
get gistsService() {
23+
try {
24+
return getOwner(this).lookup("service:gists");
25+
} catch (e) {
26+
return null;
27+
}
28+
}
29+
30+
get gistsPreference() {
31+
return this.gistsService?.currentPreference ?? null;
32+
}
33+
34+
get isGistModeActive() {
35+
return this.gistsPreference === TABLE_AI_LAYOUT;
36+
}
37+
38+
get shouldShowGistTooltip() {
39+
return (
40+
settings.tooltip_content === "ai_topic_gist" &&
41+
this.args.topic.ai_topic_gist &&
42+
!this.isGistModeActive
43+
);
44+
}
45+
46+
get shouldShowExcerptTooltip() {
47+
return (
48+
settings.tooltip_content === "first_post_excerpt" &&
49+
this.args.topic.excerpt &&
50+
!this.isGistModeActive
51+
);
52+
}
53+
54+
get shouldShowTooltip() {
55+
return this.shouldShowGistTooltip || this.shouldShowExcerptTooltip;
56+
}
57+
58+
get tooltipContent() {
59+
if (this.shouldShowGistTooltip) {
60+
return this.args.topic.ai_topic_gist;
61+
}
62+
if (this.shouldShowExcerptTooltip) {
63+
return replaceEmoji(htmlSafe(this.args.topic.excerpt));
64+
}
65+
return null;
66+
}
67+
68+
<template>
69+
{{#if this.shouldShowTooltip}}
70+
<DTooltip
71+
@triggers={{triggers}}
72+
@untriggers={{triggers}}
73+
@placement="bottom-start"
74+
>
75+
<:trigger>
76+
{{yield}}
77+
</:trigger>
78+
<:content>
79+
<div class="d-tooltip-content">
80+
{{this.tooltipContent}}
81+
</div>
82+
</:content>
83+
</DTooltip>
84+
{{else}}
85+
{{yield}}
86+
{{/if}}
87+
</template>
88+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import TopicListTooltip from "../../components/topic-list-tooltip";
2+
3+
<template>
4+
<TopicListTooltip @topic={{@outletArgs.topic}}>
5+
{{yield}}
6+
</TopicListTooltip>
7+
</template>

locales/en.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
en:
22
theme_metadata:
3-
description: Show topic excerpts or gists on hover
3+
description: Show a tooltip containing excerpts or AI gists on topic list title hover
44
settings:
5-
example_setting: A description of a setting.
5+
tooltip_content: "Choose what content to display in topic tooltips. <p>To use AI topic gists, you must have the <a href='/admin/plugins/discourse-ai/settings?filter=ai_summary_gists_enabled'>Discourse AI plugin enabled with gists configured</a>. Gists will only appear as tooltips when they are not already displayed inline in the topic list.</p>"

screenshots/dark-screenshot.jpg

50.5 KB
Loading

screenshots/light-screenshot.jpg

49.7 KB
Loading

settings.yml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,6 @@
1-
example_setting:
2-
default: true
1+
tooltip_content:
2+
type: enum
3+
default: first_post_excerpt
4+
choices:
5+
- first_post_excerpt
6+
- ai_topic_gist

0 commit comments

Comments
 (0)