From 44da2db97e0a662c63385c9550924b35f6ca16ba Mon Sep 17 00:00:00 2001 From: n4ze3m Date: Tue, 6 Aug 2024 23:32:31 +0530 Subject: [PATCH] feat: Add segmented control for custom and copilot prompts in PromptBody component --- src/assets/locale/fa/settings.json | 4 ++++ src/entries/options/App.tsx | 13 ++++++++----- src/services/title.ts | 2 +- 3 files changed, 13 insertions(+), 6 deletions(-) diff --git a/src/assets/locale/fa/settings.json b/src/assets/locale/fa/settings.json index 0cbafdc..02098b6 100644 --- a/src/assets/locale/fa/settings.json +++ b/src/assets/locale/fa/settings.json @@ -147,6 +147,10 @@ "type": "نوع پرامپت", "actions": "اقدامات" }, + "segmented": { + "custom": "پرامپت‌های سفارشی", + "copilot": "پرامپت‌های کوپایلوت" + }, "systemPrompt": "پرامپت سیستم ", "quickPrompt": "پرامپت سریع", "tooltip": { diff --git a/src/entries/options/App.tsx b/src/entries/options/App.tsx index b385df8..997e1de 100644 --- a/src/entries/options/App.tsx +++ b/src/entries/options/App.tsx @@ -1,6 +1,6 @@ import { QueryClient, QueryClientProvider } from "@tanstack/react-query" import { MemoryRouter } from "react-router-dom" -import { useEffect } from "react" +import { useEffect, useState } from "react" const queryClient = new QueryClient() import { ConfigProvider, Empty, theme } from "antd" import { StyleProvider } from "@ant-design/cssinjs" @@ -13,13 +13,15 @@ import { PageAssistProvider } from "@/components/Common/PageAssistProvider" function IndexOption() { const { mode } = useDarkMode() const { t, i18n } = useTranslation() + const [direction, setDirection] = useState<"ltr" | "rtl">("ltr") useEffect(() => { if (i18n.resolvedLanguage) { - document.documentElement.lang = i18n.resolvedLanguage; - document.documentElement.dir = i18n.dir(i18n.resolvedLanguage); + document.documentElement.lang = i18n.resolvedLanguage + document.documentElement.dir = i18n.dir(i18n.resolvedLanguage) + setDirection(i18n.dir(i18n.resolvedLanguage)) } - }, [i18n, i18n.resolvedLanguage]); + }, [i18n, i18n.resolvedLanguage]) return ( @@ -38,7 +40,8 @@ function IndexOption() { }} description={t("common:noData")} /> - )}> + )} + direction={direction}> diff --git a/src/services/title.ts b/src/services/title.ts index c7a9cd4..ac4b8e8 100644 --- a/src/services/title.ts +++ b/src/services/title.ts @@ -14,7 +14,7 @@ export const DEFAULT_TITLE_GEN_PROMPT = `Here is the query: -------------- -Create a concise, 3-5 word phrase as a title for the previous query. Suitable emojis for the summary can be used to enhance understanding. Avoid quotation marks or special formatting. RESPOND ONLY WITH THE TITLE TEXT. ANSWER USING THE SAME LANGUAGE AS THE QUERY. +Create a concise, 3-5 word phrase as a title for the previous query. Avoid quotation marks or special formatting. RESPOND ONLY WITH THE TITLE TEXT. ANSWER USING THE SAME LANGUAGE AS THE QUERY. Examples of titles: