diff --git a/pgml-dashboard/src/components/accordian/accordian.scss b/pgml-dashboard/src/components/accordian/accordian.scss index e90cb1ac5..dc1a279ce 100644 --- a/pgml-dashboard/src/components/accordian/accordian.scss +++ b/pgml-dashboard/src/components/accordian/accordian.scss @@ -4,13 +4,7 @@ div[data-controller="accordian"] { } .accordian-body { - display: none; - height: 0px; - transition: all 0.5s ease-in-out; - } - - .accordian-body.selected { - display: block; - height: auto; + overflow: hidden; + transition: all 0.3s ease-in-out; } } diff --git a/pgml-dashboard/src/components/accordian/accordian_controller.js b/pgml-dashboard/src/components/accordian/accordian_controller.js index b9eace831..d91ba65f6 100644 --- a/pgml-dashboard/src/components/accordian/accordian_controller.js +++ b/pgml-dashboard/src/components/accordian/accordian_controller.js @@ -1,18 +1,37 @@ import { Controller } from "@hotwired/stimulus"; export default class extends Controller { + initialize() { + this.bodies = document.getElementsByClassName("accordian-body"); + this.headers = document.getElementsByClassName("accordian-header"); + + this.heights = new Map(); + for (let i = 0; i < this.bodies.length; i++) { + this.heights.set(this.bodies[i], this.bodies[i].offsetHeight); + if (i > 0) { + this.bodies[i].style.maxHeight = "0px"; + } else { + this.bodies[i].style.maxHeight = this.bodies[i].offsetHeight + "px"; + } + } + } + + titleClick(e) { let target = e.currentTarget.getAttribute("data-value"); - let elements = document.getElementsByClassName("accordian-body"); - for (let i = 0; i < elements.length; i++) { - elements[i].classList.remove("selected"); - } - elements = document.getElementsByClassName("accordian-header"); - for (let i = 0; i < elements.length; i++) { - elements[i].classList.remove("selected"); - } - let element = document.querySelector(`[data-accordian-target="${target}"]`); - element.classList.add("selected"); e.currentTarget.classList.add("selected"); + + let body = document.querySelector(`[data-accordian-target="${target}"]`); + body.classList.add("selected"); + body.style.maxHeight = this.heights.get(body) + "px"; + + for (let i = 0; i < this.bodies.length; i++) { + if (body != this.bodies[i]) { + this.bodies[i].classList.remove("selected"); + this.bodies[i].style.maxHeight = "0px"; + } + if (e.currentTarget != this.headers[i]) + this.headers[i].classList.remove("selected"); + } } } diff --git a/pgml-dashboard/src/components/chatbot/chatbot.scss b/pgml-dashboard/src/components/chatbot/chatbot.scss index ded625965..f5964dc8f 100644 --- a/pgml-dashboard/src/components/chatbot/chatbot.scss +++ b/pgml-dashboard/src/components/chatbot/chatbot.scss @@ -59,8 +59,8 @@ div[data-controller="chatbot"] { } .chatbot-brain-option-logo { - height: 34px; - width: 34px; + height: 30px; + width: 30px; background-position: center; background-repeat: no-repeat; background-size: contain; diff --git a/pgml-dashboard/src/components/chatbot/chatbot_controller.js b/pgml-dashboard/src/components/chatbot/chatbot_controller.js index 515dea535..ef6703b33 100644 --- a/pgml-dashboard/src/components/chatbot/chatbot_controller.js +++ b/pgml-dashboard/src/components/chatbot/chatbot_controller.js @@ -65,7 +65,7 @@ const knowledgeBaseIdToName = (knowledgeBase) => { const createKnowledgeBaseNotice = (knowledgeBase) => { return ` -