UX: summary fixed positioning (#740)

Co-authored-by: Rafael Silva <xfalcox@gmail.com>
This commit is contained in:
chapoi 2024-08-05 17:39:08 +02:00 committed by GitHub
parent 5c9f610fa4
commit d17bbc2dc4
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 77 additions and 2 deletions

View File

@ -21,6 +21,7 @@ export default class AiSummaryBox extends Component {
@service siteSettings;
@service messageBus;
@service currentUser;
@service site;
@tracked text = "";
@tracked summarizedOn = null;
@ -123,7 +124,9 @@ export default class AiSummaryBox extends Component {
})
.then(() => {
if (update.done) {
this.summarizedOn = shortDateNoYear(topicSummary.updated_at);
this.summarizedOn = shortDateNoYear(
moment(topicSummary.updated_at, "YYYY-MM-DD HH:mm:ss Z")
);
this.summarizedBy = topicSummary.algorithm;
this.newPostsSinceSummary = topicSummary.new_posts_since_summary;
this.outdated = topicSummary.outdated;
@ -134,6 +137,17 @@ export default class AiSummaryBox extends Component {
});
}
@action
onRegisterApi(api) {
this.dMenu = api;
}
@action
async onClose() {
await this.dMenu.close();
this.unsubscribe();
}
<template>
{{#if @outletArgs.topic.summarizable}}
<div
@ -145,6 +159,7 @@ export default class AiSummaryBox extends Component {
@onShow={{this.generateSummary}}
@arrow={{true}}
@identifier="topic-map__ai-summary"
@onRegisterApi={{this.onRegisterApi}}
@interactive={{true}}
@triggers="click"
@placement="left"
@ -158,7 +173,18 @@ export default class AiSummaryBox extends Component {
>
<:content>
<div class="ai-summary-container">
<h3>Topic Summary</h3>
<header class="ai-summary__header">
<h3>{{i18n "discourse_ai.summarization.topic.title"}}</h3>
{{#if this.site.desktopView}}
<DButton
@title="discourse_ai.summarization.topic.close"
@action={{this.onClose}}
@icon="times"
@class="btn-transparent ai-summary__close"
/>
{{/if}}
</header>
<article class="ai-summary-box">
{{#if this.loading}}
<AiSummarySkeleton />

View File

@ -0,0 +1,45 @@
.topic-map {
.ai-summarization-button {
.fk-d-menu {
position: fixed;
top: calc(var(--header-offset) + 1rem) !important;
left: unset !important;
right: 1rem !important;
width: 470px;
max-width: 470px !important; //overruling JS
max-height: calc(100vh - var(--header-offset) - 3rem);
&__inner-content {
max-height: unset;
padding: 0;
}
.ai-summary__header,
.ai-summary-box {
padding-inline: 1.5rem;
box-sizing: border-box;
}
.ai-summary {
&__header {
position: sticky;
top: 0;
display: flex;
justify-content: space-between;
align-items: center;
padding-block: 0.5rem;
padding-right: 0.5rem;
background: var(--secondary);
border-bottom: 1px solid var(--primary-low);
h3 {
margin: 0;
}
}
&-box {
padding-bottom: 1rem;
}
}
}
}
}

View File

@ -404,6 +404,9 @@ en:
since:
one: "Last hour"
other: "Last %{count} hours"
topic:
title: "Topic summary"
close: "Close summary panel"
review:
types:
reviewable_ai_post:

View File

@ -16,6 +16,7 @@ enabled_site_setting :discourse_ai_enabled
register_asset "stylesheets/modules/ai-helper/common/ai-helper.scss"
register_asset "stylesheets/modules/summarization/common/ai-summary.scss"
register_asset "stylesheets/modules/summarization/desktop/ai-summary.scss", :desktop
register_asset "stylesheets/modules/ai-bot/common/bot-replies.scss"
register_asset "stylesheets/modules/ai-bot/common/ai-persona.scss"