1
1
mirror of https://github.com/leon-ai/leon.git synced 2024-11-28 12:43:35 +03:00

feat(web app): add "Show more" when answer is "too big"

This commit is contained in:
Théo LUDWIG 2023-07-01 23:33:41 +02:00
parent 2ad6541c3e
commit c512b422e7
No known key found for this signature in database
GPG Key ID: ADFE5A563D718F3B
3 changed files with 32 additions and 0 deletions

View File

@ -287,6 +287,17 @@ small {
.bubble-container.leon {
text-align: left;
}
.show-more {
margin: 3px;
text-decoration: underline;
}
.show-more:hover {
cursor: pointer;
text-decoration: none;
}
.show-all {
max-height: 100% !important;
}
.bubble {
padding: 6px 12px;
@ -297,6 +308,7 @@ small {
text-align: left;
opacity: 0;
animation: fadeIn 0.2s ease-in forwards;
overflow: hidden;
}
#feed .me .bubble {
background-color: #1c75db;

View File

@ -1,3 +1,5 @@
const MAXIMUM_HEIGHT_TO_SHOW_SEE_MORE = 340
export default class Chatbot {
constructor() {
this.et = new EventTarget()
@ -95,6 +97,23 @@ export default class Chatbot {
this.feed.appendChild(container).appendChild(bubble)
if (container.clientHeight > MAXIMUM_HEIGHT_TO_SHOW_SEE_MORE) {
bubble.style.maxHeight = `${MAXIMUM_HEIGHT_TO_SHOW_SEE_MORE}px`
const showMore = document.createElement('p')
const showMoreText = 'Show more'
showMore.className = 'show-more'
showMore.innerHTML = showMoreText
container.appendChild(showMore)
showMore.addEventListener('click', () => {
bubble.classList.toggle('show-all')
showMore.innerHTML =
showMore.innerHTML === showMoreText ? 'Show less' : showMoreText
})
}
if (save) {
this.saveBubble(who, string)
}

View File

@ -2,6 +2,7 @@
"compilerOptions": {
"useDefineForClassFields": true,
"skipLibCheck": true,
"module": "ESNext",
/* Bundler mode */
"moduleResolution": "bundler",
"allowImportingTsExtensions": true,