Skip to content

Commit

Permalink
Added settings provider maximum description lines (#2611)
Browse files Browse the repository at this point in the history
  • Loading branch information
anderson-oki authored Aug 9, 2024
1 parent f424c21 commit baae406
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 6 deletions.
2 changes: 2 additions & 0 deletions frontend/src/pages/Settings/Providers/components.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -108,10 +108,12 @@ export const ProviderView: FunctionComponent<ProviderViewProps> = ({
})
.map((v, idx) => (
<Card
titleStyles={{ overflow: "hidden", textOverflow: "ellipsis" }}
key={BuildKey(v.key, idx)}
header={v.name ?? capitalize(v.key)}
description={v.description}
onClick={() => select(v)}
lineClamp={2}
></Card>
));
} else {
Expand Down
29 changes: 23 additions & 6 deletions frontend/src/pages/Settings/components/Card.tsx
Original file line number Diff line number Diff line change
@@ -1,21 +1,32 @@
import { FunctionComponent } from "react";
import { Center, Stack, Text, UnstyledButton } from "@mantine/core";
import {
Center,
MantineStyleProp,
Stack,
Text,
UnstyledButton,
} from "@mantine/core";
import { faPlus } from "@fortawesome/free-solid-svg-icons";
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
import TextPopover from "@/components/TextPopover";
import styles from "./Card.module.scss";

interface CardProps {
header?: string;
description?: string;
plus?: boolean;
header?: string;
lineClamp?: number | undefined;
onClick?: () => void;
plus?: boolean;
titleStyles?: MantineStyleProp | undefined;
}

export const Card: FunctionComponent<CardProps> = ({
header,
description,
plus,
onClick,
lineClamp,
titleStyles,
}) => {
return (
<UnstyledButton p="lg" onClick={onClick} className={styles.card}>
Expand All @@ -24,9 +35,15 @@ export const Card: FunctionComponent<CardProps> = ({
<FontAwesomeIcon size="2x" icon={faPlus}></FontAwesomeIcon>
</Center>
) : (
<Stack h="100%" gap={0} align="flex-start">
<Text fw="bold">{header}</Text>
<Text hidden={description === undefined}>{description}</Text>
<Stack h="100%" gap={0}>
<Text fw="bold" style={titleStyles}>
{header}
</Text>
<TextPopover text={description}>
<Text hidden={description === undefined} lineClamp={lineClamp}>
{description}
</Text>
</TextPopover>
</Stack>
)}
</UnstyledButton>
Expand Down

0 comments on commit baae406

Please sign in to comment.