feat(app): v2 desktop UI improvements (#29689)
Co-authored-by: Brendan Allan <git@brendonovich.dev> Co-authored-by: Brendan Allan <14191578+Brendonovich@users.noreply.github.com>
This commit is contained in:
parent
2bf85b8479
commit
363d6d1a26
80 changed files with 3575 additions and 575 deletions
34
packages/app/src/utils/toast.tsx
Normal file
34
packages/app/src/utils/toast.tsx
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
import { Icon, type IconProps } from "@opencode-ai/ui/icon"
|
||||
import { Toast, showToast as showLegacyToast, type ToastOptions, type ToastVariant } from "@opencode-ai/ui/toast"
|
||||
import { ToastV2, showToastV2 } from "@opencode-ai/ui/v2/toast-v2"
|
||||
|
||||
let v2 = false
|
||||
|
||||
export function setV2Toast(value: boolean) {
|
||||
v2 = value
|
||||
}
|
||||
|
||||
export function ToastRegion(props: { v2: boolean }) {
|
||||
if (props.v2) return <ToastV2.Region />
|
||||
return <Toast.Region />
|
||||
}
|
||||
|
||||
export function showToast(options: ToastOptions | string) {
|
||||
if (!v2) return showLegacyToast(options)
|
||||
if (typeof options === "string") return showToastV2(options)
|
||||
|
||||
return showToastV2({
|
||||
...options,
|
||||
icon: resolveIcon(options.icon, options.variant),
|
||||
actions: options.actions?.map((action) => ({
|
||||
...action,
|
||||
variant: action.onClick === "dismiss" ? "secondary" : "primary",
|
||||
})),
|
||||
})
|
||||
}
|
||||
|
||||
function resolveIcon(icon: IconProps["name"] | undefined, variant: ToastVariant | undefined) {
|
||||
const name = icon ?? (variant === "success" ? "check" : undefined)
|
||||
if (!name) return
|
||||
return <Icon name={name} />
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue