Skip to content

Commit

Permalink
feat: App tile scalability (#645)
Browse files Browse the repository at this point in the history
* feat: App tile scalability

* fix: missing translation
  • Loading branch information
SeDemal committed Jun 9, 2024
1 parent 3a3a825 commit 28927cf
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 29 deletions.
3 changes: 3 additions & 0 deletions packages/translation/src/lang/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -637,6 +637,9 @@ export default {
openInNewTab: {
label: "Open in new tab",
},
showTitle: {
label: "Show app name",
},
showDescriptionTooltip: {
label: "Show description tooltip",
},
Expand Down
55 changes: 26 additions & 29 deletions packages/widgets/src/app/component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import type { PropsWithChildren } from "react";
import { useState } from "react";
import { Box, Center, Flex, Loader, Stack, Text, Tooltip, UnstyledButton } from "@mantine/core";
import { IconDeviceDesktopX } from "@tabler/icons-react";
import combineClasses from "clsx";

import type { RouterOutputs } from "@homarr/api";
import { clientApi } from "@homarr/api/client";
Expand All @@ -13,7 +14,7 @@ import { useScopedI18n } from "@homarr/translation/client";
import type { WidgetComponentProps } from "../definition";
import classes from "./app.module.css";

export default function AppWidget({ options, serverData, isEditMode, width, height }: WidgetComponentProps<"app">) {
export default function AppWidget({ options, serverData, isEditMode, width }: WidgetComponentProps<"app">) {
const t = useScopedI18n("widget.app");
const isQueryEnabled = Boolean(options.appId);
const {
Expand Down Expand Up @@ -92,35 +93,31 @@ export default function AppWidget({ options, serverData, isEditMode, width, heig

return (
<AppLink href={app?.href ?? ""} openInNewTab={options.openInNewTab} enabled={Boolean(app?.href) && !isEditMode}>
<Flex align="center" justify="center" h="100%" pos="relative">
<Tooltip.Floating
label={app?.description}
position="right-start"
multiline
disabled={!options.showDescriptionTooltip || !app?.description}
styles={{ tooltip: { maxWidth: 300 } }}
<Tooltip.Floating
label={app?.description}
position="right-start"
multiline
disabled={!options.showDescriptionTooltip || !app?.description}
styles={{ tooltip: { maxWidth: 300 } }}
>
<Flex
className={combineClasses("app-flex-wrapper", app?.name, app?.id)}
h="100%"
w="100%"
direction="column"
p="7.5cqmin"
justify="center"
align="center"
>
<Flex
h="100%"
direction="column"
align="center"
gap={0}
style={{
overflow: "visible",
flexGrow: 5,
}}
>
{height >= 96 && (
<Text fw={700} ta="center">
{app?.name}
</Text>
)}
<img src={app?.iconUrl} alt={app?.name} className={classes.appIcon} />
</Flex>
</Tooltip.Floating>

{shouldRunPing && <PingIndicator pingResult={pingResult} />}
</Flex>
{options.showTitle && (
<Text className="app-title" fw={700} size="12.5cqmin">
{app?.name}
</Text>
)}
<img src={app?.iconUrl} alt={app?.name} className={combineClasses(classes.appIcon, "app-icon")} />
</Flex>
</Tooltip.Floating>
{shouldRunPing && <PingIndicator pingResult={pingResult} />}
</AppLink>
);
}
Expand Down
1 change: 1 addition & 0 deletions packages/widgets/src/app/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ export const { definition, componentLoader, serverDataLoader } = createWidgetDef
options: optionsBuilder.from((factory) => ({
appId: factory.app(),
openInNewTab: factory.switch({ defaultValue: true }),
showTitle: factory.switch({ defaultValue: true }),
showDescriptionTooltip: factory.switch({ defaultValue: false }),
pingEnabled: factory.switch({ defaultValue: false }),
})),
Expand Down

0 comments on commit 28927cf

Please sign in to comment.