mirror of
https://github.com/ajnart/homarr.git
synced 2025-11-10 15:35:55 +01:00
💄 Made InfoCard more customizable
This commit is contained in:
@@ -1,14 +1,18 @@
|
|||||||
import { HoverCard, useMantineTheme} from '@mantine/core';
|
import { DefaultMantineColor, HoverCard, HoverCardProps, SystemProp, useMantineTheme} from '@mantine/core';
|
||||||
import { RichTextEditor, Link } from '@mantine/tiptap';
|
import { RichTextEditor, RichTextEditorProps, Link } from '@mantine/tiptap';
|
||||||
import { useEditor } from '@tiptap/react';
|
import { useEditor } from '@tiptap/react';
|
||||||
import StarterKit from '@tiptap/starter-kit';
|
import StarterKit from '@tiptap/starter-kit';
|
||||||
import { IconInfoCircle } from '@tabler/icons-react';
|
import { IconInfoCircle } from '@tabler/icons-react';
|
||||||
|
|
||||||
interface InfoCardProps {
|
interface InfoCardProps {
|
||||||
|
bg?: SystemProp<DefaultMantineColor>;
|
||||||
|
cardProp: Partial<RichTextEditorProps>;
|
||||||
content: string;
|
content: string;
|
||||||
|
hoverProp?: Partial<HoverCardProps>;
|
||||||
|
position?: "bottom" | "left" | "right" | "top" | "bottom-end" | "bottom-start" | "left-end" | "left-start" | "right-end" | "right-start" | "top-end" | "top-start"
|
||||||
}
|
}
|
||||||
|
|
||||||
export const InfoCard = ({ content }: InfoCardProps) => {
|
export const InfoCard = ({ bg, cardProp, content, hoverProp, position }: InfoCardProps) => {
|
||||||
const { colorScheme } = useMantineTheme();
|
const { colorScheme } = useMantineTheme();
|
||||||
const editor = useEditor({
|
const editor = useEditor({
|
||||||
content,
|
content,
|
||||||
@@ -21,17 +25,27 @@ export const InfoCard = ({ content }: InfoCardProps) => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<HoverCard position="top" withArrow withinPortal>
|
<HoverCard
|
||||||
|
position={position?? 'top'}
|
||||||
|
radius="md"
|
||||||
|
withArrow
|
||||||
|
withinPortal
|
||||||
|
{...hoverProp}
|
||||||
|
>
|
||||||
<HoverCard.Target>
|
<HoverCard.Target>
|
||||||
<IconInfoCircle size="1.25rem" style={{ display: 'block', opacity: 0.5 }} />
|
<IconInfoCircle size="1.25rem" style={{ display: 'block', opacity: 0.5 }} />
|
||||||
</HoverCard.Target>
|
</HoverCard.Target>
|
||||||
<HoverCard.Dropdown
|
<HoverCard.Dropdown
|
||||||
bg={colorScheme === 'light' ? "gray.2" : "dark.8"}
|
bg={bg ?? colorScheme === 'light' ? "gray.2" : "dark.8"}
|
||||||
maw={400}
|
maw={400}
|
||||||
px="10px"
|
px="10px"
|
||||||
py="5px"
|
py="5px"
|
||||||
>
|
>
|
||||||
<RichTextEditor editor={editor} style={{ border:"0", }}>
|
<RichTextEditor
|
||||||
|
editor={editor}
|
||||||
|
style={{ border:"0", }}
|
||||||
|
{...cardProp}
|
||||||
|
>
|
||||||
<RichTextEditor.Content bg="transparent"/>
|
<RichTextEditor.Content bg="transparent"/>
|
||||||
</RichTextEditor>
|
</RichTextEditor>
|
||||||
</HoverCard.Dropdown>
|
</HoverCard.Dropdown>
|
||||||
|
|||||||
Reference in New Issue
Block a user