diff --git a/packages/widgets/src/dns-hole/controls/component.tsx b/packages/widgets/src/dns-hole/controls/component.tsx index 7ee3576a4..8ce9251a4 100644 --- a/packages/widgets/src/dns-hole/controls/component.tsx +++ b/packages/widgets/src/dns-hole/controls/component.tsx @@ -3,7 +3,20 @@ import "../../widgets-common.css"; import { useState } from "react"; -import { ActionIcon, Badge, Button, Card, Flex, ScrollArea, Stack, Text, Tooltip, UnstyledButton } from "@mantine/core"; +import { + ActionIcon, + Badge, + Button, + Card, + Flex, + Group, + Indicator, + ScrollArea, + Stack, + Text, + Tooltip, + UnstyledButton, +} from "@mantine/core"; import { useDisclosure } from "@mantine/hooks"; import { IconCircleFilled, IconClockPause, IconPlayerPlay, IconPlayerStop } from "@tabler/icons-react"; import combineClasses from "clsx"; @@ -30,6 +43,7 @@ export default function DnsHoleControlsWidget({ options, integrationIds, isEditMode, + width, }: WidgetComponentProps) { const board = useRequiredBoard(); // DnsHole integrations with interaction permissions @@ -177,10 +191,10 @@ export default function DnsHoleControlsWidget({ const controlAllButtonsVisible = options.showToggleAllButtons && integrationsWithInteractions.length > 0; return ( - )} - + ))} - + - + ); } @@ -283,6 +298,7 @@ interface ControlsCardProps { open: () => void; t: TranslationFunction; hasIconColor: boolean; + rootWidth: number; } const ControlsCard: React.FC = ({ @@ -293,6 +309,7 @@ const ControlsCard: React.FC = ({ open, t, hasIconColor, + rootWidth, }) => { const isConnected = useIntegrationConnected(data.integration.updatedAt, { timeout: 30000 }); const isEnabled = data.summary.status ? data.summary.status === "enabled" : undefined; @@ -302,95 +319,161 @@ const ControlsCard: React.FC = ({ const board = useRequiredBoard(); const iconUrl = integrationDefs[data.integration.kind].iconUrl; + const layout = rootWidth < 256 ? "sm" : "md"; return ( - - - - - - {data.integration.name} - - - toggleDns(data.integration.id)} - > - - ) - } - > - {t( - `widget.dnsHoleControls.controls.${ - !isConnected - ? "disconnected" - : typeof isEnabled === "undefined" - ? "processing" - : isEnabled - ? "enabled" - : "disabled" - }`, - )} - - + + + {layout === "md" && ( + + )} + + + + {layout === "sm" && ( + + )} + + {data.integration.name} + + + + {layout === "sm" && ( + + {!isEnabled ? ( + toggleDns(data.integration.id)} + disabled={!controlEnabled} + size="sm" + color="green" + variant="light" + > + + + ) : ( + toggleDns(data.integration.id)} + disabled={!controlEnabled} + size="sm" + color="red" + variant="light" + > + + + )} + { + setSelectedIntegrationIds([data.integration.id]); + open(); + }} + size="sm" + color="yellow" + variant="light" + > + + + + )} + {layout === "md" && ( + toggleDns(data.integration.id)} + > + + ) + } + > + {t( + `widget.dnsHoleControls.controls.${ + !isConnected + ? "disconnected" + : typeof isEnabled === "undefined" + ? "processing" + : isEnabled + ? "enabled" + : "disabled" + }`, + )} + + + )} + + {layout === "md" && ( + { + setSelectedIntegrationIds([data.integration.id]); + open(); + }} + > + + + )} - { - setSelectedIntegrationIds([data.integration.id]); - open(); - }} - > - - - - + + ); }; diff --git a/packages/widgets/src/widgets-common.css b/packages/widgets/src/widgets-common.css index 02e57f750..5bcacd11f 100644 --- a/packages/widgets/src/widgets-common.css +++ b/packages/widgets/src/widgets-common.css @@ -62,14 +62,3 @@ .text-flash { animation: glow 1s ease-in-out; } - -/*To apply to any ScrollArea that we want to flex. Same weird workaround as before*/ -.flexed-scroll-area { - height: 100%; - .mantine-ScrollArea-viewport { - & div[style="min-width: 100%; display: table;"] { - display: flex !important; - height: 100%; - } - } -}