@godxjp/ui 31.10.2 → 31.11.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,130 @@
1
+ import * as React from "react";
2
+
3
+ import {
4
+ Card,
5
+ CardContent,
6
+ CardDescription,
7
+ CardHeader,
8
+ CardTitle,
9
+ Image,
10
+ ImagePreviewGroup,
11
+ Prose,
12
+ } from "@godxjp/ui/data-display";
13
+ import { Button, Text } from "@godxjp/ui/general";
14
+ import { Flex, PageContainer } from "@godxjp/ui/layout";
15
+
16
+ import coverTerrain from "../assets/cover-terrain.svg";
17
+ import portraitIris from "../assets/portrait-iris.svg";
18
+ import shotLandscape from "../assets/shot-landscape.svg";
19
+ import shotPortrait from "../assets/shot-portrait.svg";
20
+
21
+ /* Committed SVG files under docs/assets — a docs page never fetches a third-party image. */
22
+
23
+ /**
24
+ * Image + ImagePreviewGroup — antd `Image` / `Image.PreviewGroup` (gh#1077).
25
+ *
26
+ * Click (or Enter on) a picture: it opens full-viewport with zoom in/out (buttons, wheel,
27
+ * double-click), rotate, flip and reset; drag pans a zoomed picture. Inside a group, ←/→ and the
28
+ * side buttons page every picture of the group with a "2 / 3" counter. Esc closes and focus goes
29
+ * back to the picture.
30
+ *
31
+ * Deviations from antd, on purpose: the thumbnail is a real button (keyboard-openable); the
32
+ * preview traps focus and restores it; ←/→ follow the reading direction (RTL: ← is next); with
33
+ * `items`, a clicked child opens at its own src (antd opens 0); `alt` is required; the
34
+ * `toolbarRender` / `imageRender` / `countRender` render props, `movable` and `getContainer` are
35
+ * not ported.
36
+ */
37
+ export default function Demo() {
38
+ const [current, setCurrent] = React.useState(0);
39
+ const [visible, setVisible] = React.useState(false);
40
+
41
+ return (
42
+ <PageContainer title="Image" subtitle="Click to preview large · ←/→ page through a group">
43
+ <Flex direction="col" gap="lg">
44
+ <Card>
45
+ <CardHeader>
46
+ <CardTitle level={2}>Every screenshot of a Markdown body in one preview</CardTitle>
47
+ <CardDescription>
48
+ Every Image under an ImagePreviewGroup, however deep, joins one gallery in document
49
+ order. Mapping a Markdown renderer&apos;s img to Image is enough to page through the
50
+ article&apos;s screenshots.
51
+ </CardDescription>
52
+ </CardHeader>
53
+ <CardContent>
54
+ <ImagePreviewGroup>
55
+ <Prose>
56
+ <h3>Test result</h3>
57
+ <p>Before the fix:</p>
58
+ <p>
59
+ <Image src={shotPortrait} width={180} alt="List screen before the fix" />
60
+ </p>
61
+ <p>After the fix:</p>
62
+ <p>
63
+ <Image src={shotLandscape} width={320} alt="Dashboard after the fix" />
64
+ </p>
65
+ <p>
66
+ The logo leaves the group with preview=&#123;false&#125;:{" "}
67
+ <Image src={portraitIris} width={48} alt="App icon" preview={false} />
68
+ </p>
69
+ </Prose>
70
+ </ImagePreviewGroup>
71
+ </CardContent>
72
+ </Card>
73
+
74
+ <Card>
75
+ <CardHeader>
76
+ <CardTitle level={2}>items and controlled preview.current / visible</CardTitle>
77
+ <CardDescription>
78
+ `items` lists the gallery explicitly; `preview` controls current / onChange and
79
+ visible / onVisibleChange with antd&apos;s (next, prev) argument order.
80
+ </CardDescription>
81
+ </CardHeader>
82
+ <CardContent>
83
+ <Flex direction="col" gap="sm">
84
+ <Text tone="muted">
85
+ Showing {current + 1} / 3 · {visible ? "open" : "closed"}
86
+ </Text>
87
+ <Flex gap="sm" wrap>
88
+ <Button onClick={() => setVisible(true)}>Open the gallery</Button>
89
+ </Flex>
90
+ <ImagePreviewGroup
91
+ items={[
92
+ { src: shotPortrait, alt: "List screen" },
93
+ { src: shotLandscape, alt: "Dashboard" },
94
+ { src: coverTerrain, alt: "Cover image" },
95
+ ]}
96
+ preview={{
97
+ current,
98
+ visible,
99
+ onChange: (next) => setCurrent(next),
100
+ onVisibleChange: (next) => setVisible(next),
101
+ }}
102
+ />
103
+ </Flex>
104
+ </CardContent>
105
+ </Card>
106
+
107
+ <Card>
108
+ <CardHeader>
109
+ <CardTitle level={2}>Standalone · fallback · placeholder</CardTitle>
110
+ <CardDescription>
111
+ An Image outside a group previews only itself. A picture that fails to load shows its
112
+ fallback and does not open a preview (as in antd).
113
+ </CardDescription>
114
+ </CardHeader>
115
+ <CardContent>
116
+ <Flex gap="md" wrap align="start">
117
+ <Image src={coverTerrain} width={240} alt="Cover image" placeholder />
118
+ <Image
119
+ src="/missing-screenshot.png"
120
+ fallback={portraitIris}
121
+ width={96}
122
+ alt="A picture that failed to load"
123
+ />
124
+ </Flex>
125
+ </CardContent>
126
+ </Card>
127
+ </Flex>
128
+ </PageContainer>
129
+ );
130
+ }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@godxjp/ui",
3
- "version": "31.10.2",
4
- "godxUiMcp": "31.10.2",
3
+ "version": "31.11.0",
4
+ "godxUiMcp": "31.11.0",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
7
7
  "type": "git",