Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: App tile scalability #645

Merged
merged 2 commits into from
Jun 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading