From a73591d1c1a9ab123f3d59648996c0f77d338aad Mon Sep 17 00:00:00 2001 From: Huu Le <39040748+leehuwuj@users.noreply.github.com> Date: Sat, 12 Oct 2024 16:18:09 +0700 Subject: [PATCH] feat: enhance UI and add CI pipeline (#17) * support quick translate and switch langauges * add linting ci * simpler linting * enhance linting ch * fix wrong filter --- .github/workflows/linting.yml | 32 ++++++ .github/workflows/publish.yml | 2 - src/app/page.tsx | 126 ++++++++++++++++-------- src/app/sections/language-selection.tsx | 71 +++++++++++++ src/app/sections/result.tsx | 48 ++++----- 5 files changed, 204 insertions(+), 75 deletions(-) create mode 100644 .github/workflows/linting.yml create mode 100644 src/app/sections/language-selection.tsx diff --git a/.github/workflows/linting.yml b/.github/workflows/linting.yml new file mode 100644 index 0000000..92743fe --- /dev/null +++ b/.github/workflows/linting.yml @@ -0,0 +1,32 @@ +name: 'Linting' + +on: + push: + branches: [ main ] + pull_request: + branches: [ main ] + +jobs: + cargo-check: + strategy: + fail-fast: false + matrix: + include: + - platform: 'macos-latest' + args: '--target aarch64-apple-darwin' + - platform: 'windows-latest' + args: '' + + runs-on: ${{ matrix.platform }} + steps: + - uses: actions/checkout@v4 + + - name: Install Rust stable + uses: dtolnay/rust-toolchain@stable + with: + targets: ${{ matrix.platform == 'macos-latest' && 'aarch64-apple-darwin' || '' }} + + - name: Run Cargo check + run: | + cd src-tauri + cargo check \ No newline at end of file diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index f19b493..c5b242d 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -17,8 +17,6 @@ jobs: include: - platform: 'macos-latest' # for Arm based macs (M1 and above). args: '--target aarch64-apple-darwin' - - platform: 'macos-latest' # for Intel based macs. - args: '--target x86_64-apple-darwin' - platform: 'windows-latest' args: '' diff --git a/src/app/page.tsx b/src/app/page.tsx index bfa9df0..a91cc0b 100644 --- a/src/app/page.tsx +++ b/src/app/page.tsx @@ -1,7 +1,7 @@ "use client"; import { invoke } from "@tauri-apps/api/core"; -import { Select, SelectItem } from "@nextui-org/react"; +import { button, Select, SelectItem } from "@nextui-org/react"; import { listen } from "@tauri-apps/api/event"; import { TextInput } from "./sections/input"; import { Result } from "./sections/result"; @@ -11,7 +11,9 @@ import { BottomBar } from "./sections/bottomBar"; import { SettingContext } from "./providers/settings"; import { FaRegArrowAltCircleRight } from "react-icons/fa"; import { IoStopCircleOutline } from "react-icons/io5"; +import { HiSwitchHorizontal } from "react-icons/hi"; import { AppSettings } from "./types/settings"; +import { Tabs, Tab } from "@nextui-org/react"; async function tauri_get_result( text: string, @@ -105,46 +107,58 @@ const LanguageSelections = ({ selectedLang?: LanguageConfig; changeLangConfig: (lang: LanguageConfig) => void; }) => { - // const sourceLangues = [ - // { value: "en", label: "English" }, - // { value: "es", label: "Spanish" }, - // { value: "fr", label: "French" }, - // ]; const targetLangues = [ { value: "vi", label: "Tiếng Việt" }, { value: "en", label: "English" }, ]; + const handleLanguageSwitch = () => { + if (selectedLang) { + const newConfig = { + sourceLang: selectedLang.targetLang, + targetLang: selectedLang.sourceLang, + }; + changeLangConfig(newConfig); + } + }; + return (
Output language:
- +