From a9afa0432989e4aa423bba9d4f791e1ee9379a43 Mon Sep 17 00:00:00 2001 From: Kris Date: Tue, 19 Nov 2024 15:33:34 -0500 Subject: [PATCH] UX: update gist toggle styles (#926) --- .../discourse/components/ai-gist-toggle.gjs | 67 +++++++++-------- .../discourse/components/ai-topic-gist.gjs | 33 ++++----- .../topic-list-gist-toggle.gjs | 15 ++++ .../discovery-above/mobile-gist-toggle.gjs | 13 ---- .../desktop-gist-toggle.gjs | 16 ---- .../discourse/services/gist-preference.js | 12 --- .../javascripts/discourse/services/gists.js | 29 ++++++++ .../summarization/common/ai-gists.scss | 65 ++++++++++++++++ .../summarization/common/ai-summary.scss | 74 ------------------- config/locales/client.en.yml | 8 +- plugin.rb | 2 + svg-icons/icons-sprite.svg | 16 ++++ 12 files changed, 186 insertions(+), 164 deletions(-) create mode 100644 assets/javascripts/discourse/connectors/before-create-topic-button/topic-list-gist-toggle.gjs delete mode 100644 assets/javascripts/discourse/connectors/discovery-above/mobile-gist-toggle.gjs delete mode 100644 assets/javascripts/discourse/connectors/topic-list-heading-bottom/desktop-gist-toggle.gjs delete mode 100644 assets/javascripts/discourse/services/gist-preference.js create mode 100644 assets/javascripts/discourse/services/gists.js create mode 100644 assets/stylesheets/modules/summarization/common/ai-gists.scss create mode 100644 svg-icons/icons-sprite.svg diff --git a/assets/javascripts/discourse/components/ai-gist-toggle.gjs b/assets/javascripts/discourse/components/ai-gist-toggle.gjs index 76f35157..24aaccbc 100644 --- a/assets/javascripts/discourse/components/ai-gist-toggle.gjs +++ b/assets/javascripts/discourse/components/ai-gist-toggle.gjs @@ -4,35 +4,43 @@ import { action } from "@ember/object"; import { service } from "@ember/service"; import DButton from "discourse/components/d-button"; import DropdownMenu from "discourse/components/dropdown-menu"; +import bodyClass from "discourse/helpers/body-class"; import icon from "discourse-common/helpers/d-icon"; import i18n from "discourse-common/helpers/i18n"; import DMenu from "float-kit/components/d-menu"; +import eq from "truth-helpers/helpers/eq"; export default class AiGistToggle extends Component { - @service router; - @service gistPreference; - - get shouldShow() { - return this.router.currentRoute.attributes?.list?.topics?.some( - (topic) => topic.ai_topic_gist - ); - } + @service gists; get buttons() { return [ { - id: "gists_enabled", - label: "discourse_ai.summarization.gists_enabled_long", - icon: "discourse-sparkles", + id: "table", + label: "discourse_ai.summarization.topic_list_layout.button.compact", + icon: "discourse-table", }, { - id: "gists_disabled", - label: "discourse_ai.summarization.gists_disabled", - icon: "far-eye-slash", + id: "table-ai", + label: "discourse_ai.summarization.topic_list_layout.button.expanded", + icon: "discourse-table-sparkles", + description: + "discourse_ai.summarization.topic_list_layout.button.expanded_description", }, ]; } + get selectedOptionId() { + return this.gists.get("preference"); + } + + get currentButton() { + const buttonPreference = this.buttons.find( + (button) => button.id === this.selectedOptionId + ); + return buttonPreference || this.buttons[0]; + } + @action onRegisterApi(api) { this.dMenu = api; @@ -40,29 +48,22 @@ export default class AiGistToggle extends Component { @action onSelect(optionId) { - this.gistPreference.setPreference(optionId); + this.gists.setPreference(optionId); this.dMenu.close(); }