-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: attachment click handler (#22)
- Loading branch information
1 parent
0b9a72c
commit c2b48c5
Showing
10 changed files
with
74 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import * as Styles from "./style"; | ||
import type { ComponentProps } from "react"; | ||
import React from "react"; | ||
import { useConfig } from "../../core/ConfigContext"; | ||
import type { APIEmbedImage } from "discord-api-types/v10"; | ||
|
||
interface Props extends ComponentProps<typeof Styles.Image> { | ||
embedImage: APIEmbedImage; | ||
width?: number; | ||
height?: number; | ||
} | ||
|
||
// Not to be confused with ImageEmbed, this is images that are embedded in embeds | ||
function EmbeddedImage({ width, height, embedImage, ...rest }: Props) { | ||
const { embedImageOnClick } = useConfig(); | ||
|
||
return ( | ||
<Styles.Image | ||
{...rest} | ||
src={embedImage.proxy_url ?? embedImage.url} | ||
clickable={embedImageOnClick !== undefined} | ||
onClick={() => embedImageOnClick?.(embedImage)} | ||
width={width} | ||
height={height} | ||
/> | ||
); | ||
} | ||
|
||
export default EmbeddedImage; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters