Spaces:
Sleeping
Sleeping
Keldos commited on
Commit ·
1c8e01a
1
Parent(s): 601c367
WIP: fix viewport height in mobile devices
Browse files
web_assets/javascript/ChuanhuChat.js
CHANGED
|
@@ -277,6 +277,11 @@ function setPopupBoxPosition() {
|
|
| 277 |
// chuanhuPopup.style.top = `${(screenHeight - popupBoxHeight) / 2}px`;
|
| 278 |
}
|
| 279 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 280 |
function setChatbotHeight() {
|
| 281 |
return;
|
| 282 |
const screenWidth = window.innerWidth;
|
|
@@ -345,17 +350,19 @@ var gradioObserver = new MutationObserver(function (mutations) {
|
|
| 345 |
// 监视页面变化
|
| 346 |
window.addEventListener("DOMContentLoaded", function () {
|
| 347 |
// const ga = document.getElementsByTagName("gradio-app");
|
|
|
|
| 348 |
gradioApp().addEventListener("render", initialize);
|
| 349 |
isInIframe = (window.self !== window.top);
|
| 350 |
historyLoaded = false;
|
| 351 |
});
|
| 352 |
window.addEventListener('resize', ()=>{
|
| 353 |
// setChatbotHeight();
|
|
|
|
| 354 |
setPopupBoxPosition();
|
| 355 |
adjustSide();
|
| 356 |
windowWidth = window.innerWidth;
|
| 357 |
});
|
| 358 |
-
window.addEventListener('scroll', ()=>{
|
| 359 |
window.matchMedia("(prefers-color-scheme: dark)").addEventListener("change", adjustDarkMode);
|
| 360 |
|
| 361 |
// console suprise
|
|
|
|
| 277 |
// chuanhuPopup.style.top = `${(screenHeight - popupBoxHeight) / 2}px`;
|
| 278 |
}
|
| 279 |
|
| 280 |
+
function updateVH() {
|
| 281 |
+
const vh = window.innerHeight * 0.01;
|
| 282 |
+
document.documentElement.style.setProperty('--vh', `${vh}px`);
|
| 283 |
+
}
|
| 284 |
+
|
| 285 |
function setChatbotHeight() {
|
| 286 |
return;
|
| 287 |
const screenWidth = window.innerWidth;
|
|
|
|
| 350 |
// 监视页面变化
|
| 351 |
window.addEventListener("DOMContentLoaded", function () {
|
| 352 |
// const ga = document.getElementsByTagName("gradio-app");
|
| 353 |
+
updateVH();
|
| 354 |
gradioApp().addEventListener("render", initialize);
|
| 355 |
isInIframe = (window.self !== window.top);
|
| 356 |
historyLoaded = false;
|
| 357 |
});
|
| 358 |
window.addEventListener('resize', ()=>{
|
| 359 |
// setChatbotHeight();
|
| 360 |
+
updateVH();
|
| 361 |
setPopupBoxPosition();
|
| 362 |
adjustSide();
|
| 363 |
windowWidth = window.innerWidth;
|
| 364 |
});
|
| 365 |
+
window.addEventListener('scroll', ()=>{setPopupBoxPosition();});
|
| 366 |
window.matchMedia("(prefers-color-scheme: dark)").addEventListener("change", adjustDarkMode);
|
| 367 |
|
| 368 |
// console suprise
|
web_assets/stylesheet/ChuanhuChat.css
CHANGED
|
@@ -1,4 +1,6 @@
|
|
| 1 |
:root {
|
|
|
|
|
|
|
| 2 |
--chatbot-color-light: #000000;
|
| 3 |
--chatbot-color-dark: #FFFFFF;
|
| 4 |
--chatbot-background-color-light: #F3F3F3;
|
|
@@ -237,10 +239,10 @@ body.popup-open {
|
|
| 237 |
display: inline-flex;
|
| 238 |
justify-content: space-between;
|
| 239 |
/* margin-top: 54px; */
|
| 240 |
-
/* height: calc(
|
| 241 |
position: absolute;
|
| 242 |
top: 65px;
|
| 243 |
-
height: calc(
|
| 244 |
}
|
| 245 |
|
| 246 |
#chuanhu-area {
|
|
@@ -403,7 +405,7 @@ body.popup-open {
|
|
| 403 |
#menu-area.showSide {
|
| 404 |
width: var(--menu-width);
|
| 405 |
max-width: var(--menu-width);
|
| 406 |
-
height: calc(
|
| 407 |
visibility: visible;
|
| 408 |
/* margin-right: 16px; */
|
| 409 |
border-right: 0.5px solid var(--border-color-primary);
|
|
@@ -415,7 +417,7 @@ body.popup-open {
|
|
| 415 |
}
|
| 416 |
#toolbox-area.showSide {
|
| 417 |
width: var(--toolbox-width);
|
| 418 |
-
height: calc(
|
| 419 |
visibility: visible;
|
| 420 |
/* margin-left: 16px; */
|
| 421 |
}
|
|
@@ -440,17 +442,17 @@ body.popup-open {
|
|
| 440 |
/* right: calc(0px - var(--toolbox-width)); */
|
| 441 |
z-index: 10008;
|
| 442 |
overflow: unset;
|
| 443 |
-
top:
|
| 444 |
margin: 0;
|
| 445 |
}
|
| 446 |
#toolbox-area > div {
|
| 447 |
width: 100vw;
|
| 448 |
-
height: calc(
|
| 449 |
}
|
| 450 |
#toolbox-area.showSide {
|
| 451 |
width: 100vw;
|
| 452 |
right: 0;
|
| 453 |
-
top: calc(
|
| 454 |
margin: 0;
|
| 455 |
border-radius: 6px;
|
| 456 |
box-shadow: 0 2px 64px 4px rgba(0, 0, 0, 0.2);
|
|
@@ -540,7 +542,7 @@ body.popup-open {
|
|
| 540 |
}
|
| 541 |
#chuanhu-popup {
|
| 542 |
width: 100vw;
|
| 543 |
-
height: calc(
|
| 544 |
border-radius: inherit inherit 0 0;
|
| 545 |
}
|
| 546 |
#toolbox-area > .gradio-box > .gradio-row:first-of-type,
|
|
@@ -556,7 +558,7 @@ body.popup-open {
|
|
| 556 |
}
|
| 557 |
#toolbox-area > .gradio-box > .gradio-tabs > div.tabitem,
|
| 558 |
#chuanhu-popup > .gradio-box > .gradio-tabs > div.tabitem {
|
| 559 |
-
height: calc(
|
| 560 |
overflow-x: auto;
|
| 561 |
border: none;
|
| 562 |
}
|
|
@@ -722,7 +724,7 @@ body.popup-open {
|
|
| 722 |
} */
|
| 723 |
|
| 724 |
#chuanhu-history {
|
| 725 |
-
height: calc(
|
| 726 |
overflow-y: auto;
|
| 727 |
}
|
| 728 |
#chuanhu-history > div {
|
|
@@ -807,14 +809,14 @@ body.popup-open {
|
|
| 807 |
overflow: hidden;
|
| 808 |
display: inline-flex;
|
| 809 |
/* margin-top: 54px; */
|
| 810 |
-
/* height: calc(
|
| 811 |
/* position: absolute;
|
| 812 |
top: 48px;
|
| 813 |
} */
|
| 814 |
/*
|
| 815 |
.hide-body {
|
| 816 |
display: none;
|
| 817 |
-
top: -
|
| 818 |
|
| 819 |
}
|
| 820 |
#train-body {
|
|
@@ -823,7 +825,7 @@ body.popup-open {
|
|
| 823 |
|
| 824 |
#chuanhu-body.hide-body {
|
| 825 |
display: none;
|
| 826 |
-
top: calc(
|
| 827 |
}
|
| 828 |
#chuanhu-body {
|
| 829 |
transition: top 0.3s ease-in-out, display 0.3s ease;
|
|
|
|
| 1 |
:root {
|
| 2 |
+
--vh: 1vh;
|
| 3 |
+
|
| 4 |
--chatbot-color-light: #000000;
|
| 5 |
--chatbot-color-dark: #FFFFFF;
|
| 6 |
--chatbot-background-color-light: #F3F3F3;
|
|
|
|
| 239 |
display: inline-flex;
|
| 240 |
justify-content: space-between;
|
| 241 |
/* margin-top: 54px; */
|
| 242 |
+
/* height: calc(100*var(--vh) - 72px); */
|
| 243 |
position: absolute;
|
| 244 |
top: 65px;
|
| 245 |
+
height: calc(100*var(--vh) - 65px);
|
| 246 |
}
|
| 247 |
|
| 248 |
#chuanhu-area {
|
|
|
|
| 405 |
#menu-area.showSide {
|
| 406 |
width: var(--menu-width);
|
| 407 |
max-width: var(--menu-width);
|
| 408 |
+
height: calc(100*var(--vh) - 65px);
|
| 409 |
visibility: visible;
|
| 410 |
/* margin-right: 16px; */
|
| 411 |
border-right: 0.5px solid var(--border-color-primary);
|
|
|
|
| 417 |
}
|
| 418 |
#toolbox-area.showSide {
|
| 419 |
width: var(--toolbox-width);
|
| 420 |
+
height: calc(100*var(--vh) - 65px);
|
| 421 |
visibility: visible;
|
| 422 |
/* margin-left: 16px; */
|
| 423 |
}
|
|
|
|
| 442 |
/* right: calc(0px - var(--toolbox-width)); */
|
| 443 |
z-index: 10008;
|
| 444 |
overflow: unset;
|
| 445 |
+
top: calc(100*var(--vh));
|
| 446 |
margin: 0;
|
| 447 |
}
|
| 448 |
#toolbox-area > div {
|
| 449 |
width: 100vw;
|
| 450 |
+
height: calc( 90*var(--vh) - 48px );
|
| 451 |
}
|
| 452 |
#toolbox-area.showSide {
|
| 453 |
width: 100vw;
|
| 454 |
right: 0;
|
| 455 |
+
top: calc( 10*var(--vh) + 48px );
|
| 456 |
margin: 0;
|
| 457 |
border-radius: 6px;
|
| 458 |
box-shadow: 0 2px 64px 4px rgba(0, 0, 0, 0.2);
|
|
|
|
| 542 |
}
|
| 543 |
#chuanhu-popup {
|
| 544 |
width: 100vw;
|
| 545 |
+
height: calc( 90*var(--vh) - 48px );
|
| 546 |
border-radius: inherit inherit 0 0;
|
| 547 |
}
|
| 548 |
#toolbox-area > .gradio-box > .gradio-row:first-of-type,
|
|
|
|
| 558 |
}
|
| 559 |
#toolbox-area > .gradio-box > .gradio-tabs > div.tabitem,
|
| 560 |
#chuanhu-popup > .gradio-box > .gradio-tabs > div.tabitem {
|
| 561 |
+
height: calc( 90*var(--vh) - 48px - 46px - 45px );
|
| 562 |
overflow-x: auto;
|
| 563 |
border: none;
|
| 564 |
}
|
|
|
|
| 724 |
} */
|
| 725 |
|
| 726 |
#chuanhu-history {
|
| 727 |
+
height: calc(100*var(--vh) - 65px - 61px);
|
| 728 |
overflow-y: auto;
|
| 729 |
}
|
| 730 |
#chuanhu-history > div {
|
|
|
|
| 809 |
overflow: hidden;
|
| 810 |
display: inline-flex;
|
| 811 |
/* margin-top: 54px; */
|
| 812 |
+
/* height: calc(100*var(--vh) - 72px); */
|
| 813 |
/* position: absolute;
|
| 814 |
top: 48px;
|
| 815 |
} */
|
| 816 |
/*
|
| 817 |
.hide-body {
|
| 818 |
display: none;
|
| 819 |
+
top: calc(-100*var(--vh));
|
| 820 |
|
| 821 |
}
|
| 822 |
#train-body {
|
|
|
|
| 825 |
|
| 826 |
#chuanhu-body.hide-body {
|
| 827 |
display: none;
|
| 828 |
+
top: calc(100*var(--vh) + 48px);
|
| 829 |
}
|
| 830 |
#chuanhu-body {
|
| 831 |
transition: top 0.3s ease-in-out, display 0.3s ease;
|
web_assets/stylesheet/chatbot.css
CHANGED
|
@@ -118,19 +118,19 @@ hr.append-display {
|
|
| 118 |
/* update on 2023.4.8: 高度的细致调整已写入JavaScript */
|
| 119 |
@media screen and (min-width: 500px) {
|
| 120 |
/* #chuanhu-chatbot {
|
| 121 |
-
height: calc(
|
| 122 |
}
|
| 123 |
#chuanhu-chatbot>.wrapper>.wrap {
|
| 124 |
-
max-height: calc(
|
| 125 |
} */
|
| 126 |
}
|
| 127 |
/* 屏幕宽度小于500px的设备 */
|
| 128 |
@media screen and (max-width: 499px) {
|
| 129 |
/* #chuanhu-chatbot {
|
| 130 |
-
height: calc(
|
| 131 |
}
|
| 132 |
#chuanhu-chatbot>.wrapper>.wrap {
|
| 133 |
-
max-height: calc(
|
| 134 |
} */
|
| 135 |
[data-testid = "bot"] {
|
| 136 |
max-width: calc(100% - 84px) !important;
|
|
@@ -147,7 +147,7 @@ hr.append-display {
|
|
| 147 |
}
|
| 148 |
|
| 149 |
#chuanhu-chatbot {
|
| 150 |
-
height: calc(
|
| 151 |
border-radius: 0;
|
| 152 |
}
|
| 153 |
#chuanhu-chatbot>.wrapper>.wrap {
|
|
|
|
| 118 |
/* update on 2023.4.8: 高度的细致调整已写入JavaScript */
|
| 119 |
@media screen and (min-width: 500px) {
|
| 120 |
/* #chuanhu-chatbot {
|
| 121 |
+
height: calc(100*var(--vh) - 200px);
|
| 122 |
}
|
| 123 |
#chuanhu-chatbot>.wrapper>.wrap {
|
| 124 |
+
max-height: calc(100*var(--vh) - 200px - var(--line-sm)*1rem - 2*var(--block-label-margin) );
|
| 125 |
} */
|
| 126 |
}
|
| 127 |
/* 屏幕宽度小于500px的设备 */
|
| 128 |
@media screen and (max-width: 499px) {
|
| 129 |
/* #chuanhu-chatbot {
|
| 130 |
+
height: calc(100*var(--vh) - 140px);
|
| 131 |
}
|
| 132 |
#chuanhu-chatbot>.wrapper>.wrap {
|
| 133 |
+
max-height: calc(100*var(--vh) - 140px - var(--line-sm)*1rem - 2*var(--block-label-margin) );
|
| 134 |
} */
|
| 135 |
[data-testid = "bot"] {
|
| 136 |
max-width: calc(100% - 84px) !important;
|
|
|
|
| 147 |
}
|
| 148 |
|
| 149 |
#chuanhu-chatbot {
|
| 150 |
+
height: calc(100*var(--vh) - 65px) !important;
|
| 151 |
border-radius: 0;
|
| 152 |
}
|
| 153 |
#chuanhu-chatbot>.wrapper>.wrap {
|