-
Notifications
You must be signed in to change notification settings - Fork 95
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
41763d3
commit f9e2d7c
Showing
6 changed files
with
622 additions
and
0 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
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
50 changes: 50 additions & 0 deletions
50
examples/conversational-ai/talk-to-santa/components/language-dropdown.tsx
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,50 @@ | ||
"use client"; | ||
|
||
import { LANGUAGES } from "@/app/(main)/(santa)/page"; | ||
import { | ||
Select, | ||
SelectContent, | ||
SelectItem, | ||
SelectTrigger, | ||
SelectValue, | ||
} from "@/components/ui/select"; | ||
|
||
interface LanguageDropdownProps { | ||
setLanguage: (language: string) => void; | ||
language: string | null; | ||
languages: typeof LANGUAGES; | ||
} | ||
|
||
export function LanguageDropdown({ | ||
setLanguage, | ||
language, | ||
languages, | ||
}: LanguageDropdownProps) { | ||
const currentLanguage = languages.find(lang => lang.code === language)?.name; | ||
|
||
return ( | ||
<div className="h-10 opacity-0 transition-opacity duration-300 ease-in-out" | ||
style={{ opacity: language ? 1 : 0 }}> | ||
{language && ( | ||
<Select value={language} onValueChange={setLanguage}> | ||
<SelectTrigger className="w-[180px] transition-colors"> | ||
<SelectValue placeholder="Select Language"> | ||
{currentLanguage} | ||
</SelectValue> | ||
</SelectTrigger> | ||
<SelectContent> | ||
{languages.map(lang => ( | ||
<SelectItem | ||
key={lang.code} | ||
value={lang.code} | ||
className="hover:bg-red-100 focus:bg-red-100 cursor-pointer" | ||
> | ||
{lang.name} | ||
</SelectItem> | ||
))} | ||
</SelectContent> | ||
</Select> | ||
)} | ||
</div> | ||
); | ||
} |
Oops, something went wrong.