-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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
- Loading branch information
Showing
5 changed files
with
204 additions
and
75 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
import React from "react"; | ||
import { Select, SelectItem } from "@nextui-org/react"; | ||
import { HiSwitchHorizontal } from "react-icons/hi"; | ||
|
||
interface LanguageConfig { | ||
sourceLang: { code: string; label: string }; | ||
targetLang: { code: string; label: string }; | ||
} | ||
|
||
const LanguageSelections = ({ | ||
selectedLang, | ||
changeLangConfig, | ||
}: { | ||
selectedLang?: LanguageConfig; | ||
changeLangConfig: (lang: LanguageConfig) => void; | ||
}) => { | ||
const targetLanguages = [ | ||
{ 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 ( | ||
<div className="mb-3 flex flex-row gap-2 align-middle items-center"> | ||
<div className="flex w-3/6 items-center relative space-x-2"> | ||
<Select | ||
className="flex-grow" | ||
value={selectedLang?.targetLang.label} | ||
placeholder={selectedLang?.targetLang.label} | ||
> | ||
{targetLanguages.map((lang) => ( | ||
<SelectItem | ||
key={lang.value} | ||
value={lang.label} | ||
onClick={() => { | ||
const newConfig = selectedLang; | ||
if (newConfig) { | ||
newConfig.targetLang = { | ||
code: lang.value, | ||
label: lang.label, | ||
}; | ||
changeLangConfig(newConfig); | ||
} | ||
}} | ||
id={lang.label} | ||
> | ||
{lang.label} | ||
</SelectItem> | ||
))} | ||
</Select> | ||
<button | ||
onClick={handleLanguageSwitch} | ||
aria-label="Switch Languages" | ||
> | ||
<HiSwitchHorizontal size={20} /> | ||
</button> | ||
</div> | ||
</div> | ||
); | ||
}; | ||
|
||
export { LanguageSelections }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters