Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 15 additions & 8 deletions src/components/playground/SettingsDropdown.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ const settingsDropdown: SettingValue[] = [
type: "outputs",
key: "audio",
},

{
title: "---",
type: "separator",
Expand Down Expand Up @@ -60,8 +59,9 @@ export const SettingsDropdown = () => {
const isEnabled = (setting: SettingValue) => {
if (setting.type === "separator" || setting.type === "theme_color")
return false;

if (setting.type === "chat") {
return config.settings[setting.type];
return config.settings.chat;
}

if (setting.type === "inputs") {
Expand All @@ -77,6 +77,7 @@ export const SettingsDropdown = () => {

const toggleSetting = (setting: SettingValue) => {
if (setting.type === "separator" || setting.type === "theme_color") return;

const newValue = !isEnabled(setting);
const newSettings = { ...config.settings };

Expand All @@ -87,6 +88,7 @@ export const SettingsDropdown = () => {
} else if (setting.type === "outputs") {
newSettings.outputs[setting.key as "video" | "audio"] = newValue;
}

setUserSettings(newSettings);
};

Expand All @@ -96,6 +98,7 @@ export const SettingsDropdown = () => {
Settings
<ChevronIcon />
</DropdownMenu.Trigger>

<DropdownMenu.Portal>
<DropdownMenu.Content
className="z-50 flex w-60 flex-col gap-0 overflow-hidden rounded text-gray-100 border border-gray-800 bg-gray-900 py-2 text-sm"
Expand All @@ -113,16 +116,20 @@ export const SettingsDropdown = () => {
}

return (
<DropdownMenu.Label
<DropdownMenu.CheckboxItem
key={setting.key}
onClick={() => toggleSetting(setting)}
checked={isEnabled(setting)}
onSelect={(event) => {
event.preventDefault();
toggleSetting(setting);
}}
className="flex max-w-full flex-row items-end gap-2 px-3 py-2 text-xs hover:bg-gray-800 cursor-pointer"
>
<div className="w-4 h-4 flex items-center">
{isEnabled(setting) && <CheckIcon />}
</div>
<DropdownMenu.ItemIndicator className="w-4 h-4 flex items-center">
<CheckIcon />
</DropdownMenu.ItemIndicator>
<span>{setting.title}</span>
</DropdownMenu.Label>
</DropdownMenu.CheckboxItem>
);
})}
</DropdownMenu.Content>
Expand Down