From 156593faa445173a28763c6d68b9edda3f43dddb Mon Sep 17 00:00:00 2001 From: wong2 Date: Fri, 22 Dec 2023 18:30:33 +0800 Subject: [PATCH] Update setting page saving UX --- src/app/components/Page.tsx | 2 +- src/app/i18n/locales/japanese.json | 3 +- src/app/i18n/locales/simplified-chinese.json | 3 +- src/app/pages/SettingPage.tsx | 223 +++++++++---------- 4 files changed, 115 insertions(+), 116 deletions(-) diff --git a/src/app/components/Page.tsx b/src/app/components/Page.tsx index 3ea9e7f2..5a0bc4fa 100644 --- a/src/app/components/Page.tsx +++ b/src/app/components/Page.tsx @@ -6,7 +6,7 @@ const PagePanel: FC> = (props) => {
{props.title}
-
{props.children}
+
{props.children}
) } diff --git a/src/app/i18n/locales/japanese.json b/src/app/i18n/locales/japanese.json index be47986c..c743bce6 100644 --- a/src/app/i18n/locales/japanese.json +++ b/src/app/i18n/locales/japanese.json @@ -98,5 +98,6 @@ "Login to Claude.ai": "Claude.aiにログインする", "Login to Bard": "Bardにログインする", "Recent Updates": "最近の更新", - "Added a separate Gemini Pro bot, can be enabled in the settings": "独立したGemini Proボットを追加しました。設定で有効にできます" + "Added a separate Gemini Pro bot, can be enabled in the settings": "独立したGemini Proボットを追加しました。設定で有効にできます", + "Save changes": "変更を保存する" } diff --git a/src/app/i18n/locales/simplified-chinese.json b/src/app/i18n/locales/simplified-chinese.json index 8e268e83..817904fb 100644 --- a/src/app/i18n/locales/simplified-chinese.json +++ b/src/app/i18n/locales/simplified-chinese.json @@ -99,5 +99,6 @@ "Login to Claude.ai": "登录Claude.ai", "Login to Bard": "登录Bard", "Recent Updates": "最近更新", - "Added a separate Gemini Pro bot, can be enabled in the settings": "添加了Gemini Pro,可在设置中启用" + "Added a separate Gemini Pro bot, can be enabled in the settings": "添加了Gemini Pro,可在设置中启用", + "Save changes": "保存更改" } diff --git a/src/app/pages/SettingPage.tsx b/src/app/pages/SettingPage.tsx index d9986c17..0b371025 100644 --- a/src/app/pages/SettingPage.tsx +++ b/src/app/pages/SettingPage.tsx @@ -1,8 +1,9 @@ +import { motion } from 'framer-motion' import { FC, PropsWithChildren, useCallback, useEffect, useState } from 'react' import toast, { Toaster } from 'react-hot-toast' import { useTranslation } from 'react-i18next' import Browser from 'webextension-polyfill' -import { MotionButton } from '~app/components/Button' +import Button from '~app/components/Button' import { Input } from '~app/components/Input' import RadioGroup from '~app/components/RadioGroup' import Select from '~app/components/Select' @@ -93,125 +94,121 @@ function SettingPage() { return ( -
-
-
-

{t('Startup page')}

-
- ({ name: bot.name, value: botId })), + ]} + value={userConfig.startupPage} + onChange={(v) => updateConfigValue({ startupPage: v })} + />
-
- - ({ label: `${k} ${t('Mode')}`, value: v }))} - value={userConfig.chatgptMode} - onChange={(v) => updateConfigValue({ chatgptMode: v as ChatGPTMode })} - /> - {userConfig.chatgptMode === ChatGPTMode.API ? ( - - ) : userConfig.chatgptMode === ChatGPTMode.Azure ? ( - - ) : userConfig.chatgptMode === ChatGPTMode.Poe ? ( - - ) : userConfig.chatgptMode === ChatGPTMode.OpenRouter ? ( - - ) : ( - - )} - - - ({ label: `${k} ${t('Mode')}`, value: v }))} - value={userConfig.claudeMode} - onChange={(v) => updateConfigValue({ claudeMode: v as ClaudeMode })} +
+
+

{t('Chatbots')}

+ +
+
+ + ({ label: `${k} ${t('Mode')}`, value: v }))} + value={userConfig.chatgptMode} + onChange={(v) => updateConfigValue({ chatgptMode: v as ChatGPTMode })} + /> + {userConfig.chatgptMode === ChatGPTMode.API ? ( + + ) : userConfig.chatgptMode === ChatGPTMode.Azure ? ( + + ) : userConfig.chatgptMode === ChatGPTMode.Poe ? ( + + ) : userConfig.chatgptMode === ChatGPTMode.OpenRouter ? ( + + ) : ( + + )} + + + ({ label: `${k} ${t('Mode')}`, value: v }))} + value={userConfig.claudeMode} + onChange={(v) => updateConfigValue({ claudeMode: v as ClaudeMode })} + /> + {userConfig.claudeMode === ClaudeMode.API ? ( + + ) : userConfig.claudeMode === ClaudeMode.Webapp ? ( + + ) : userConfig.claudeMode === ClaudeMode.OpenRouter ? ( + + ) : ( + + )} + + +
+

+ API Key ( + + how to create key + + ) +

+ updateConfigValue({ geminiApiKey: e.currentTarget.value })} + type="password" /> - {userConfig.claudeMode === ClaudeMode.API ? ( - - ) : userConfig.claudeMode === ClaudeMode.Webapp ? ( - - ) : userConfig.claudeMode === ClaudeMode.OpenRouter ? ( - - ) : ( - - )} - - -
-

- API Key ( - - how to create key - - ) -

- updateConfigValue({ geminiApiKey: e.currentTarget.value })} - type="password" +
{t('Your keys are stored locally')}
+
+
+ +
+

{t('Chat style')}

+
+ updateConfigValue({ bingConversationStyle: v })} - position="top" - /> -
-
-
- - ({ label: `${k} ${t('Mode')}`, value: v }))} - value={userConfig.perplexityMode} - onChange={(v) => updateConfigValue({ perplexityMode: v as PerplexityMode })} - /> - {userConfig.perplexityMode === PerplexityMode.API && ( - - )} - -
- - -
-
- {dirty && ( - + + + ({ label: `${k} ${t('Mode')}`, value: v }))} + value={userConfig.perplexityMode} + onChange={(v) => updateConfigValue({ perplexityMode: v as PerplexityMode })} /> - )} + {userConfig.perplexityMode === PerplexityMode.API && ( + + )} +
+ +
- + {dirty && ( + +