Files
decky-loader/frontend/src/components/Markdown.tsx
T
ynhhoJ cbea1518ed Removed FocusRing from Decky Changelog Modal and use Focusable instead which fixes: #685 (#779)
* fix(Updater): Remove `FocusRing` component and use `Focusable` instead

* feat(Markdown): Add Link `class` to a tag for a mentain a Steam UI colors palette
2025-06-29 11:37:47 -07:00

48 lines
1.6 KiB
TypeScript

import { Focusable, Navigation, findClass, findClassByName } from '@decky/ui';
import { FunctionComponent, useRef } from 'react';
import ReactMarkdown, { Options as ReactMarkdownOptions } from 'react-markdown';
import remarkGfm from 'remark-gfm';
interface MarkdownProps extends ReactMarkdownOptions {
onDismiss?: () => void;
}
const Markdown: FunctionComponent<MarkdownProps> = (props) => {
const eventDetailsBodyClassName = findClassByName('EventDetailsBody') || undefined;
const eventLinkClassName = findClass('43088', 'Link');
return (
<Focusable>
<ReactMarkdown
remarkPlugins={[remarkGfm]}
components={{
div: (nodeProps: any) => <Focusable {...nodeProps.node.properties}>{nodeProps.children}</Focusable>,
a: (nodeProps: any) => {
const aRef = useRef<HTMLAnchorElement>(null);
return (
// TODO fix focus ring
<Focusable
onActivate={() => {}}
onOKButton={() => {
props.onDismiss?.();
Navigation.NavigateToExternalWeb(aRef.current!.href);
}}
style={{ display: 'inline' }}
focusClassName="steam-focus"
className={eventDetailsBodyClassName}
>
<a ref={aRef} {...nodeProps.node.properties} className={eventLinkClassName}>
{nodeProps.children}
</a>
</Focusable>
);
},
}}
{...props}
/>
</Focusable>
);
};
export default Markdown;