Collapse welcome recent chats button

0c411398f057806e394b58948ae32108c2e165e5

Cohee <18619528+Cohee1207@users.noreply.github.com>

3 files changed, +33 -0Ignore whitespace
public/css/welcome.css+8 -0
@@ -10,6 +10,13 @@
1010 padding-bottom: 5px;
1111}
1212
13+.welcomePanel.recentHidden .welcomeRecent,
14+.welcomePanel.recentHidden .recentChatsTitle,
15+.welcomePanel.recentHidden .hideRecentChats,
16+.welcomePanel:not(.recentHidden) .showRecentChats {
17+ display: none;
18+}
19+
1320body.bubblechat .welcomePanel {
1421 border-radius: 10px;
1522 background-color: var(--SmartThemeBotMesBlurTintColor);
@@ -42,6 +49,7 @@ body.bubblechat .welcomePanel {
4249.welcomePanel .welcomeHeaderVersionDisplay {
4350 font-size: calc(var(--mainFontSize) * 1.3);
4451 font-weight: 600;
52+ flex-grow: 1;
4553}
4654
4755.welcomePanel .welcomeHeaderLogo {
public/scripts/templates/welcomePanel.html+6 -0
@@ -2,6 +2,12 @@
22 <div class="welcomeHeaderTitle">
33 <img src="img/logo.png" alt="SillyTavern Logo" class="welcomeHeaderLogo">
44 <span class="welcomeHeaderVersionDisplay">{{version}}</span>
5+ <div class="mes_button showRecentChats" title="Show recent chats" data-i18n="[title]Show recent chats">
6+ <i class="fa-solid fa-circle-chevron-down fa-fw fa-lg"></i>
7+ </div>
8+ <div class="mes_button hideRecentChats" title="Hide recent chats" data-i18n="[title]Hide recent chats">
9+ <i class="fa-solid fa-circle-xmark fa-fw fa-lg"></i>
10+ </div>
511 </div>
612 <div class="welcomeHeader">
713 <div class="recentChatsTitle" data-i18n="Recent Chats">
public/scripts/welcome-screen.js+19 -0
@@ -94,6 +94,25 @@ async function sendWelcomePanel() {
9494 };
9595 const template = await renderTemplateAsync('welcomePanel', templateData);
9696 const fragment = document.createRange().createContextualFragment(template);
97+ fragment.querySelectorAll('.welcomePanel').forEach((root) => {
98+ const recentHiddenClass = 'recentHidden';
99+ const recentHiddenKey = 'WelcomePage_RecentChatsHidden';
100+ if (accountStorage.getItem(recentHiddenKey) === 'true') {
101+ root.classList.add(recentHiddenClass);
102+ }
103+ root.querySelectorAll('.showRecentChats').forEach((button) => {
104+ button.addEventListener('click', () => {
105+ root.classList.remove(recentHiddenClass);
106+ accountStorage.setItem(recentHiddenKey, 'false');
107+ });
108+ });
109+ root.querySelectorAll('.hideRecentChats').forEach((button) => {
110+ button.addEventListener('click', () =>{
111+ root.classList.add(recentHiddenClass);
112+ accountStorage.setItem(recentHiddenKey, 'true');
113+ });
114+ });
115+ });
97116 fragment.querySelectorAll('.recentChat').forEach((item) => {
98117 item.addEventListener('click', () => {
99118 const avatarId = item.getAttribute('data-avatar');