aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/docs/components/image/ImageFigure.tsx
diff options
context:
space:
mode:
authorHsiangNianian <admin@jyunko.cn>2023-04-22 19:52:26 +0800
committerHsiangNianian <admin@jyunko.cn>2023-04-22 19:52:26 +0800
commit4838df315931bb883f704ec3e1abe2685f296cdf (patch)
tree57a8550c4cd5338f1126364bb518c6cde8d96e7d /docs/components/image/ImageFigure.tsx
parentdb74ade0234a40c2120ad5f2a41bee50ce13de02 (diff)
downloadHydroRoll-4838df315931bb883f704ec3e1abe2685f296cdf.tar.gz
HydroRoll-4838df315931bb883f704ec3e1abe2685f296cdf.zip
😀
Diffstat (limited to 'docs/components/image/ImageFigure.tsx')
-rw-r--r--docs/components/image/ImageFigure.tsx40
1 files changed, 40 insertions, 0 deletions
diff --git a/docs/components/image/ImageFigure.tsx b/docs/components/image/ImageFigure.tsx
new file mode 100644
index 0000000..b90237e
--- /dev/null
+++ b/docs/components/image/ImageFigure.tsx
@@ -0,0 +1,40 @@
+import React from "react";
+import Image from "next/image";
+
+type ImageProps = Parameters<typeof Image>[0];
+
+export type ImageFigureProps = ImageProps & {
+ caption?: string;
+ margin?: number;
+ captionSpacing?: number;
+ shadow?: boolean;
+ borderRadius?: boolean;
+};
+
+export function ImageFigure(props: ImageFigureProps): React.ReactNode {
+ const {
+ caption,
+ margin = 40,
+ captionSpacing = null,
+ shadow = false,
+ borderRadius = false,
+ ...rest
+ } = props;
+
+ return (
+ <figure className="block text-center" style={{ margin: `${margin}px 0` }}>
+ <div className="relative inline-block w-full max-w-full overflow-hidden border-box text-[0px]">
+ {/* eslint-disable-next-line jsx-a11y/alt-text */}
+ <Image {...rest} />
+ </div>
+ {caption && (
+ <figcaption
+ className="m-0 text-xs text-center text-gray-500"
+ style={captionSpacing ? { marginTop: captionSpacing } : {}}
+ >
+ {caption}
+ </figcaption>
+ )}
+ </figure>
+ );
+}