snort/packages/app/src/Element/MixCloudEmbed.tsx

24 lines
675 B
TypeScript
Raw Normal View History

2023-01-25 01:01:16 +00:00
import { MixCloudRegex } from "Const";
2023-04-14 11:33:19 +00:00
import useLogin from "Hooks/useLogin";
2023-01-25 01:01:16 +00:00
const MixCloudEmbed = ({ link }: { link: string }) => {
2023-02-09 12:26:54 +00:00
const feedPath = (MixCloudRegex.test(link) && RegExp.$1) + "%2F" + (MixCloudRegex.test(link) && RegExp.$2);
2023-01-25 01:01:16 +00:00
2023-04-14 11:33:19 +00:00
const lightTheme = useLogin().preferences.theme === "light";
const lightParams = lightTheme ? "light=1" : "light=0";
return (
<>
<br />
<iframe
title="SoundCloud player"
width="100%"
height="120"
frameBorder="0"
src={`https://www.mixcloud.com/widget/iframe/?hide_cover=1&${lightParams}&feed=%2F${feedPath}%2F`}
/>
</>
);
};
2023-01-25 01:01:16 +00:00
export default MixCloudEmbed;