Keldos commited on
Commit
10ba661
1 Parent(s): 33e41e9

WIP: add chat-histor-list buttons

Browse files
web_assets/javascript/ChuanhuChat.js CHANGED
@@ -97,6 +97,7 @@ function initialize() {
97
 
98
  adjustDarkMode();
99
  adjustSide();
 
100
  setLoclize();
101
  selectHistory();
102
  // setChatbotHeight();
@@ -349,6 +350,7 @@ function chatbotContentChanged(attempt = 1) {
349
  gradioApp().querySelectorAll('#chuanhu-chatbot .message-wrap .message-row.bot-row').forEach(addChuanhuButton);
350
  if (chatbotIndicator.classList.contains('hide')) {
351
  setLatestMessage();
 
352
  }
353
  }, i === 0 ? 0 : 200);
354
  }
 
97
 
98
  adjustDarkMode();
99
  adjustSide();
100
+ setChatList();
101
  setLoclize();
102
  selectHistory();
103
  // setChatbotHeight();
 
350
  gradioApp().querySelectorAll('#chuanhu-chatbot .message-wrap .message-row.bot-row').forEach(addChuanhuButton);
351
  if (chatbotIndicator.classList.contains('hide')) {
352
  setLatestMessage();
353
+ setChatList();
354
  }
355
  }, i === 0 ? 0 : 200);
356
  }
web_assets/javascript/chat-list.js ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ function setChatList() {
3
+ var selectedChat = null;
4
+ var chatList = gradioApp().querySelector('fieldset#history-select-dropdown');
5
+ selectedChat = chatList.querySelector(".wrap label.selected")
6
+ if (!selectedChat || selectedChat.classList.contains('added-chat-btns')) {
7
+ return;
8
+ }
9
+
10
+ chatList.querySelector('.chat-selected-btns')?.remove(); // remove old buttons
11
+ chatList.querySelectorAll('.added-chat-btns').forEach(chat => chat.classList.remove('added-chat-btns'));
12
+
13
+ var ChatSelectedBtns = document.createElement('div');
14
+ ChatSelectedBtns.classList.add('chat-selected-btns');
15
+ selectedChat.classList.add('added-chat-btns');
16
+ ChatSelectedBtns.innerHTML = selectedChatBtns;
17
+ selectedChat.appendChild(ChatSelectedBtns);
18
+
19
+ return;
20
+ }
21
+
22
+ const selectedChatBtns = `
23
+ <button><svg class="icon-need-hover" stroke="currentColor" fill="none" stroke-width="2" height="18px" width="18px" viewBox="0 0 24 24" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><path d="M12 20h9"></path><path d="M16.5 3.5a2.121 2.121 0 0 1 3 3L7 19l-4 1 1-4L16.5 3.5z"></path></svg></button>
24
+ <button><svg class="icon-need-hover" stroke="currentColor" fill="none" stroke-width="2" height="18px" width="18px" viewBox="0 0 24 24" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg"><polyline points="3 6 5 6 21 6"></polyline><path d="M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"></path><line x1="10" y1="11" x2="10" y2="17"></line><line x1="14" y1="11" x2="14" y2="17"></line></svg></button>
25
+ `
web_assets/stylesheet/ChuanhuChat.css CHANGED
@@ -1036,6 +1036,28 @@ input:checked + .chatbot-input-more-span {
1036
  overflow-x: hidden;
1037
  }
1038
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1039
  /* .main-body {
1040
  flex-wrap: nowrap;
1041
  gap: 0;
 
1036
  overflow-x: hidden;
1037
  }
1038
 
1039
+ .chat-selected-btns {
1040
+ height: 18px;
1041
+ gap: 8px;
1042
+ display: inline-flex;
1043
+ position: absolute;
1044
+ right: 16px;
1045
+ }
1046
+ .chat-selected-btns::before {
1047
+ content: "";
1048
+ position: absolute;
1049
+ background-image: linear-gradient(to right, rgba(0, 0, 0, 0), var(--message-list-background-selected) 80%);
1050
+ width: 32px;
1051
+ height: 22px;
1052
+ top: 0;
1053
+ left: -32px;
1054
+ }
1055
+ .icon-need-hover {
1056
+ opacity: 0.64;
1057
+ }
1058
+ button:hover .icon-need-hover {
1059
+ opacity: 0.85;
1060
+ }
1061
  /* .main-body {
1062
  flex-wrap: nowrap;
1063
  gap: 0;
web_assets/stylesheet/override-gradio.css CHANGED
@@ -33,6 +33,7 @@ fieldset#history-select-dropdown .wrap label {
33
  background: none;
34
  padding: 10px 16px 10px;
35
  box-shadow: none;
 
36
  }
37
  fieldset#history-select-dropdown .wrap label:hover {
38
  background: var(--message-list-background-hover);
@@ -41,12 +42,17 @@ fieldset#history-select-dropdown .wrap label:active {
41
  background: var(--message-list-background-selected);
42
  }
43
  fieldset#history-select-dropdown .wrap label.selected {
 
44
  background: var(--message-list-background-selected);
 
45
  }
46
  fieldset#history-select-dropdown .wrap label > span {
47
  /* font-size: small; */
48
  margin-left: 0;
49
- color: var(--checkbox-label-text-color);
 
 
 
50
  }
51
  fieldset#history-select-dropdown .wrap label > span::before {
52
  content: url("data:image/svg+xml,%3Csvg stroke='%23000000' fill='none' stroke-opacity='0.85' stroke-width='2' viewBox='0 0 24 24' stroke-linecap='round' stroke-linejoin='round' height='1em' width='1em' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z'%3E%3C/path%3E%3C/svg%3E");
 
33
  background: none;
34
  padding: 10px 16px 10px;
35
  box-shadow: none;
36
+ justify-content: space-between;
37
  }
38
  fieldset#history-select-dropdown .wrap label:hover {
39
  background: var(--message-list-background-hover);
 
42
  background: var(--message-list-background-selected);
43
  }
44
  fieldset#history-select-dropdown .wrap label.selected {
45
+ color: var(--checkbox-label-text-color);
46
  background: var(--message-list-background-selected);
47
+ padding: 10px 64px 10px 16px;
48
  }
49
  fieldset#history-select-dropdown .wrap label > span {
50
  /* font-size: small; */
51
  margin-left: 0;
52
+ /* text-overflow: ellipsis; */
53
+ white-space: nowrap;
54
+ word-break: break-all;
55
+ overflow: hidden;
56
  }
57
  fieldset#history-select-dropdown .wrap label > span::before {
58
  content: url("data:image/svg+xml,%3Csvg stroke='%23000000' fill='none' stroke-opacity='0.85' stroke-width='2' viewBox='0 0 24 24' stroke-linecap='round' stroke-linejoin='round' height='1em' width='1em' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z'%3E%3C/path%3E%3C/svg%3E");