1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-01-06 00:07:44 +01:00
unleash.unleash/frontend/src/component/common/Markdown/Markdown.tsx
Nuno Góis d161fb49ee
chore: implement event grouping in the event timeline (#8254)
https://linear.app/unleash/issue/2-2663/implement-event-grouping-when-multiple-events-happen-in-a-short-period

This PR introduces a grouping logic for timeline events, enhancing the
way events are displayed when they occur close to each other.

We also updated and refactored components to support handling groups of
events rather than individual events.

Also includes some minor code cleanups and optimizations as part of
general refactoring efforts (scouting).


![image](https://github.com/user-attachments/assets/eed74ddd-017c-430d-b919-3cb7e257052d)

---------

Co-authored-by: David Leek <david@getunleash.io>
2024-09-26 14:48:52 +01:00

28 lines
748 B
TypeScript

import { Link } from '@mui/material';
import type { AnchorHTMLAttributes, ComponentProps } from 'react';
import ReactMarkdown from 'react-markdown';
import { useNavigate } from 'react-router-dom';
const LinkRenderer = ({
href = '',
children,
}: AnchorHTMLAttributes<HTMLAnchorElement>) => {
const navigate = useNavigate();
if (href.startsWith('/'))
return <Link onClick={() => navigate(href)}>{children}</Link>;
return (
<Link href={href} target='_blank' rel='noreferrer'>
{children}
</Link>
);
};
export const Markdown = ({
components,
...props
}: ComponentProps<typeof ReactMarkdown>) => (
<ReactMarkdown components={{ a: LinkRenderer, ...components }} {...props} />
);