@alexgorbatchev/shadcn 0.0.94 → 0.0.95
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.
- package/dist/components/image-viewer/ImageRegionMarker.d.ts +33 -8
- package/dist/components/image-viewer/index.d.ts +1 -1
- package/dist/components/image-viewer/index.js +19 -4
- package/dist/prototype.js +1 -1
- package/llms/components/data-display/ImageRegionMarker.md +19 -3
- package/llms.txt +1 -1
- package/package.json +1 -1
|
@@ -4,21 +4,46 @@ declare const imageRegionMarkerVariants: (props?: ({
|
|
|
4
4
|
variant?: "difference" | "draft" | "comment" | null | undefined;
|
|
5
5
|
} & import("class-variance-authority/types").ClassProp) | undefined) => string;
|
|
6
6
|
export type ImageRegionMarkerVariant = NonNullable<VariantProps<typeof imageRegionMarkerVariants>["variant"]>;
|
|
7
|
+
/** A length in CSS pixels, or any CSS length such as a percentage of the positioned image box. */
|
|
8
|
+
export type ImageRegionLength = number | string;
|
|
9
|
+
/** Where a region sits inside its positioned image box. */
|
|
10
|
+
export interface IImageRegionBox {
|
|
11
|
+
left: ImageRegionLength;
|
|
12
|
+
top: ImageRegionLength;
|
|
13
|
+
width: ImageRegionLength;
|
|
14
|
+
height: ImageRegionLength;
|
|
15
|
+
}
|
|
16
|
+
/** Where a badge sits relative to its marker's box. */
|
|
17
|
+
export interface IImageRegionBadgePosition {
|
|
18
|
+
left: ImageRegionLength;
|
|
19
|
+
top: ImageRegionLength;
|
|
20
|
+
}
|
|
7
21
|
export interface IImageRegionMarkerProps extends ComponentProps<"div"> {
|
|
8
22
|
/** Which kind of region the marker outlines. Defaults to `comment`. */
|
|
9
23
|
variant?: ImageRegionMarkerVariant;
|
|
24
|
+
/** The region's box inside the positioned image box. Lets consumers place the marker without passing `style`. */
|
|
25
|
+
region?: IImageRegionBox;
|
|
10
26
|
}
|
|
11
27
|
/**
|
|
12
|
-
* Outlines a region drawn over an image. Position it with `
|
|
13
|
-
* percentages of the positioned image box). Children render inside the marker's box, such as
|
|
14
|
-
* `ImageRegionMarkerBadge` pinned to one of its corners.
|
|
28
|
+
* Outlines a region drawn over an image. Position it with `region` (`left`, `top`, `width`, `height`, in pixels or
|
|
29
|
+
* any CSS length, such as percentages of the positioned image box). Children render inside the marker's box, such as
|
|
30
|
+
* an `ImageRegionMarkerBadge` pinned to one of its corners.
|
|
15
31
|
*/
|
|
16
|
-
export declare function ImageRegionMarker({ variant, className, ...props }: IImageRegionMarkerProps): ReactElement;
|
|
17
|
-
export
|
|
32
|
+
export declare function ImageRegionMarker({ variant, region, className, style, ...props }: IImageRegionMarkerProps): ReactElement;
|
|
33
|
+
export interface IImageRegionMarkerBadgeProps extends ComponentProps<"div"> {
|
|
34
|
+
/** Where the badge sits relative to its marker's box. */
|
|
35
|
+
position?: IImageRegionBadgePosition;
|
|
36
|
+
/**
|
|
37
|
+
* Whether the badge takes pointer input. Defaults to `true`; pass `false` while another gesture, such as drawing a
|
|
38
|
+
* new region, owns the pointer so the badge does not intercept it.
|
|
39
|
+
*/
|
|
40
|
+
interactive?: boolean;
|
|
41
|
+
}
|
|
18
42
|
/**
|
|
19
43
|
* Holds an interactive control, such as a comment-count button, beside an `ImageRegionMarker`. It carries the
|
|
20
|
-
* marker's outline and halo, so its edge stays visible on light and dark screenshots. Position it with `
|
|
21
|
-
* relative to the marker's box; it receives pointer events although the marker does not
|
|
44
|
+
* marker's outline and halo, so its edge stays visible on light and dark screenshots. Position it with `position`
|
|
45
|
+
* relative to the marker's box; it receives pointer events although the marker does not, unless `interactive` is
|
|
46
|
+
* `false`.
|
|
22
47
|
*/
|
|
23
|
-
export declare function ImageRegionMarkerBadge({ className, ...props }: IImageRegionMarkerBadgeProps): ReactElement;
|
|
48
|
+
export declare function ImageRegionMarkerBadge({ position, interactive, className, style, ...props }: IImageRegionMarkerBadgeProps): ReactElement;
|
|
24
49
|
export {};
|
|
@@ -8,4 +8,4 @@ export { computeImageDiff } from "./computeImageDiff.js";
|
|
|
8
8
|
export { getNormalizedImagePoint } from "./getNormalizedImagePoint.js";
|
|
9
9
|
export type { IImageComparisonSource, IImageDiff, IImageDiffOptions, IImageDiffRegion, IImagePixels, IImageRect, IImageSize, INormalizedImagePoint, ImageComparisonMode, ImageComparisonOrientation, ImageZoom, } from "./types.js";
|
|
10
10
|
export { ImageRegionMarker, ImageRegionMarkerBadge } from "./ImageRegionMarker.js";
|
|
11
|
-
export type { IImageRegionMarkerBadgeProps, IImageRegionMarkerProps, ImageRegionMarkerVariant, } from "./ImageRegionMarker.js";
|
|
11
|
+
export type { IImageRegionBadgePosition, IImageRegionBox, IImageRegionMarkerBadgeProps, IImageRegionMarkerProps, ImageRegionLength, ImageRegionMarkerVariant, } from "./ImageRegionMarker.js";
|
|
@@ -488,18 +488,33 @@ var imageRegionMarkerVariants = cva("pointer-events-none absolute rounded-xs sha
|
|
|
488
488
|
},
|
|
489
489
|
defaultVariants: { variant: "comment" }
|
|
490
490
|
});
|
|
491
|
-
function ImageRegionMarker({
|
|
491
|
+
function ImageRegionMarker({
|
|
492
|
+
variant,
|
|
493
|
+
region,
|
|
494
|
+
className,
|
|
495
|
+
style,
|
|
496
|
+
...props
|
|
497
|
+
}) {
|
|
492
498
|
return /* @__PURE__ */ jsx5("div", {
|
|
493
499
|
"data-slot": "image-region-marker",
|
|
494
500
|
"data-variant": variant ?? "comment",
|
|
495
501
|
className: cn2(imageRegionMarkerVariants({ variant }), className),
|
|
502
|
+
style: region ? { ...style, ...region } : style,
|
|
496
503
|
...props
|
|
497
504
|
});
|
|
498
505
|
}
|
|
499
|
-
function ImageRegionMarkerBadge({
|
|
506
|
+
function ImageRegionMarkerBadge({
|
|
507
|
+
position,
|
|
508
|
+
interactive = true,
|
|
509
|
+
className,
|
|
510
|
+
style,
|
|
511
|
+
...props
|
|
512
|
+
}) {
|
|
500
513
|
return /* @__PURE__ */ jsx5("div", {
|
|
501
514
|
"data-slot": "image-region-marker-badge",
|
|
502
|
-
|
|
515
|
+
"data-interactive": interactive,
|
|
516
|
+
className: cn2("absolute z-10 rounded-sm shadow-[0_0_0_4px_var(--background)] outline-2 outline-primary forced-colors:outline-[Highlight]", interactive ? "pointer-events-auto" : "pointer-events-none", className),
|
|
517
|
+
style: position ? { ...style, ...position } : style,
|
|
503
518
|
...props
|
|
504
519
|
});
|
|
505
520
|
}
|
|
@@ -517,7 +532,7 @@ function ImageDifferenceOverlay({ diff }) {
|
|
|
517
532
|
children: diff.regions.map((region) => /* @__PURE__ */ jsx6(ImageRegionMarker, {
|
|
518
533
|
"data-slot": "image-difference-region",
|
|
519
534
|
variant: "difference",
|
|
520
|
-
|
|
535
|
+
region: {
|
|
521
536
|
left: toPercent(region.x, diff.width),
|
|
522
537
|
top: toPercent(region.y, diff.height),
|
|
523
538
|
width: toPercent(region.width, diff.width),
|
package/dist/prototype.js
CHANGED
|
@@ -2051,7 +2051,7 @@ var program = new Command;
|
|
|
2051
2051
|
// package.json
|
|
2052
2052
|
var package_default = {
|
|
2053
2053
|
name: "@alexgorbatchev/shadcn",
|
|
2054
|
-
version: "0.0.
|
|
2054
|
+
version: "0.0.95",
|
|
2055
2055
|
description: "Sharp, monospace React components with compact and comfortable densities.",
|
|
2056
2056
|
license: "MIT",
|
|
2057
2057
|
repository: {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# ImageRegionMarker
|
|
2
2
|
|
|
3
|
-
Import from `@alexgorbatchev/shadcn/image-viewer`. Outlines a region over an image: a 2px outline 1px outside the region over a 4px halo in the page background, so the outline keeps 3:1 against any screenshot in both themes; forced colours draw it in Highlight. Variants: `comment` (a saved comment's region), `draft` (dashed, a region being drawn) and `difference` (changed pixels, used by ImageComparison's Highlight differences). Position it with `
|
|
3
|
+
Import from `@alexgorbatchev/shadcn/image-viewer`. Outlines a region over an image: a 2px outline 1px outside the region over a 4px halo in the page background, so the outline keeps 3:1 against any screenshot in both themes; forced colours draw it in Highlight. Variants: `comment` (a saved comment's region), `draft` (dashed, a region being drawn) and `difference` (changed pixels, used by ImageComparison's Highlight differences). Position it with `region` (left, top, width, height in pixels or any CSS length) over a positioned image box. `ImageRegionMarkerBadge` pins an interactive control, such as a comment count, beside the marker with the same outline and halo; place it with `position`, and pass `interactive={false}` while another gesture owns the pointer. The theme's `target-emphasis` utility is the matching two-tone mark for a jump target on the page.
|
|
4
4
|
|
|
5
5
|
Story: @alexgorbatchev/shadcn/components/data-display/ImageRegionMarker
|
|
6
6
|
Source: src/components/stories/data-display/ImageRegionMarker.stories.tsx
|
|
@@ -38,8 +38,8 @@ ImageRegionMarker
|
|
|
38
38
|
(args) => (<div className="flex flex-wrap gap-6">
|
|
39
39
|
{screenshots.map((screenshot) => (<figure key={screenshot.label} className="flex flex-col gap-2">
|
|
40
40
|
<div role="img" aria-label={screenshot.label} className="relative h-40 w-72" style={{ background: screenshot.background }}>
|
|
41
|
-
<ImageRegionMarker {...args}
|
|
42
|
-
<ImageRegionMarkerBadge
|
|
41
|
+
<ImageRegionMarker {...args} region={{ left: "20%", top: "35%", width: "45%", height: "30%" }}>
|
|
42
|
+
<ImageRegionMarkerBadge position={{ left: "calc(100% + 8px)", top: -32 }}>
|
|
43
43
|
<Button size="sm" variant="secondary" aria-label={`Open comments on ${screenshot.label}`}>
|
|
44
44
|
3
|
|
45
45
|
</Button>
|
|
@@ -77,6 +77,22 @@ Storybook CSF excerpts. Default args and render apply unless overridden. Local h
|
|
|
77
77
|
}
|
|
78
78
|
```
|
|
79
79
|
|
|
80
|
+
### InertBadge
|
|
81
|
+
|
|
82
|
+
```tsx
|
|
83
|
+
{
|
|
84
|
+
render: () => (<div role="img" aria-label="Screenshot being drawn on" className="relative h-40 w-72 bg-muted">
|
|
85
|
+
<ImageRegionMarker region={{ left: 40, top: 50, width: 120, height: 60 }}>
|
|
86
|
+
<ImageRegionMarkerBadge position={{ left: 128, top: -32 }} interactive={false}>
|
|
87
|
+
<Button size="sm" variant="secondary" aria-label="Open comments">
|
|
88
|
+
1
|
|
89
|
+
</Button>
|
|
90
|
+
</ImageRegionMarkerBadge>
|
|
91
|
+
</ImageRegionMarker>
|
|
92
|
+
</div>)
|
|
93
|
+
}
|
|
94
|
+
```
|
|
95
|
+
|
|
80
96
|
### TargetEmphasis
|
|
81
97
|
|
|
82
98
|
```tsx
|
package/llms.txt
CHANGED
|
@@ -343,7 +343,7 @@ Generated from the public package exports and Storybook sources.
|
|
|
343
343
|
- [DataViewer](./llms/components/data-display/DataViewer.md)
|
|
344
344
|
- [Heading](./llms/components/data-display/Heading.md): Heading renders `h1`–`h6` from the required `level` so the document outline stays correct, while `size` (sm, base, lg, xl) sets the visual size independently. Sizes default by level: 1 xl, 2 lg, 3 base, 4–6 sm. `truncate` keeps one line.
|
|
345
345
|
- [ImageComparison](./llms/components/data-display/ImageComparison.md): Import from `@alexgorbatchev/shadcn/image-viewer`. ImageComparison fills its container and compares `before` and `after` images (`{ src, alt, crossOrigin? }`) labelled by `beforeLabel` and `afterLabel` (default "Before" and "After"). `toggle` (the default) shows the after image and the "Hold to show before" button shows the before image while a pointer, Space, or Enter is held. `swipe` stacks both images; the divider is a slider (0–100, arrows ±1, Page Up/Page Down ±10, Home/End) whose handle drags with pointer capture. `side-by-side` shows labelled panes left and right (`horizontal`) or top and bottom (`vertical`) that scroll in sync at original size. Every mode starts fitted and offers original size. A differently sized before image is drawn inside the after image box, and the toolbar reports the mismatch. "Highlight differences" compares pixels on first use, caches the result per image pair, outlines changed regions, and summarizes them; it is disabled with a reason when pixels cannot be read. `mode`, `orientation`, `zoom`, and `showDifferences` are controllable with matching `default*` and `on*Change` props; `showToolbar={false}` hides the controls, which sit beside wide comparisons and below narrow ones.
|
|
346
|
-
- [ImageRegionMarker](./llms/components/data-display/ImageRegionMarker.md): Import from `@alexgorbatchev/shadcn/image-viewer`. Outlines a region over an image: a 2px outline 1px outside the region over a 4px halo in the page background, so the outline keeps 3:1 against any screenshot in both themes; forced colours draw it in Highlight. Variants: `comment` (a saved comment's region), `draft` (dashed, a region being drawn) and `difference` (changed pixels, used by ImageComparison's Highlight differences). Position it with `
|
|
346
|
+
- [ImageRegionMarker](./llms/components/data-display/ImageRegionMarker.md): Import from `@alexgorbatchev/shadcn/image-viewer`. Outlines a region over an image: a 2px outline 1px outside the region over a 4px halo in the page background, so the outline keeps 3:1 against any screenshot in both themes; forced colours draw it in Highlight. Variants: `comment` (a saved comment's region), `draft` (dashed, a region being drawn) and `difference` (changed pixels, used by ImageComparison's Highlight differences). Position it with `region` (left, top, width, height in pixels or any CSS length) over a positioned image box. `ImageRegionMarkerBadge` pins an interactive control, such as a comment count, beside the marker with the same outline and halo; place it with `position`, and pass `interactive={false}` while another gesture owns the pointer. The theme's `target-emphasis` utility is the matching two-tone mark for a jump target on the page.
|
|
347
347
|
- [ImageViewer](./llms/components/data-display/ImageViewer.md): Import from `@alexgorbatchev/shadcn/image-viewer`. ImageViewer fills the container it is given, such as a `DialogContent size="fullscreen"` body, and shows one image in a native scroll viewport. `fit` (the default) scales the image down proportionally to fit both dimensions, centered and without scrollbars, and never upscales it; `original` shows natural size in CSS pixels, centered on axes where it is smaller and scrolling where it is larger. Switching zoom keeps the viewed center. Control zoom with `zoom` and `onZoomChange`, or leave it uncontrolled with `defaultZoom`; place `ImageZoomToggle` in a header or toolbar, or set `showZoomControl` for the built-in toggle. `overlay` renders content sized and positioned exactly over the rendered image at every zoom, `imageRef` and `overlayRef` expose the rendered image box, and `getNormalizedImagePoint(event, box)` maps pointer coordinates to 0–1 image coordinates.
|
|
348
348
|
- [ImageZoomToggle](./llms/components/data-display/ImageZoomToggle.md): Import from `@alexgorbatchev/shadcn/image-viewer`. A two-option toggle for ImageViewer and ImageComparison zoom that consumers place in a header or toolbar. "Fit to screen" and "Original size" are pressed-state toggles with constant names, so assistive technology announces the active zoom through `aria-pressed`. One option always stays pressed. `label` names the group (default "Zoom"); `size`, `orientation`, `layout`, `disabled`, and `density` follow ToggleGroup.
|
|
349
349
|
- [Item](./llms/components/data-display/Item.md)
|