import { useState } from "react"; import { Button } from "~/components/ui/Button"; import { BaseDialog } from "~/components/ui/BaseDialog"; import { useSignalEffect } from "@preact/signals-react"; import { selectedModel, selectedLora } from "~/signals/uiEvents/modelSelection"; import { getModelById, getLoraById } from "~/data/models"; import { ModelSelectionDialog } from "./ModelSelectionDialog"; import { LoraSelectionDialog } from "./LoraSelectionDialog"; interface ModelButtonProps { iconSrc: string; iconAlt: string; label?: string; subtitle?: string; type: "model" | "lora"; } export const ModelButton = ({ iconSrc, iconAlt, label, subtitle, type, }: ModelButtonProps) => { const [isOpen, setIsOpen] = useState(false); // Update button label based on selection useSignalEffect(() => { // This will re-render component when these signals change selectedModel.value; selectedLora.value; }); // Set button text based on current selection let buttonLabel = label; let buttonSubtitle = subtitle; if (type === "model" && selectedModel.value) { const model = getModelById(selectedModel.value); if (model) { buttonLabel = model.name; buttonSubtitle = "Model"; } } if (type === "lora" && selectedLora.value) { const lora = getLoraById(selectedLora.value); if (lora) { buttonLabel = lora.name; buttonSubtitle = "LoRA"; } } return ( <> setIsOpen(false)} className="max-w-3xl" > { setIsOpen(false)} />} {/* {type === "model" ? ( setIsOpen(false)} /> ):( setIsOpen(false)} /> )} */} ); };