mirror of
https://github.com/discourse/discourse-ai.git
synced 2025-03-09 11:48:47 +00:00
DEV: Add wrapping classes and remove has()
usage (#281)
This commit is contained in:
parent
0902f74af5
commit
f6996a6ef0
@ -32,13 +32,33 @@ export default class AISuggestionDropdown extends Component {
|
|||||||
|
|
||||||
get showAIButton() {
|
get showAIButton() {
|
||||||
const minCharacterCount = 40;
|
const minCharacterCount = 40;
|
||||||
return this.composer.model.replyLength > minCharacterCount;
|
const isShowAIButton = this.composer.model.replyLength > minCharacterCount;
|
||||||
|
const composerFields = document.querySelector(".composer-fields");
|
||||||
|
|
||||||
|
if (composerFields) {
|
||||||
|
if (isShowAIButton) {
|
||||||
|
composerFields.classList.add("showing-ai-suggestions");
|
||||||
|
} else {
|
||||||
|
composerFields.classList.remove("showing-ai-suggestions");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return isShowAIButton;
|
||||||
}
|
}
|
||||||
|
|
||||||
get disableSuggestionButton() {
|
get disableSuggestionButton() {
|
||||||
return this.loading;
|
return this.loading;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@action
|
||||||
|
applyClasses() {
|
||||||
|
if (this.showAIButton) {
|
||||||
|
document.querySelector(".composer-fields")?.classList.add("showing-ai-suggestions");
|
||||||
|
} else {
|
||||||
|
document.querySelector(".composer-fields")?.classList.remove("showing-ai-suggestions");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@bind
|
@bind
|
||||||
onClickOutside(event) {
|
onClickOutside(event) {
|
||||||
const menu = document.querySelector(".ai-title-suggestions-menu");
|
const menu = document.querySelector(".ai-title-suggestions-menu");
|
||||||
@ -111,10 +131,18 @@ export default class AISuggestionDropdown extends Component {
|
|||||||
this.loading = false;
|
this.loading = false;
|
||||||
this.suggestIcon = "sync-alt";
|
this.suggestIcon = "sync-alt";
|
||||||
this.showMenu = true;
|
this.showMenu = true;
|
||||||
|
|
||||||
|
if (this.args.mode === "suggest_category") {
|
||||||
|
document.querySelector(".category-input")?.classList.add("showing-ai-suggestion-menu");
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
#closeMenu() {
|
#closeMenu() {
|
||||||
|
if (this.showMenu && this.args.mode === "suggest_category") {
|
||||||
|
document.querySelector(".category-input")?.classList.remove("showing-ai-suggestion-menu");
|
||||||
|
}
|
||||||
|
|
||||||
this.suggestIcon = "discourse-sparkles";
|
this.suggestIcon = "discourse-sparkles";
|
||||||
this.showMenu = false;
|
this.showMenu = false;
|
||||||
this.showErrors = false;
|
this.showErrors = false;
|
||||||
|
@ -249,7 +249,7 @@
|
|||||||
border-left: none;
|
border-left: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
.title-input:has(.suggestion-button) {
|
.showing-ai-suggestions .title-input {
|
||||||
// border on focus should be on top of suggestion button
|
// border on focus should be on top of suggestion button
|
||||||
input:focus {
|
input:focus {
|
||||||
z-index: 1;
|
z-index: 1;
|
||||||
@ -288,14 +288,14 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.category-input:has(.ai-suggestions-menu) {
|
.category-input.showing-ai-suggestion-menu {
|
||||||
position: relative;
|
position: relative;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Prevent suggestion button from wrapping on smaller screens
|
// Prevent suggestion button from wrapping on smaller screens
|
||||||
@media screen and (max-width: 768px) {
|
@media screen and (max-width: 768px) {
|
||||||
#reply-control {
|
#reply-control .composer-fields.showing-ai-suggestions {
|
||||||
.category-input:has(.suggestion-button) {
|
.category-input {
|
||||||
.category-chooser {
|
.category-chooser {
|
||||||
width: 10px;
|
width: 10px;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user