feat: refine widget interactions
This commit is contained in:
1 parent
a8a7545f40
commit
842e86012d
107 files changed
+3144
-1233
No files matched your search
@@ -83,12 +83,18 @@ export default function SmartHomeEntityStateWidget({
|
||||
{ key: "deviceClass" as const, value: entity?.attributes.device_class },
|
||||
{ key: "icon" as const, value: entity?.attributes.icon },
|
||||
].filter(({ value }) => typeof value === "string" && value.length > 0);
|
||||
const displayName =
|
||||
displayMode === "advanced" && typeof entity?.attributes.friendly_name === "string"
|
||||
? entity.attributes.friendly_name
|
||||
: options.displayName;
|
||||
const state = entity?.state ?? "—";
|
||||
|
||||
return (
|
||||
<UnstyledButton
|
||||
mod={{ "entity-state": entity?.state, "entity-id": options.entityId }}
|
||||
onClick={handleClick}
|
||||
disabled={!isActionable}
|
||||
aria-label={`${displayName}: ${state}${attribute}`}
|
||||
aria-description={error?.message}
|
||||
w="100%"
|
||||
h="100%"
|
||||
@@ -101,15 +107,13 @@ export default function SmartHomeEntityStateWidget({
|
||||
>
|
||||
<Center h="100%" w="100%">
|
||||
<Stack align="center" gap={isTiny ? 4 : "md"} p="xs" maw="100%">
|
||||
<Text ta="center" fw="bold" size={isTiny ? "sm" : "lg"}>
|
||||
{displayMode === "advanced" && typeof entity?.attributes.friendly_name === "string"
|
||||
? entity.attributes.friendly_name
|
||||
: options.displayName}
|
||||
</Text>
|
||||
<Text ta="center" size={isTiny ? "xs" : "lg"}>
|
||||
{entity?.state ?? "—"}
|
||||
<Text ta="center" fw={700} size={isTiny ? "lg" : "2xl"} lh={1.1} lineClamp={1} maw="100%">
|
||||
{state}
|
||||
{attribute}
|
||||
</Text>
|
||||
<Text ta="center" c="dimmed" fw={500} size={isTiny ? "xs" : "sm"} lineClamp={2} maw="100%">
|
||||
{displayName}
|
||||
</Text>
|
||||
{displayMode === "advanced" && entity && (
|
||||
<>
|
||||
<Group justify="center" gap={4}>
|
||||
@@ -131,7 +135,7 @@ export default function SmartHomeEntityStateWidget({
|
||||
)}
|
||||
{error && (
|
||||
<Tooltip label={error.message} multiline>
|
||||
<Text size="xs" c="red" lineClamp={2}>
|
||||
<Text size="xs" c="red" lineClamp={2} tabIndex={0}>
|
||||
{t("widget.smartHome-entityState.error.toggleFailed")}
|
||||
</Text>
|
||||
</Tooltip>
|
||||
|
||||
@@ -87,7 +87,7 @@ export default function SmartHomeTriggerAutomationWidget({
|
||||
|
||||
return (
|
||||
<Box pos="relative" w="100%" h="100%">
|
||||
<VisuallyHidden role="status">
|
||||
<VisuallyHidden component="output">
|
||||
{isPending
|
||||
? t("widget.smartHome-executeAutomation.status.running")
|
||||
: isShowSuccess
|
||||
@@ -100,6 +100,7 @@ export default function SmartHomeTriggerAutomationWidget({
|
||||
<UnstyledButton
|
||||
onClick={handleClick}
|
||||
disabled={!integrationId || !canInteract || isPending}
|
||||
aria-label={t("widget.smartHome-executeAutomation.spotlightAction.run", { name: options.displayName })}
|
||||
style={{
|
||||
cursor: !isEditMode && integrationId && canInteract ? "pointer" : "initial",
|
||||
pointerEvents: isEditMode ? "none" : undefined,
|
||||
@@ -130,9 +131,11 @@ export default function SmartHomeTriggerAutomationWidget({
|
||||
</Overlay>
|
||||
)}
|
||||
<Center w="100%" h="100%">
|
||||
<Stack align="center" gap="md">
|
||||
<IconAutomation size={isTiny ? 16 : undefined} />
|
||||
<Text ta="center" fw="bold" fz={isTiny ? "xs" : undefined}>
|
||||
<Stack align="center" gap={isTiny ? 6 : "md"} p="xs" maw="100%">
|
||||
<ThemeIcon variant="light" size={isTiny ? "md" : "xl"} radius="xl">
|
||||
<IconAutomation size={isTiny ? 14 : 24} />
|
||||
</ThemeIcon>
|
||||
<Text ta="center" fw={600} fz={isTiny ? "xs" : "sm"} lineClamp={2} maw="100%">
|
||||
{options.displayName}
|
||||
</Text>
|
||||
{displayMode === "advanced" && (
|
||||
|
||||
Reference in new issue
Block a user