diff --git a/src/components/event/textNote/PreviewedLink.tsx b/src/components/event/textNote/PreviewedLink.tsx index 92b3e8f..1aa95e2 100644 --- a/src/components/event/textNote/PreviewedLink.tsx +++ b/src/components/event/textNote/PreviewedLink.tsx @@ -1,14 +1,15 @@ -import { Component, JSX, Switch, Match, createEffect, Show } from 'solid-js'; +import { Component, JSX, Switch, Match, createSignal, createEffect, Show } from 'solid-js'; import LazyLoad from '@/components/utils/LazyLoad'; import SafeLink from '@/components/utils/SafeLink'; import useConfig from '@/core/useConfig'; -import { useOgp } from '@/utils/ogp'; +import { useTranslation } from '@/i18n/useTranslation'; +import { useOgp, isOgpUrl } from '@/utils/ogp'; import { isTwitterUrl, parseYouTubeVideoUrl } from '@/utils/url'; type PreviewdLinkProps = { - class?: string; - href: string; + url: string; + initialHidden: boolean; children?: JSX.Element; }; @@ -29,13 +30,13 @@ const youtubeUrl = (videoId: string): string => { return iframeUrl.href; }; -const TwitterEmbed: Component<{ class?: string; href: string }> = (props) => { +const TwitterEmbed: Component<{ url: string }> = (props) => { let twitterRef: HTMLQuoteElement | undefined; const { getColorTheme } = useConfig(); createEffect(() => { - if (isTwitterUrl(props.href)) { + if (isTwitterUrl(props.url)) { window.twttr?.widgets?.load(twitterRef); } }); @@ -51,12 +52,12 @@ const TwitterEmbed: Component<{ class?: string; href: string }> = (props) => { return (
- {twitterUrl(props.href)} + {twitterUrl(props.url)}
); @@ -68,7 +69,7 @@ const OgpEmbed: Component<{ class?: string; url: string }> = (props) => { })); return ( - } keyed> + } keyed> {(ogpProps) => (
@@ -89,39 +90,75 @@ const OgpEmbed: Component<{ class?: string; url: string }> = (props) => { ); }; +type ClickToShowProps = { + initialHidden: boolean; + url: string; + children: JSX.Element; +}; + +const ClickToShow: Component = (props) => { + const i18n = useTranslation(); + const [hidden, setHidden] = createSignal(props.initialHidden); + + return ( + + + +
+ } + > + {props.children} +
+ ); +}; + const PreviewedLink: Component = (props) => { const { config } = useConfig(); return ( - }> - - + }> + + + + - + {({ videoId }) => ( - - - - } - > - {() => ( -
-