proto-plugin 0.1.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.
- package/AGENTS.md +350 -0
- package/README.md +279 -0
- package/components.json +18 -0
- package/package.json +73 -0
- package/scripts/download-mobbin-reference-images.mjs +112 -0
- package/scripts/lib/host-config.example.sh +48 -0
- package/scripts/lib/host-config.sh +25 -0
- package/scripts/lib/resolve-host-root.mjs +18 -0
- package/scripts/lib/source-path.sh +49 -0
- package/scripts/link-source-db.sh +128 -0
- package/scripts/link-source.sh +40 -0
- package/scripts/publish-package.sh +147 -0
- package/scripts/share-prototype.sh +279 -0
- package/scripts/sync-from-source.sh +74 -0
- package/scripts/verify-prototype-component-ids.mjs +151 -0
- package/scripts/verify-prototype-preview-states.mjs +135 -0
- package/src/app.ts +4 -0
- package/src/components/platform-ui/code-block.tsx +21 -0
- package/src/components/platform-ui/controls-panel-options.tsx +71 -0
- package/src/components/platform-ui/controls-panel-select.tsx +438 -0
- package/src/components/platform-ui/empty-state.tsx +15 -0
- package/src/components/platform-ui/icon-button.tsx +18 -0
- package/src/components/platform-ui/panel-select.tsx +123 -0
- package/src/components/platform-ui/panel.tsx +97 -0
- package/src/components/platform-ui/review-dropdown-menu.tsx +35 -0
- package/src/components/platform-ui/sidebar.tsx +293 -0
- package/src/components/platform-ui/toolbar-icon-button.tsx +34 -0
- package/src/components/platform-ui/toolbar.tsx +37 -0
- package/src/components/prototype-gallery-client.tsx +57 -0
- package/src/components/prototype-provider.tsx +20 -0
- package/src/components/prototypes/mini-pill-label.tsx +37 -0
- package/src/components/prototypes/prototype-change-log-panel.tsx +207 -0
- package/src/components/prototypes/prototype-comment-provider.tsx +61 -0
- package/src/components/prototypes/prototype-comment-toolbar.tsx +65 -0
- package/src/components/prototypes/prototype-control.tsx +31 -0
- package/src/components/prototypes/prototype-controls.tsx +553 -0
- package/src/components/prototypes/prototype-create-exploration-modal.tsx +117 -0
- package/src/components/prototypes/prototype-create-state-modal.tsx +117 -0
- package/src/components/prototypes/prototype-default-state-map-page.tsx +66 -0
- package/src/components/prototypes/prototype-design-brief-modal.tsx +128 -0
- package/src/components/prototypes/prototype-design-brief-panel.tsx +525 -0
- package/src/components/prototypes/prototype-design-context-panel.tsx +65 -0
- package/src/components/prototypes/prototype-floating-pill.module.scss +1341 -0
- package/src/components/prototypes/prototype-mobbin-gallery.tsx +330 -0
- package/src/components/prototypes/prototype-reference-docs.tsx +222 -0
- package/src/components/prototypes/prototype-review-chrome.module.scss +630 -0
- package/src/components/prototypes/prototype-review-chrome.tsx +1241 -0
- package/src/components/prototypes/prototype-review-dropdown-menu-item.tsx +1 -0
- package/src/components/prototypes/prototype-review-dropdown-menu-separator.tsx +1 -0
- package/src/components/prototypes/prototype-review-panel-menu-item.tsx +1 -0
- package/src/components/prototypes/prototype-review-panel-menu-separator.tsx +1 -0
- package/src/components/prototypes/prototype-review-panel-select.tsx +4 -0
- package/src/components/prototypes/prototype-review-sidebar.tsx +167 -0
- package/src/components/prototypes/prototype-share-link-restore.tsx +75 -0
- package/src/components/prototypes/prototype-share-mode.tsx +206 -0
- package/src/components/prototypes/prototype-spec-panel-content.tsx +538 -0
- package/src/components/prototypes/prototype-state-canvas-overlay.module.scss +336 -0
- package/src/components/prototypes/prototype-state-canvas-overlay.tsx +1023 -0
- package/src/components/prototypes/prototype-state-canvas.tsx +38 -0
- package/src/components/prototypes/prototype-state-screenshot-preview.tsx +47 -0
- package/src/components/prototypes/prototype-target.tsx +120 -0
- package/src/components/prototypes/prototype-tweak-highlight.tsx +132 -0
- package/src/components/prototypes/prototype-tweaks.tsx +48 -0
- package/src/components/prototypes/prototype-variant-explorer.tsx +347 -0
- package/src/components/prototypes/prototype-variant-rationale-panel.tsx +49 -0
- package/src/components/prototypes/prototype-variant-tabs.tsx +207 -0
- package/src/components/prototypes/prototype-vercel-preview-modal.tsx +120 -0
- package/src/components/prototypes/state-map-annotation-tooltip.module.scss +89 -0
- package/src/components/prototypes/state-map-annotation-tooltip.tsx +137 -0
- package/src/components/prototypes/state-map-wireframe-highlight.module.scss +25 -0
- package/src/components/prototypes/state-map-wireframe-highlight.tsx +82 -0
- package/src/components/shell/prototype-gallery-shell.tsx +79 -0
- package/src/components/shell/prototype-screenshot-capture.tsx +45 -0
- package/src/components/shell/prototype-shell.module.scss +194 -0
- package/src/components/shell/prototype-shell.tsx +160 -0
- package/src/components/shell/prototype-state-screenshot-capture.tsx +68 -0
- package/src/components/ui/button.tsx +58 -0
- package/src/components/ui/dialog.module.scss +81 -0
- package/src/components/ui/dialog.tsx +127 -0
- package/src/components/ui/dropdown-menu.tsx +200 -0
- package/src/components/ui/input.tsx +22 -0
- package/src/components/ui/label.tsx +26 -0
- package/src/components/ui/option-select.tsx +81 -0
- package/src/components/ui/scroll-area.tsx +48 -0
- package/src/components/ui/separator.tsx +31 -0
- package/src/components/ui/slider.tsx +28 -0
- package/src/components/ui/switch.tsx +29 -0
- package/src/components/ui/tabs.tsx +55 -0
- package/src/components/ui/toggle-group.tsx +80 -0
- package/src/components/ui/tooltip.tsx +32 -0
- package/src/config/create-prototype-gallery-page.tsx +65 -0
- package/src/config/create-prototype-host-app.tsx +121 -0
- package/src/config/create-prototype-page.tsx +41 -0
- package/src/config/create-prototype-site-layout.tsx +28 -0
- package/src/config/define-prototype-config.ts +7 -0
- package/src/config/prototype-icon.tsx +25 -0
- package/src/config/prototype-site-layout-client.tsx +35 -0
- package/src/config/with-prototype.ts +20 -0
- package/src/index.ts +303 -0
- package/src/lib/pr-split/build-pr-agent-prompt.ts +68 -0
- package/src/lib/pr-split/build-pr-split-prototype-url.ts +12 -0
- package/src/lib/pr-split/pr-split-highlight.ts +6 -0
- package/src/lib/pr-split/pr-split-types.ts +58 -0
- package/src/lib/pr-split/resolve-source-preview-url.ts +45 -0
- package/src/lib/pr-split/use-pr-vercel-previews.ts +69 -0
- package/src/lib/prototype-comments/core/annotation-channel.ts +41 -0
- package/src/lib/prototype-comments/core/annotation-status.ts +60 -0
- package/src/lib/prototype-comments/core/annotation-target.ts +567 -0
- package/src/lib/prototype-comments/core/capture-theme.ts +41 -0
- package/src/lib/prototype-comments/core/capture.ts +11 -0
- package/src/lib/prototype-comments/core/comment-capture-blocked.ts +47 -0
- package/src/lib/prototype-comments/core/comment-threads.ts +52 -0
- package/src/lib/prototype-comments/core/element-identification.ts +615 -0
- package/src/lib/prototype-comments/core/export.ts +35 -0
- package/src/lib/prototype-comments/core/freeze-animations.ts +266 -0
- package/src/lib/prototype-comments/core/identify-element.ts +76 -0
- package/src/lib/prototype-comments/core/normalize-viewport.ts +35 -0
- package/src/lib/prototype-comments/core/react-detection.ts +704 -0
- package/src/lib/prototype-comments/core/restore.ts +7 -0
- package/src/lib/prototype-comments/core/screenshot.ts +428 -0
- package/src/lib/prototype-comments/core/source-location.ts +906 -0
- package/src/lib/prototype-comments/core/storage.ts +80 -0
- package/src/lib/prototype-comments/core/types.ts +79 -0
- package/src/lib/prototype-comments/core/validation.ts +17 -0
- package/src/lib/prototype-comments/hooks/useLayoutShift.ts +61 -0
- package/src/lib/prototype-comments/index.ts +58 -0
- package/src/lib/prototype-comments/react/CommentCaptureToolbar.tsx +1398 -0
- package/src/lib/prototype-comments/react/CommentProvider.tsx +298 -0
- package/src/lib/prototype-comments/scss.d.ts +10 -0
- package/src/lib/prototype-comments/ui/CommentAnnotationOverlay.tsx +253 -0
- package/src/lib/prototype-comments/ui/CommentDetailPage.tsx +56 -0
- package/src/lib/prototype-comments/ui/CommentHeaderCount.tsx +28 -0
- package/src/lib/prototype-comments/ui/CommentThread.tsx +331 -0
- package/src/lib/prototype-comments/ui/CommentsGrid.tsx +780 -0
- package/src/lib/prototype-comments/ui/CommentsListPage.tsx +25 -0
- package/src/lib/prototype-comments/ui/CommentsSidebar.tsx +77 -0
- package/src/lib/prototype-comments/ui/annotation-marker/index.tsx +200 -0
- package/src/lib/prototype-comments/ui/annotation-marker/styles.module.scss +194 -0
- package/src/lib/prototype-comments/ui/annotation-popup/index.tsx +335 -0
- package/src/lib/prototype-comments/ui/annotation-popup/styles.module.scss +469 -0
- package/src/lib/prototype-comments/ui/capture-styles.module.scss +2225 -0
- package/src/lib/prototype-comments/ui/comment-highlight.ts +48 -0
- package/src/lib/prototype-comments/ui/comment-thread.module.scss +203 -0
- package/src/lib/prototype-comments/ui/comments-grid-card.module.scss +253 -0
- package/src/lib/prototype-comments/ui/comments-sidebar.module.scss +123 -0
- package/src/lib/prototype-comments/ui/icon-transitions.module.scss +51 -0
- package/src/lib/prototype-comments/ui/icons.tsx +1086 -0
- package/src/lib/prototype-comments/ui/is-comment-detail-path.ts +7 -0
- package/src/lib/prototypes/capture-prototype-viewport.ts +32 -0
- package/src/lib/prototypes/changelog-meta-context.tsx +162 -0
- package/src/lib/prototypes/changelog-meta-storage.ts +62 -0
- package/src/lib/prototypes/changelog-meta.ts +95 -0
- package/src/lib/prototypes/create-prototype-registry.ts +74 -0
- package/src/lib/prototypes/create-state-screenshot-thumbnail.ts +46 -0
- package/src/lib/prototypes/design-exploration-default-storage.ts +68 -0
- package/src/lib/prototypes/design-exploration-default.ts +51 -0
- package/src/lib/prototypes/design-exploration-types.ts +203 -0
- package/src/lib/prototypes/prototype-comment-registry.tsx +145 -0
- package/src/lib/prototypes/prototype-comment-review-bridge.tsx +40 -0
- package/src/lib/prototypes/prototype-comment-review-state.ts +57 -0
- package/src/lib/prototypes/prototype-component-registry.ts +40 -0
- package/src/lib/prototypes/prototype-config-types.ts +34 -0
- package/src/lib/prototypes/prototype-preview-state-registry.ts +443 -0
- package/src/lib/prototypes/prototype-preview-state-types.ts +89 -0
- package/src/lib/prototypes/prototype-review-context.tsx +905 -0
- package/src/lib/prototypes/prototype-review-url.ts +134 -0
- package/src/lib/prototypes/prototype-share-link.ts +175 -0
- package/src/lib/prototypes/prototype-state-canvas-constants.ts +118 -0
- package/src/lib/prototypes/prototype-state-canvas-types.ts +159 -0
- package/src/lib/prototypes/prototype-state-screenshot.ts +39 -0
- package/src/lib/prototypes/prototype-tweak-registry.ts +96 -0
- package/src/lib/prototypes/prototype-tweak-types.ts +31 -0
- package/src/lib/prototypes/reference-docs.ts +137 -0
- package/src/lib/prototypes/screenshot-manifest.ts +33 -0
- package/src/lib/prototypes/screenshot-src.ts +7 -0
- package/src/lib/prototypes/share-command.ts +8 -0
- package/src/lib/prototypes/state-map-annotation.ts +70 -0
- package/src/lib/prototypes/use-design-exploration-default.ts +114 -0
- package/src/lib/prototypes/use-persisted-local-state.ts +140 -0
- package/src/lib/prototypes/use-prototype-comments.ts +63 -0
- package/src/lib/prototypes/use-prototype-mobile-viewport-frame.ts +46 -0
- package/src/lib/prototypes/use-prototype-state-screenshot-src.ts +71 -0
- package/src/lib/prototypes/use-prototype-tool-theme.tsx +115 -0
- package/src/lib/prototypes/use-prototype-viewport-frame.ts +34 -0
- package/src/lib/prototypes/use-register-prototype-reference-docs.ts +16 -0
- package/src/lib/prototypes/use-snap-corner-position.ts +417 -0
- package/src/lib/prototypes/use-toolbar-hover-panel.ts +98 -0
- package/src/lib/prototypes/variant-set-lucide-icon.tsx +55 -0
- package/src/lib/tool-portal.ts +33 -0
- package/src/lib/use-copy-to-clipboard.ts +81 -0
- package/src/lib/utils.ts +6 -0
- package/src/lib/vercel-preview/parse-vercel-github-comment.ts +81 -0
- package/src/server/create-host-api-route.ts +100 -0
- package/src/server/create-prototype-api-routes.ts +428 -0
- package/src/server/gallery/create-gallery-api.ts +56 -0
- package/src/server/gallery/folders-route.ts +156 -0
- package/src/server/gallery/gallery-env.ts +39 -0
- package/src/server/gallery/gallery-route.ts +150 -0
- package/src/server/gallery/gallery-types.ts +15 -0
- package/src/server/gallery/image-route.ts +59 -0
- package/src/server/gallery/item-route.ts +92 -0
- package/src/server/pr-vercel-preview-route.ts +162 -0
- package/src/server/redis/client.ts +55 -0
- package/src/server/redis/prototype-changelog-meta.ts +31 -0
- package/src/server/redis/prototype-comments.ts +92 -0
- package/src/server/redis/prototype-design-exploration-default.ts +32 -0
- package/src/server.ts +51 -0
- package/src/styles/globals.css +624 -0
- package/tsconfig.json +19 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { ReviewDropdownMenuItem as PrototypeReviewDropdownMenuItem } from "@prototype/components/platform-ui/review-dropdown-menu";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { ReviewDropdownMenuSeparator as PrototypeReviewDropdownMenuSeparator } from "@prototype/components/platform-ui/review-dropdown-menu";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { PanelMenuItem as PrototypeReviewPanelMenuItem } from "@prototype/components/platform-ui/panel-select";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { PanelMenuSeparator as PrototypeReviewPanelMenuSeparator } from "@prototype/components/platform-ui/panel-select";
|
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import { filterAnnotationsByChannel } from "@prototype/lib/prototype-comments/core/annotation-channel";
|
|
4
|
+
import { countUnresolvedAnnotations } from "@prototype/lib/prototype-comments/core/annotation-status";
|
|
5
|
+
import { getRootAnnotations } from "@prototype/lib/prototype-comments/core/comment-threads";
|
|
6
|
+
import { useCommentStore } from "@prototype/lib/prototype-comments/react/CommentProvider";
|
|
7
|
+
import { CommentHeaderCount } from "@prototype/lib/prototype-comments/ui/CommentHeaderCount";
|
|
8
|
+
import { CommentsGrid } from "@prototype/lib/prototype-comments/ui/CommentsGrid";
|
|
9
|
+
import { usePrototypeReview } from "@prototype/lib/prototypes/prototype-review-context";
|
|
10
|
+
import {
|
|
11
|
+
SIDEBAR_ICON_BUTTON_CLASS,
|
|
12
|
+
Sidebar,
|
|
13
|
+
} from "@prototype/components/platform-ui/sidebar";
|
|
14
|
+
import { IconButton } from "@prototype/components/platform-ui/icon-button";
|
|
15
|
+
import { cn } from "@prototype/lib/utils";
|
|
16
|
+
import { EmptyState } from "@prototype/components/platform-ui/empty-state";
|
|
17
|
+
import { PrototypeChangeLogPanel } from "@prototype/components/prototypes/prototype-change-log-panel";
|
|
18
|
+
import { miniPillTextFromLabel } from "@prototype/components/prototypes/mini-pill-label";
|
|
19
|
+
import { MessageSquarePlus } from "lucide-react";
|
|
20
|
+
import { useMemo } from "react";
|
|
21
|
+
|
|
22
|
+
type PrototypeReviewSidebarProps = {
|
|
23
|
+
onSelect: (id: string) => void;
|
|
24
|
+
selectedId?: string | null;
|
|
25
|
+
onClose: () => void;
|
|
26
|
+
isCommentModeActive?: boolean;
|
|
27
|
+
onToggleCommentMode?: () => void;
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
export function PrototypeReviewSidebar({
|
|
31
|
+
onSelect,
|
|
32
|
+
selectedId,
|
|
33
|
+
onClose,
|
|
34
|
+
isCommentModeActive = false,
|
|
35
|
+
onToggleCommentMode,
|
|
36
|
+
}: PrototypeReviewSidebarProps) {
|
|
37
|
+
const review = usePrototypeReview();
|
|
38
|
+
const { annotations, deleteAnnotation, updateAnnotation, resolveAnnotation, storageError, storageReady } = useCommentStore();
|
|
39
|
+
const isVariantsPanel = review.sidebarPanel === "variants";
|
|
40
|
+
const isChangeLogPanel = review.sidebarPanel === "change-log";
|
|
41
|
+
const isSpecPanel = review.sidebarPanel === "spec";
|
|
42
|
+
|
|
43
|
+
const activeVariantLabel = useMemo(() => {
|
|
44
|
+
if (!review.activeVariantSetId) return "Variants";
|
|
45
|
+
const label = review.variantSets.find(
|
|
46
|
+
(set) => set.id === review.activeVariantSetId,
|
|
47
|
+
)?.label;
|
|
48
|
+
return label ? miniPillTextFromLabel(label) : "Variants";
|
|
49
|
+
}, [review.activeVariantSetId, review.variantSets]);
|
|
50
|
+
|
|
51
|
+
const variantsContent = useMemo(() => {
|
|
52
|
+
if (!isVariantsPanel) return null;
|
|
53
|
+
if (review.activeVariantSetId) {
|
|
54
|
+
return review.getVariantSidebarContent(review.activeVariantSetId);
|
|
55
|
+
}
|
|
56
|
+
return review.getLegacyVariantSidebarContent();
|
|
57
|
+
}, [
|
|
58
|
+
isVariantsPanel,
|
|
59
|
+
review.activeVariantSetId,
|
|
60
|
+
review.variantSidebarRevision,
|
|
61
|
+
review.getVariantSidebarContent,
|
|
62
|
+
review.getLegacyVariantSidebarContent,
|
|
63
|
+
]);
|
|
64
|
+
|
|
65
|
+
const commentAnnotations = useMemo(
|
|
66
|
+
() => filterAnnotationsByChannel(annotations, "comment"),
|
|
67
|
+
[annotations],
|
|
68
|
+
);
|
|
69
|
+
const unresolvedCount = countUnresolvedAnnotations(commentAnnotations);
|
|
70
|
+
const totalCount = getRootAnnotations(commentAnnotations).length;
|
|
71
|
+
|
|
72
|
+
const specContent = isSpecPanel ? review.specContentRef.current : null;
|
|
73
|
+
|
|
74
|
+
const isCommentsPanel =
|
|
75
|
+
!isVariantsPanel && !isChangeLogPanel && !isSpecPanel;
|
|
76
|
+
|
|
77
|
+
const sidebarText = isVariantsPanel
|
|
78
|
+
? activeVariantLabel
|
|
79
|
+
: isChangeLogPanel
|
|
80
|
+
? "Overview"
|
|
81
|
+
: isSpecPanel
|
|
82
|
+
? "PRs"
|
|
83
|
+
: "Comments";
|
|
84
|
+
|
|
85
|
+
return (
|
|
86
|
+
<Sidebar
|
|
87
|
+
open={review.open}
|
|
88
|
+
text={sidebarText}
|
|
89
|
+
titleAddon={
|
|
90
|
+
isCommentsPanel ? (
|
|
91
|
+
<CommentHeaderCount
|
|
92
|
+
unresolved={unresolvedCount}
|
|
93
|
+
total={totalCount}
|
|
94
|
+
/>
|
|
95
|
+
) : undefined
|
|
96
|
+
}
|
|
97
|
+
headerActions={
|
|
98
|
+
isCommentsPanel && onToggleCommentMode ? (
|
|
99
|
+
<IconButton
|
|
100
|
+
type="button"
|
|
101
|
+
onClick={onToggleCommentMode}
|
|
102
|
+
onMouseDown={(event) => event.preventDefault()}
|
|
103
|
+
aria-label={
|
|
104
|
+
isCommentModeActive ? "Exit comment mode" : "Add comment"
|
|
105
|
+
}
|
|
106
|
+
aria-pressed={isCommentModeActive}
|
|
107
|
+
className={cn(
|
|
108
|
+
SIDEBAR_ICON_BUTTON_CLASS,
|
|
109
|
+
isCommentModeActive && "bg-accent text-accent-foreground",
|
|
110
|
+
)}
|
|
111
|
+
>
|
|
112
|
+
<MessageSquarePlus size={16} strokeWidth={2} />
|
|
113
|
+
</IconButton>
|
|
114
|
+
) : undefined
|
|
115
|
+
}
|
|
116
|
+
onClose={
|
|
117
|
+
isVariantsPanel
|
|
118
|
+
? review.closeVariants
|
|
119
|
+
: isSpecPanel
|
|
120
|
+
? review.closeSidebar
|
|
121
|
+
: isChangeLogPanel
|
|
122
|
+
? review.closeSidebar
|
|
123
|
+
: onClose
|
|
124
|
+
}
|
|
125
|
+
ariaLabel={
|
|
126
|
+
isVariantsPanel
|
|
127
|
+
? "Variants panel"
|
|
128
|
+
: isChangeLogPanel
|
|
129
|
+
? "Overview panel"
|
|
130
|
+
: isSpecPanel
|
|
131
|
+
? "PRs panel"
|
|
132
|
+
: "Review panel"
|
|
133
|
+
}
|
|
134
|
+
dataAttribute="data-prototype-review-sidebar"
|
|
135
|
+
widthCssVar="--comments-sidebar-width"
|
|
136
|
+
>
|
|
137
|
+
{isSpecPanel ? (
|
|
138
|
+
specContent ?? (
|
|
139
|
+
<EmptyState>
|
|
140
|
+
No PRs configured yet. Add a PR split spec on this prototype to
|
|
141
|
+
see implementation cards here.
|
|
142
|
+
</EmptyState>
|
|
143
|
+
)
|
|
144
|
+
) : isVariantsPanel ? (
|
|
145
|
+
variantsContent ?? (
|
|
146
|
+
<EmptyState>No variant overview available.</EmptyState>
|
|
147
|
+
)
|
|
148
|
+
) : isChangeLogPanel ? (
|
|
149
|
+
<PrototypeChangeLogPanel onSelect={onSelect} selectedId={selectedId} />
|
|
150
|
+
) : !storageReady ? (
|
|
151
|
+
<EmptyState>Loading comments…</EmptyState>
|
|
152
|
+
) : storageError ? (
|
|
153
|
+
<EmptyState>{storageError}</EmptyState>
|
|
154
|
+
) : (
|
|
155
|
+
<CommentsGrid
|
|
156
|
+
annotations={commentAnnotations}
|
|
157
|
+
layout="sidebar"
|
|
158
|
+
onSelect={onSelect}
|
|
159
|
+
onDelete={deleteAnnotation}
|
|
160
|
+
onUpdateComment={updateAnnotation}
|
|
161
|
+
onResolve={resolveAnnotation}
|
|
162
|
+
selectedId={selectedId}
|
|
163
|
+
/>
|
|
164
|
+
)}
|
|
165
|
+
</Sidebar>
|
|
166
|
+
);
|
|
167
|
+
}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import { usePrototypeCommentRegistry } from "@prototype/lib/prototypes/prototype-comment-registry";
|
|
4
|
+
import { usePrototypeReviewOptional } from "@prototype/lib/prototypes/prototype-review-context";
|
|
5
|
+
import {
|
|
6
|
+
clearShareComponentParams,
|
|
7
|
+
readShareLinkParams,
|
|
8
|
+
scrollPrototypeTargetIntoView,
|
|
9
|
+
} from "@prototype/lib/prototypes/prototype-share-link";
|
|
10
|
+
import { useEffect, useRef } from "react";
|
|
11
|
+
|
|
12
|
+
const HANDLER_RETRY_MS = 50;
|
|
13
|
+
const HANDLER_RETRY_LIMIT = 40;
|
|
14
|
+
|
|
15
|
+
export function PrototypeShareLinkRestore() {
|
|
16
|
+
const { readHandlers } = usePrototypeCommentRegistry();
|
|
17
|
+
const review = usePrototypeReviewOptional();
|
|
18
|
+
const restoredRef = useRef(false);
|
|
19
|
+
|
|
20
|
+
useEffect(() => {
|
|
21
|
+
if (restoredRef.current || !review) return;
|
|
22
|
+
|
|
23
|
+
const shareParams = readShareLinkParams(
|
|
24
|
+
new URLSearchParams(window.location.search),
|
|
25
|
+
);
|
|
26
|
+
if (!shareParams) return;
|
|
27
|
+
|
|
28
|
+
let attempts = 0;
|
|
29
|
+
|
|
30
|
+
const completeRestore = () => {
|
|
31
|
+
restoredRef.current = true;
|
|
32
|
+
|
|
33
|
+
const targetId = shareParams.targetId;
|
|
34
|
+
|
|
35
|
+
window.requestAnimationFrame(() => {
|
|
36
|
+
window.requestAnimationFrame(() => {
|
|
37
|
+
scrollPrototypeTargetIntoView(targetId);
|
|
38
|
+
review.focusShareTarget(targetId);
|
|
39
|
+
|
|
40
|
+
const url = new URL(window.location.href);
|
|
41
|
+
clearShareComponentParams(url);
|
|
42
|
+
window.history.replaceState(null, "", url);
|
|
43
|
+
});
|
|
44
|
+
});
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
const tryRestore = () => {
|
|
48
|
+
if (restoredRef.current) return;
|
|
49
|
+
|
|
50
|
+
const handlers = readHandlers();
|
|
51
|
+
const needsStateRestore = shareParams.state != null;
|
|
52
|
+
|
|
53
|
+
if (needsStateRestore && !handlers?.onRestore) {
|
|
54
|
+
if (attempts >= HANDLER_RETRY_LIMIT) {
|
|
55
|
+
completeRestore();
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
attempts += 1;
|
|
60
|
+
window.setTimeout(tryRestore, HANDLER_RETRY_MS);
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
if (needsStateRestore && handlers?.onRestore) {
|
|
65
|
+
handlers.onRestore(shareParams.state);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
completeRestore();
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
tryRestore();
|
|
72
|
+
}, [readHandlers, review]);
|
|
73
|
+
|
|
74
|
+
return null;
|
|
75
|
+
}
|
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
getPrototypeTargetElement,
|
|
5
|
+
getPrototypeTargetIdFromElement,
|
|
6
|
+
} from "@prototype/components/prototypes/prototype-target";
|
|
7
|
+
import { buildCommentCaptureCursorStyles, isCommentCaptureBlockedTarget } from "@prototype/lib/prototype-comments/core/comment-capture-blocked";
|
|
8
|
+
import { deepElementFromPoint } from "@prototype/lib/prototype-comments/core/annotation-target";
|
|
9
|
+
import { injectCaptureColorTokens } from "@prototype/lib/prototype-comments/core/capture-theme";
|
|
10
|
+
import { useCommentCaptureBridgeOptional } from "@prototype/lib/prototype-comments/react/CommentCaptureToolbar";
|
|
11
|
+
import styles from "@prototype/lib/prototype-comments/ui/capture-styles.module.scss";
|
|
12
|
+
import { usePrototypeCommentRegistry } from "@prototype/lib/prototypes/prototype-comment-registry";
|
|
13
|
+
import { usePrototypeReview } from "@prototype/lib/prototypes/prototype-review-context";
|
|
14
|
+
import { usePrototypeToolTheme } from "@prototype/lib/prototypes/use-prototype-tool-theme";
|
|
15
|
+
import { buildComponentShareLink } from "@prototype/lib/prototypes/prototype-share-link";
|
|
16
|
+
import { cn } from "@prototype/lib/utils";
|
|
17
|
+
import { X } from "lucide-react";
|
|
18
|
+
import { useEffect, useState } from "react";
|
|
19
|
+
import { createPortal } from "react-dom";
|
|
20
|
+
import { toast } from "sonner";
|
|
21
|
+
|
|
22
|
+
const SHARE_BORDER =
|
|
23
|
+
"color-mix(in srgb, var(--prototype-comment-color-blue) 60%, transparent)";
|
|
24
|
+
const SHARE_FILL =
|
|
25
|
+
"color-mix(in srgb, var(--prototype-comment-color-blue) 5%, transparent)";
|
|
26
|
+
|
|
27
|
+
export function PrototypeShareMode() {
|
|
28
|
+
const review = usePrototypeReview();
|
|
29
|
+
const { commentTheme } = usePrototypeToolTheme();
|
|
30
|
+
const bridge = useCommentCaptureBridgeOptional();
|
|
31
|
+
const { readHandlers } = usePrototypeCommentRegistry();
|
|
32
|
+
const [mounted, setMounted] = useState(false);
|
|
33
|
+
const [hoverRect, setHoverRect] = useState<DOMRect | null>(null);
|
|
34
|
+
const [hoverLabel, setHoverLabel] = useState<string | null>(null);
|
|
35
|
+
|
|
36
|
+
useEffect(() => {
|
|
37
|
+
setMounted(true);
|
|
38
|
+
injectCaptureColorTokens();
|
|
39
|
+
}, []);
|
|
40
|
+
|
|
41
|
+
useEffect(() => {
|
|
42
|
+
if (!review.shareModeActive) return;
|
|
43
|
+
if (bridge?.isCommentModeActive) {
|
|
44
|
+
bridge.onEnterCommentMode();
|
|
45
|
+
}
|
|
46
|
+
}, [bridge, review.shareModeActive]);
|
|
47
|
+
|
|
48
|
+
useEffect(() => {
|
|
49
|
+
if (bridge?.isCommentModeActive && review.shareModeActive) {
|
|
50
|
+
review.exitShareMode();
|
|
51
|
+
}
|
|
52
|
+
}, [bridge, review]);
|
|
53
|
+
|
|
54
|
+
useEffect(() => {
|
|
55
|
+
if (!review.shareModeActive) {
|
|
56
|
+
setHoverRect(null);
|
|
57
|
+
setHoverLabel(null);
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
const handleMouseMove = (event: MouseEvent) => {
|
|
62
|
+
const target = (event.composedPath()[0] || event.target) as HTMLElement;
|
|
63
|
+
if (isCommentCaptureBlockedTarget(target)) {
|
|
64
|
+
setHoverRect(null);
|
|
65
|
+
setHoverLabel(null);
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
const elementUnder = deepElementFromPoint(event.clientX, event.clientY);
|
|
70
|
+
if (!elementUnder || isCommentCaptureBlockedTarget(elementUnder)) {
|
|
71
|
+
setHoverRect(null);
|
|
72
|
+
setHoverLabel(null);
|
|
73
|
+
return;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
const anchor = getPrototypeTargetElement(elementUnder);
|
|
77
|
+
if (!anchor) {
|
|
78
|
+
setHoverRect(null);
|
|
79
|
+
setHoverLabel(null);
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
setHoverRect(anchor.getBoundingClientRect());
|
|
84
|
+
setHoverLabel(anchor.getAttribute("data-element"));
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
document.addEventListener("mousemove", handleMouseMove);
|
|
88
|
+
return () => document.removeEventListener("mousemove", handleMouseMove);
|
|
89
|
+
}, [review.shareModeActive]);
|
|
90
|
+
|
|
91
|
+
useEffect(() => {
|
|
92
|
+
if (!review.shareModeActive) return;
|
|
93
|
+
|
|
94
|
+
const handleClick = (event: MouseEvent) => {
|
|
95
|
+
const target = (event.composedPath()[0] || event.target) as HTMLElement;
|
|
96
|
+
if (isCommentCaptureBlockedTarget(target)) return;
|
|
97
|
+
|
|
98
|
+
const elementUnder = deepElementFromPoint(event.clientX, event.clientY);
|
|
99
|
+
if (!elementUnder || isCommentCaptureBlockedTarget(elementUnder)) return;
|
|
100
|
+
|
|
101
|
+
const anchor = getPrototypeTargetElement(elementUnder);
|
|
102
|
+
const targetId = getPrototypeTargetIdFromElement(elementUnder);
|
|
103
|
+
if (!anchor || !targetId) {
|
|
104
|
+
toast.error("Select a prototype component to share");
|
|
105
|
+
return;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
event.preventDefault();
|
|
109
|
+
event.stopPropagation();
|
|
110
|
+
|
|
111
|
+
const handlers = readHandlers();
|
|
112
|
+
const liveState = handlers?.getLiveState() ?? {};
|
|
113
|
+
const shareLink = buildComponentShareLink(targetId, liveState, {
|
|
114
|
+
commentId: bridge?.selectedId,
|
|
115
|
+
});
|
|
116
|
+
|
|
117
|
+
void navigator.clipboard
|
|
118
|
+
.writeText(shareLink)
|
|
119
|
+
.then(() => {
|
|
120
|
+
toast.success("Component link copied", {
|
|
121
|
+
description: "Paste the link to share this view.",
|
|
122
|
+
duration: 3000,
|
|
123
|
+
});
|
|
124
|
+
review.exitShareMode();
|
|
125
|
+
})
|
|
126
|
+
.catch(() => {
|
|
127
|
+
toast.error("Could not copy to clipboard");
|
|
128
|
+
});
|
|
129
|
+
};
|
|
130
|
+
|
|
131
|
+
const handleKeyDown = (event: KeyboardEvent) => {
|
|
132
|
+
if (event.key === "Escape") {
|
|
133
|
+
review.exitShareMode();
|
|
134
|
+
}
|
|
135
|
+
};
|
|
136
|
+
|
|
137
|
+
document.addEventListener("click", handleClick, true);
|
|
138
|
+
document.addEventListener("keydown", handleKeyDown);
|
|
139
|
+
return () => {
|
|
140
|
+
document.removeEventListener("click", handleClick, true);
|
|
141
|
+
document.removeEventListener("keydown", handleKeyDown);
|
|
142
|
+
};
|
|
143
|
+
}, [readHandlers, review]);
|
|
144
|
+
|
|
145
|
+
useEffect(() => {
|
|
146
|
+
if (!review.shareModeActive) return;
|
|
147
|
+
|
|
148
|
+
const style = document.createElement("style");
|
|
149
|
+
style.id = "prototype-share-mode-cursor";
|
|
150
|
+
style.textContent = buildCommentCaptureCursorStyles();
|
|
151
|
+
document.head.appendChild(style);
|
|
152
|
+
|
|
153
|
+
return () => {
|
|
154
|
+
style.remove();
|
|
155
|
+
};
|
|
156
|
+
}, [review.shareModeActive]);
|
|
157
|
+
|
|
158
|
+
if (!mounted || !review.shareModeActive) return null;
|
|
159
|
+
|
|
160
|
+
return createPortal(
|
|
161
|
+
<>
|
|
162
|
+
<div
|
|
163
|
+
data-prototype-comment-theme={commentTheme}
|
|
164
|
+
data-prototype-comment-accent="blue"
|
|
165
|
+
data-prototype-comment-root=""
|
|
166
|
+
data-prototype-share-overlay=""
|
|
167
|
+
className={styles.targetHighlightLayer}
|
|
168
|
+
>
|
|
169
|
+
{hoverRect ? (
|
|
170
|
+
<div
|
|
171
|
+
aria-hidden
|
|
172
|
+
className={cn(styles.singleSelectOutline, styles.enter)}
|
|
173
|
+
style={{
|
|
174
|
+
left: hoverRect.left,
|
|
175
|
+
top: hoverRect.top,
|
|
176
|
+
width: hoverRect.width,
|
|
177
|
+
height: hoverRect.height,
|
|
178
|
+
borderColor: SHARE_BORDER,
|
|
179
|
+
backgroundColor: SHARE_FILL,
|
|
180
|
+
}}
|
|
181
|
+
/>
|
|
182
|
+
) : null}
|
|
183
|
+
</div>
|
|
184
|
+
|
|
185
|
+
<div
|
|
186
|
+
data-prototype-share-hint
|
|
187
|
+
className="pointer-events-auto fixed bottom-20 left-1/2 z-[1051] flex -translate-x-1/2 items-center gap-2 rounded-lg bg-card px-3 py-2 shadow-md ring-[0.5px] ring-border"
|
|
188
|
+
>
|
|
189
|
+
<span className="text-xs text-foreground">
|
|
190
|
+
{hoverLabel
|
|
191
|
+
? `Click to copy link to ${hoverLabel}`
|
|
192
|
+
: "Click a component to copy its link"}
|
|
193
|
+
</span>
|
|
194
|
+
<button
|
|
195
|
+
type="button"
|
|
196
|
+
aria-label="Exit share mode"
|
|
197
|
+
className="text-muted-foreground hover:text-foreground rounded p-1 transition-colors duration-200 ease"
|
|
198
|
+
onClick={review.exitShareMode}
|
|
199
|
+
>
|
|
200
|
+
<X size={14} />
|
|
201
|
+
</button>
|
|
202
|
+
</div>
|
|
203
|
+
</>,
|
|
204
|
+
document.body,
|
|
205
|
+
);
|
|
206
|
+
}
|