Skip to content

Commit 1289b2d

Browse files
committed
feat(ui): add image-zoom
1 parent 1515011 commit 1289b2d

File tree

6 files changed

+152
-5
lines changed

6 files changed

+152
-5
lines changed

web/app/components/image-zoom.css

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
[data-rmiz] {
2+
display: block;
3+
position: relative;
4+
}
5+
6+
[data-rmiz-ghost] {
7+
pointer-events: none;
8+
position: absolute;
9+
}
10+
11+
[data-rmiz-btn-zoom],
12+
[data-rmiz-btn-unzoom] {
13+
display: none;
14+
}
15+
16+
[data-rmiz-content="found"] img {
17+
cursor: zoom-in;
18+
}
19+
20+
[data-rmiz-modal][open] {
21+
width: 100vw /* fallback */;
22+
width: 100dvw;
23+
24+
height: 100vh /* fallback */;
25+
height: 100dvh;
26+
27+
background-color: transparent;
28+
max-width: none;
29+
max-height: none;
30+
margin: 0;
31+
padding: 0;
32+
position: fixed;
33+
overflow: hidden;
34+
}
35+
36+
[data-rmiz-modal]:focus-visible {
37+
outline: none;
38+
}
39+
40+
[data-rmiz-modal-overlay] {
41+
transition: background-color 0.3s;
42+
position: absolute;
43+
inset: 0;
44+
}
45+
46+
[data-rmiz-modal-overlay="visible"] {
47+
background-color: var(--color-fd-background);
48+
}
49+
50+
[data-rmiz-modal-overlay="hidden"] {
51+
background-color: transparent;
52+
}
53+
54+
[data-rmiz-modal-content] {
55+
width: 100%;
56+
height: 100%;
57+
position: relative;
58+
}
59+
60+
[data-rmiz-modal]::backdrop {
61+
display: none;
62+
}
63+
64+
[data-rmiz-modal-img] {
65+
cursor: zoom-out;
66+
image-rendering: high-quality;
67+
transform-origin: 0 0;
68+
transition: transform 0.3s;
69+
position: absolute;
70+
}
71+
72+
@media (prefers-reduced-motion: reduce) {
73+
[data-rmiz-modal-overlay],
74+
[data-rmiz-modal-img] {
75+
transition-duration: 0.01ms !important;
76+
}
77+
}

web/app/components/image-zoom.tsx

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
"use client";
2+
3+
import { Image, type ImageProps } from "fumadocs-core/framework";
4+
import type { ComponentProps } from "react";
5+
import Zoom, { type UncontrolledProps } from "react-medium-image-zoom";
6+
import "@/components/image-zoom.css";
7+
8+
export type ImageZoomProps = ImageProps & {
9+
/**
10+
* Image props when zoom in
11+
*/
12+
zoomInProps?: ComponentProps<"img">;
13+
14+
/**
15+
* Props for `react-medium-image-zoom`
16+
*/
17+
rmiz?: UncontrolledProps;
18+
};
19+
20+
function getImageSrc(src: ImageProps["src"]): string {
21+
if (typeof src === "string") return src;
22+
23+
if (typeof src === "object") {
24+
// Next.js
25+
if ("default" in src)
26+
return (src as { default: { src: string } }).default.src;
27+
return src.src;
28+
}
29+
30+
return "";
31+
}
32+
33+
export function ImageZoom({
34+
zoomInProps,
35+
children,
36+
rmiz,
37+
...props
38+
}: ImageZoomProps) {
39+
return (
40+
<Zoom
41+
zoomMargin={20}
42+
wrapElement="span"
43+
{...rmiz}
44+
zoomImg={{
45+
src: getImageSrc(props.src),
46+
sizes: undefined,
47+
...zoomInProps,
48+
}}
49+
>
50+
{children ?? (
51+
<Image
52+
sizes="(max-width: 768px) 100vw, (max-width: 1200px) 70vw, 900px"
53+
{...props}
54+
/>
55+
)}
56+
</Zoom>
57+
);
58+
}

web/app/components/probeshell/package-config-card.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,11 @@ export default function PackageConfigCard({
3030

3131
useEffect(() => {
3232
const filteredOptions = (packerConfig ?? []).filter((name) => {
33-
return !name.startsWith("Agent") && !name.toLowerCase().startsWith("xxl") && !name.toLowerCase().endsWith("jar");
33+
return (
34+
!name.startsWith("Agent") &&
35+
!name.toLowerCase().startsWith("xxl") &&
36+
!name.toLowerCase().endsWith("jar")
37+
);
3438
});
3539

3640
const mappedOptions = filteredOptions.map((name) => {

web/biome.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,11 @@
1919
"rules": {
2020
"recommended": true,
2121
"suspicious": {
22-
"noExplicitAny": "off"
22+
"noExplicitAny": "off",
23+
"noDuplicateProperties": "off"
24+
},
25+
"complexity": {
26+
"noImportantStyles": "off"
2327
}
2428
},
2529
"domains": {

web/bun.lock

Lines changed: 5 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

web/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
"class-variance-authority": "^0.7.1",
2222
"clsx": "^2.1.1",
2323
"framer-motion": "^12.23.25",
24-
"fumadocs-core": "16.2.3",
24+
"fumadocs-core": "^16.2.4",
2525
"fumadocs-mdx": "14.1.0",
2626
"fumadocs-ui": "16.2.3",
2727
"i18next": "^25.7.2",
@@ -34,6 +34,7 @@
3434
"react-dom": "^19.2.1",
3535
"react-hook-form": "^7.68.0",
3636
"react-i18next": "^16.4.0",
37+
"react-medium-image-zoom": "^5.4.0",
3738
"react-syntax-highlighter": "^16.1.0",
3839
"sonner": "^2.0.7",
3940
"tailwind-merge": "^3.4.0",

0 commit comments

Comments
 (0)