Update app.py
Browse files
app.py
CHANGED
|
@@ -631,105 +631,118 @@ footer {display: none !important;}
|
|
| 631 |
|
| 632 |
/* MOBIL-ANPASSNINGAR - FOKUS PÅ SCROLLNING OCH KOMPAKT LAYOUT */
|
| 633 |
@media (max-width: 768px) {
|
| 634 |
-
/*
|
| 635 |
-
html
|
| 636 |
width: 100% !important;
|
| 637 |
height: 100% !important;
|
| 638 |
margin: 0 !important;
|
| 639 |
padding: 0 !important;
|
| 640 |
-
overflow
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 641 |
overflow-x: hidden !important;
|
| 642 |
background-color: #ffffff !important;
|
| 643 |
-webkit-overflow-scrolling: touch !important;
|
|
|
|
|
|
|
| 644 |
}
|
| 645 |
|
| 646 |
/* Gradio app ska tillåta scrollning */
|
| 647 |
.gradio-app {
|
| 648 |
width: 100% !important;
|
| 649 |
-
min-height: 100vh !important;
|
| 650 |
margin: 0 !important;
|
| 651 |
padding: 0 !important;
|
| 652 |
-
overflow
|
|
|
|
| 653 |
}
|
| 654 |
|
| 655 |
-
/* Container för mobil -
|
| 656 |
.gradio-container {
|
| 657 |
-
position:
|
| 658 |
width: 100% !important;
|
| 659 |
-
min-height: 100vh !important;
|
| 660 |
max-width: none !important;
|
| 661 |
margin: 0 !important;
|
| 662 |
padding: 8px !important;
|
| 663 |
box-shadow: none !important;
|
| 664 |
border-radius: 0 !important;
|
| 665 |
background-color: #ffffff !important;
|
| 666 |
-
display:
|
| 667 |
-
flex-direction: column !important;
|
| 668 |
box-sizing: border-box !important;
|
|
|
|
| 669 |
}
|
| 670 |
|
| 671 |
/* Minimera header-utrymme */
|
| 672 |
.gradio-container > .gr-markdown:first-child {
|
| 673 |
-
|
| 674 |
font-size: 12px !important;
|
| 675 |
line-height: 1.2 !important;
|
| 676 |
-
margin: 0 0 4px 0 !important;
|
| 677 |
-
padding: 4px 8px !important;
|
| 678 |
background-color: #f8f9fa !important;
|
| 679 |
border-radius: 4px !important;
|
| 680 |
text-align: center !important;
|
| 681 |
}
|
| 682 |
|
| 683 |
-
/* Chat-
|
| 684 |
.gradio-container > .gr-group {
|
| 685 |
-
|
| 686 |
-
|
| 687 |
-
flex-direction: column !important;
|
| 688 |
-
margin: 0 !important;
|
| 689 |
padding: 0 !important;
|
| 690 |
-
|
| 691 |
}
|
| 692 |
|
| 693 |
-
/*
|
| 694 |
#chatbot_conversation {
|
| 695 |
-
|
| 696 |
-
|
| 697 |
-
|
| 698 |
-
|
| 699 |
-
|
|
|
|
| 700 |
overflow-y: auto !important;
|
|
|
|
| 701 |
border: 1px solid #e9ecef !important;
|
| 702 |
border-radius: 4px !important;
|
| 703 |
background-color: #ffffff !important;
|
| 704 |
-webkit-overflow-scrolling: touch !important;
|
|
|
|
| 705 |
}
|
| 706 |
|
| 707 |
-
/*
|
| 708 |
-
#chatbot_conversation .message {
|
| 709 |
-
margin: 2px 0 !important;
|
| 710 |
-
padding: 4px !important;
|
| 711 |
-
}
|
| 712 |
-
|
| 713 |
-
/* Input och knappar - kompakta */
|
| 714 |
.gradio-container .gr-row {
|
| 715 |
-
|
| 716 |
-
margin:
|
|
|
|
| 717 |
}
|
| 718 |
|
| 719 |
/* Textbox för mobil */
|
| 720 |
.gr-textbox {
|
| 721 |
-
margin: 0 !important;
|
|
|
|
| 722 |
}
|
| 723 |
|
| 724 |
.gr-textbox textarea {
|
| 725 |
font-size: 16px !important;
|
| 726 |
-
padding: 8px !important;
|
| 727 |
border: 1px solid #e9ecef !important;
|
| 728 |
border-radius: 4px !important;
|
| 729 |
resize: none !important;
|
| 730 |
width: 100% !important;
|
| 731 |
box-sizing: border-box !important;
|
| 732 |
-
min-height: 38px !important;
|
|
|
|
|
|
|
|
|
|
| 733 |
}
|
| 734 |
|
| 735 |
.gr-textbox textarea:focus {
|
|
@@ -737,13 +750,14 @@ footer {display: none !important;}
|
|
| 737 |
outline: none !important;
|
| 738 |
}
|
| 739 |
|
| 740 |
-
/*
|
| 741 |
.gr-button {
|
|
|
|
| 742 |
width: 100% !important;
|
| 743 |
-
padding: 10px 12px !important;
|
| 744 |
-
margin:
|
| 745 |
font-size: 14px !important;
|
| 746 |
-
min-height: 40px !important;
|
| 747 |
border-radius: 4px !important;
|
| 748 |
box-sizing: border-box !important;
|
| 749 |
white-space: nowrap !important;
|
|
@@ -753,21 +767,24 @@ footer {display: none !important;}
|
|
| 753 |
|
| 754 |
/* Knapp-kolumner */
|
| 755 |
.gradio-container .gr-column {
|
|
|
|
| 756 |
width: 100% !important;
|
| 757 |
margin: 0 !important;
|
| 758 |
-
padding: 0
|
| 759 |
}
|
| 760 |
|
| 761 |
-
/*
|
| 762 |
.gr-form {
|
| 763 |
-
|
| 764 |
-
|
|
|
|
| 765 |
border-radius: 4px !important;
|
| 766 |
background-color: #f8f9fa !important;
|
|
|
|
| 767 |
}
|
| 768 |
|
| 769 |
.gr-form .gr-textbox {
|
| 770 |
-
margin:
|
| 771 |
}
|
| 772 |
|
| 773 |
.gr-form .gr-textbox input,
|
|
@@ -777,7 +794,7 @@ footer {display: none !important;}
|
|
| 777 |
border-radius: 4px !important;
|
| 778 |
}
|
| 779 |
|
| 780 |
-
/*
|
| 781 |
.chat-preview {
|
| 782 |
max-height: 80px !important;
|
| 783 |
font-size: 11px !important;
|
|
@@ -789,7 +806,7 @@ footer {display: none !important;}
|
|
| 789 |
-webkit-overflow-scrolling: touch !important;
|
| 790 |
}
|
| 791 |
|
| 792 |
-
/*
|
| 793 |
.success-message {
|
| 794 |
font-size: 14px !important;
|
| 795 |
padding: 8px !important;
|
|
@@ -804,11 +821,6 @@ footer {display: none !important;}
|
|
| 804 |
input, textarea, select {
|
| 805 |
font-size: 16px !important;
|
| 806 |
}
|
| 807 |
-
|
| 808 |
-
/* Se till att support-vyn börjar från toppen */
|
| 809 |
-
.gradio-container > .gr-group[style*="visible: true"] {
|
| 810 |
-
scroll-margin-top: 0 !important;
|
| 811 |
-
}
|
| 812 |
}
|
| 813 |
|
| 814 |
/* Extra kompakt för mycket små skärmar */
|
|
@@ -844,7 +856,42 @@ footer {display: none !important;}
|
|
| 844 |
with gr.Blocks(
|
| 845 |
css=custom_css,
|
| 846 |
title="ChargeNode Kundtjänst",
|
| 847 |
-
head='<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes">'
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 848 |
) as app:
|
| 849 |
gr.Markdown("Ställ din fråga om ChargeNodes produkter och tjänster nedan. Om du inte gillar botten, så ring oss gärna på 010 – 205 10 55")
|
| 850 |
|
|
@@ -1081,5 +1128,9 @@ if __name__ == "__main__":
|
|
| 1081 |
share=IS_HUGGINGFACE,
|
| 1082 |
server_name="0.0.0.0" if IS_HUGGINGFACE else "127.0.0.1",
|
| 1083 |
show_error=True,
|
| 1084 |
-
show_api=False
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1085 |
)
|
|
|
|
| 631 |
|
| 632 |
/* MOBIL-ANPASSNINGAR - FOKUS PÅ SCROLLNING OCH KOMPAKT LAYOUT */
|
| 633 |
@media (max-width: 768px) {
|
| 634 |
+
/* Aggressiv scrollning-fix för mobil iframe */
|
| 635 |
+
html {
|
| 636 |
width: 100% !important;
|
| 637 |
height: 100% !important;
|
| 638 |
margin: 0 !important;
|
| 639 |
padding: 0 !important;
|
| 640 |
+
overflow: auto !important;
|
| 641 |
+
-webkit-overflow-scrolling: touch !important;
|
| 642 |
+
-ms-overflow-style: -ms-autohiding-scrollbar !important;
|
| 643 |
+
}
|
| 644 |
+
|
| 645 |
+
body {
|
| 646 |
+
width: 100% !important;
|
| 647 |
+
height: 100% !important;
|
| 648 |
+
margin: 0 !important;
|
| 649 |
+
padding: 0 !important;
|
| 650 |
+
overflow-y: auto !important;
|
| 651 |
overflow-x: hidden !important;
|
| 652 |
background-color: #ffffff !important;
|
| 653 |
-webkit-overflow-scrolling: touch !important;
|
| 654 |
+
-ms-overflow-style: -ms-autohiding-scrollbar !important;
|
| 655 |
+
position: relative !important;
|
| 656 |
}
|
| 657 |
|
| 658 |
/* Gradio app ska tillåta scrollning */
|
| 659 |
.gradio-app {
|
| 660 |
width: 100% !important;
|
| 661 |
+
min-height: 100vh !important;
|
| 662 |
margin: 0 !important;
|
| 663 |
padding: 0 !important;
|
| 664 |
+
overflow: visible !important;
|
| 665 |
+
position: relative !important;
|
| 666 |
}
|
| 667 |
|
| 668 |
+
/* Container för mobil - naturlig scroll layout */
|
| 669 |
.gradio-container {
|
| 670 |
+
position: static !important; /* Viktigt: static för naturlig scroll */
|
| 671 |
width: 100% !important;
|
| 672 |
+
min-height: 100vh !important;
|
| 673 |
max-width: none !important;
|
| 674 |
margin: 0 !important;
|
| 675 |
padding: 8px !important;
|
| 676 |
box-shadow: none !important;
|
| 677 |
border-radius: 0 !important;
|
| 678 |
background-color: #ffffff !important;
|
| 679 |
+
display: block !important; /* Block istället för flex för bättre scroll */
|
|
|
|
| 680 |
box-sizing: border-box !important;
|
| 681 |
+
overflow: visible !important;
|
| 682 |
}
|
| 683 |
|
| 684 |
/* Minimera header-utrymme */
|
| 685 |
.gradio-container > .gr-markdown:first-child {
|
| 686 |
+
display: block !important;
|
| 687 |
font-size: 12px !important;
|
| 688 |
line-height: 1.2 !important;
|
| 689 |
+
margin: 0 0 4px 0 !important;
|
| 690 |
+
padding: 4px 8px !important;
|
| 691 |
background-color: #f8f9fa !important;
|
| 692 |
border-radius: 4px !important;
|
| 693 |
text-align: center !important;
|
| 694 |
}
|
| 695 |
|
| 696 |
+
/* Chat-grupper med naturlig höjd */
|
| 697 |
.gradio-container > .gr-group {
|
| 698 |
+
display: block !important;
|
| 699 |
+
margin: 4px 0 !important;
|
|
|
|
|
|
|
| 700 |
padding: 0 !important;
|
| 701 |
+
overflow: visible !important;
|
| 702 |
}
|
| 703 |
|
| 704 |
+
/* Chatbot med fast höjd för scroll */
|
| 705 |
#chatbot_conversation {
|
| 706 |
+
display: block !important;
|
| 707 |
+
height: 300px !important; /* Fast höjd istället för flex */
|
| 708 |
+
min-height: 300px !important;
|
| 709 |
+
max-height: 300px !important;
|
| 710 |
+
margin: 0 0 8px 0 !important;
|
| 711 |
+
padding: 6px !important;
|
| 712 |
overflow-y: auto !important;
|
| 713 |
+
overflow-x: hidden !important;
|
| 714 |
border: 1px solid #e9ecef !important;
|
| 715 |
border-radius: 4px !important;
|
| 716 |
background-color: #ffffff !important;
|
| 717 |
-webkit-overflow-scrolling: touch !important;
|
| 718 |
+
-ms-overflow-style: -ms-autohiding-scrollbar !important;
|
| 719 |
}
|
| 720 |
|
| 721 |
+
/* Input och knappar */
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 722 |
.gradio-container .gr-row {
|
| 723 |
+
display: block !important;
|
| 724 |
+
margin: 4px 0 !important;
|
| 725 |
+
overflow: visible !important;
|
| 726 |
}
|
| 727 |
|
| 728 |
/* Textbox för mobil */
|
| 729 |
.gr-textbox {
|
| 730 |
+
margin: 0 0 4px 0 !important;
|
| 731 |
+
display: block !important;
|
| 732 |
}
|
| 733 |
|
| 734 |
.gr-textbox textarea {
|
| 735 |
font-size: 16px !important;
|
| 736 |
+
padding: 8px !important;
|
| 737 |
border: 1px solid #e9ecef !important;
|
| 738 |
border-radius: 4px !important;
|
| 739 |
resize: none !important;
|
| 740 |
width: 100% !important;
|
| 741 |
box-sizing: border-box !important;
|
| 742 |
+
min-height: 38px !important;
|
| 743 |
+
max-height: 76px !important;
|
| 744 |
+
overflow-y: auto !important;
|
| 745 |
+
-webkit-overflow-scrolling: touch !important;
|
| 746 |
}
|
| 747 |
|
| 748 |
.gr-textbox textarea:focus {
|
|
|
|
| 750 |
outline: none !important;
|
| 751 |
}
|
| 752 |
|
| 753 |
+
/* Knappar med block layout */
|
| 754 |
.gr-button {
|
| 755 |
+
display: block !important;
|
| 756 |
width: 100% !important;
|
| 757 |
+
padding: 10px 12px !important;
|
| 758 |
+
margin: 4px 0 !important;
|
| 759 |
font-size: 14px !important;
|
| 760 |
+
min-height: 40px !important;
|
| 761 |
border-radius: 4px !important;
|
| 762 |
box-sizing: border-box !important;
|
| 763 |
white-space: nowrap !important;
|
|
|
|
| 767 |
|
| 768 |
/* Knapp-kolumner */
|
| 769 |
.gradio-container .gr-column {
|
| 770 |
+
display: block !important;
|
| 771 |
width: 100% !important;
|
| 772 |
margin: 0 !important;
|
| 773 |
+
padding: 2px 0 !important;
|
| 774 |
}
|
| 775 |
|
| 776 |
+
/* Support-formulär med scrolling */
|
| 777 |
.gr-form {
|
| 778 |
+
display: block !important;
|
| 779 |
+
padding: 8px !important;
|
| 780 |
+
margin: 4px 0 !important;
|
| 781 |
border-radius: 4px !important;
|
| 782 |
background-color: #f8f9fa !important;
|
| 783 |
+
overflow: visible !important;
|
| 784 |
}
|
| 785 |
|
| 786 |
.gr-form .gr-textbox {
|
| 787 |
+
margin: 4px 0 !important;
|
| 788 |
}
|
| 789 |
|
| 790 |
.gr-form .gr-textbox input,
|
|
|
|
| 794 |
border-radius: 4px !important;
|
| 795 |
}
|
| 796 |
|
| 797 |
+
/* Chat preview med scrolling */
|
| 798 |
.chat-preview {
|
| 799 |
max-height: 80px !important;
|
| 800 |
font-size: 11px !important;
|
|
|
|
| 806 |
-webkit-overflow-scrolling: touch !important;
|
| 807 |
}
|
| 808 |
|
| 809 |
+
/* Success message */
|
| 810 |
.success-message {
|
| 811 |
font-size: 14px !important;
|
| 812 |
padding: 8px !important;
|
|
|
|
| 821 |
input, textarea, select {
|
| 822 |
font-size: 16px !important;
|
| 823 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 824 |
}
|
| 825 |
|
| 826 |
/* Extra kompakt för mycket små skärmar */
|
|
|
|
| 856 |
with gr.Blocks(
|
| 857 |
css=custom_css,
|
| 858 |
title="ChargeNode Kundtjänst",
|
| 859 |
+
head='<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes">',
|
| 860 |
+
js="""
|
| 861 |
+
function initScrollFix() {
|
| 862 |
+
// Framtvinga scrollning på mobil i iframe
|
| 863 |
+
if (/iPhone|iPad|iPod|Android/i.test(navigator.userAgent)) {
|
| 864 |
+
document.body.style.overflow = 'auto';
|
| 865 |
+
document.documentElement.style.overflow = 'auto';
|
| 866 |
+
document.body.style.webkitOverflowScrolling = 'touch';
|
| 867 |
+
|
| 868 |
+
// Skicka meddelande till parent om scrollning
|
| 869 |
+
window.addEventListener('scroll', function() {
|
| 870 |
+
if (window.parent !== window) {
|
| 871 |
+
window.parent.postMessage({
|
| 872 |
+
type: 'gradio-scroll',
|
| 873 |
+
scrollTop: document.documentElement.scrollTop
|
| 874 |
+
}, '*');
|
| 875 |
+
}
|
| 876 |
+
});
|
| 877 |
+
|
| 878 |
+
// Lyssna på meddelanden från parent
|
| 879 |
+
window.addEventListener('message', function(event) {
|
| 880 |
+
if (event.data.type === 'scrollToTop') {
|
| 881 |
+
document.documentElement.scrollTop = 0;
|
| 882 |
+
document.body.scrollTop = 0;
|
| 883 |
+
}
|
| 884 |
+
});
|
| 885 |
+
}
|
| 886 |
+
}
|
| 887 |
+
|
| 888 |
+
// Kör när sidan laddas
|
| 889 |
+
if (document.readyState === 'loading') {
|
| 890 |
+
document.addEventListener('DOMContentLoaded', initScrollFix);
|
| 891 |
+
} else {
|
| 892 |
+
initScrollFix();
|
| 893 |
+
}
|
| 894 |
+
"""
|
| 895 |
) as app:
|
| 896 |
gr.Markdown("Ställ din fråga om ChargeNodes produkter och tjänster nedan. Om du inte gillar botten, så ring oss gärna på 010 – 205 10 55")
|
| 897 |
|
|
|
|
| 1128 |
share=IS_HUGGINGFACE,
|
| 1129 |
server_name="0.0.0.0" if IS_HUGGINGFACE else "127.0.0.1",
|
| 1130 |
show_error=True,
|
| 1131 |
+
show_api=False,
|
| 1132 |
+
height=600, # Fast höjd för iframe
|
| 1133 |
+
inbrowser=False, # Förhindra automatisk öppning
|
| 1134 |
+
favicon_path=None,
|
| 1135 |
+
app_kwargs={"docs_url": None, "redoc_url": None} # Rensa onödiga endpoints
|
| 1136 |
)
|