Skip to content

Commit

Permalink
Add clear input function to translation module
Browse files Browse the repository at this point in the history
Introduced a "Clear" button and corresponding 'clearInput' function in TranslationModule component. This allows the user to clear the input and output content in the translation module. Also adjusted the button CSS class and re-ordered disable condition checks for better readability. Modified skeleton CSS to use em for height for better responsiveness.
  • Loading branch information
waleko committed Nov 27, 2023
1 parent 32b50fb commit 26e341c
Showing 1 changed file with 20 additions and 3 deletions.
23 changes: 20 additions & 3 deletions web/src/components/TranslationModule.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,14 @@ export default function TranslationModule() {
});
}

function clearInput() {
inputSetValue("");
inputSetHighlight("");
outputSetValue("");
outputSetHighlight("");
setIsTranslated(false);
}

return (
<>
{/* Content */}
Expand All @@ -59,11 +67,20 @@ export default function TranslationModule() {
/>
<div className="mt-4">
<Button
className="bg-primary"
className="primary"
onClick={translate}
disabled={isTranslated || isLoading}
disabled={isLoading || isTranslated}
>
Translate
</Button>{" "}
<Button
variant="outline"
onClick={() => {
clearInput();
}}
disabled={inputValue === "" || (!isTranslated && isLoading)}
>
Clear
</Button>
</div>
</div>
Expand All @@ -82,7 +99,7 @@ export default function TranslationModule() {
/>
)}
{/* add skeleton */}
{isLoading && <Skeleton className={"w-full h-[200px] rounded-3"} />}
{isLoading && <Skeleton className={"w-full h-[13em] rounded-3"} />}
</div>
</div>
</>
Expand Down

0 comments on commit 26e341c

Please sign in to comment.