@bevel-software/platform-core-frontend 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/LICENSE +202 -0
- package/package.json +70 -0
- package/src/core/CoreAppShell.tsx +444 -0
- package/src/core/__tests__/ShellRoutes.test.tsx +95 -0
- package/src/core/events.ts +29 -0
- package/src/core/registry.ts +336 -0
- package/src/css-side-effect-imports.d.ts +7 -0
- package/src/html-extensions.ts +12 -0
- package/src/index.css +49 -0
- package/src/index.ts +23 -0
- package/src/lib/api.ts +57 -0
- package/src/lib/utils.ts +138 -0
- package/src/modules/access/__tests__/ManageAccessDialog.test.tsx +130 -0
- package/src/modules/access/__tests__/useFileAccess.test.tsx +253 -0
- package/src/modules/access/api.ts +205 -0
- package/src/modules/access/components/AccessRestrictedBanner.tsx +31 -0
- package/src/modules/access/components/ManageAccessDialog.tsx +1232 -0
- package/src/modules/access/components/NodeOwnersBanner.tsx +30 -0
- package/src/modules/access/hooks/useFileAccess.ts +151 -0
- package/src/modules/admin/components/AdminRolesPage.tsx +943 -0
- package/src/modules/admin/components/RolesCorruptedBanner.tsx +74 -0
- package/src/modules/admin/services/admin.api.ts +92 -0
- package/src/modules/admin/services/roles.api.ts +136 -0
- package/src/modules/admin/state/admin.context.tsx +223 -0
- package/src/modules/auth/components/LoginScreen.tsx +135 -0
- package/src/modules/auth/hooks/useAuthState.ts +59 -0
- package/src/modules/auth/services/auth.api.ts +24 -0
- package/src/modules/auth/services/microsoft-oauth.ts +57 -0
- package/src/modules/auth/state/auth.context.ts +18 -0
- package/src/modules/git/__tests__/BranchSwitcher.test.tsx +347 -0
- package/src/modules/git/__tests__/FileHistoryPanel.test.tsx +201 -0
- package/src/modules/git/__tests__/ProtectedBranchBanner.test.tsx +82 -0
- package/src/modules/git/__tests__/PullNeededBanner.test.tsx +441 -0
- package/src/modules/git/__tests__/git.api.test.ts +113 -0
- package/src/modules/git/__tests__/pr.api.test.ts +44 -0
- package/src/modules/git/__tests__/useAutoPullUpdates.test.tsx +212 -0
- package/src/modules/git/components/BranchSwitcher.tsx +527 -0
- package/src/modules/git/components/DiffView.tsx +30 -0
- package/src/modules/git/components/FileComparisonPanel.tsx +377 -0
- package/src/modules/git/components/FileHistoryPanel.tsx +320 -0
- package/src/modules/git/components/ProtectedBranchBanner.tsx +42 -0
- package/src/modules/git/components/PullNeededBanner.tsx +204 -0
- package/src/modules/git/components/PullRequestsForMe.tsx +244 -0
- package/src/modules/git/components/UnifiedDiffView.tsx +37 -0
- package/src/modules/git/hooks/__tests__/useGitState.deleteBranch.test.tsx +99 -0
- package/src/modules/git/hooks/useAutoPullUpdates.ts +121 -0
- package/src/modules/git/hooks/useGitState.ts +335 -0
- package/src/modules/git/services/__tests__/error-messages.test.ts +134 -0
- package/src/modules/git/services/error-messages.ts +257 -0
- package/src/modules/git/services/git.api.ts +163 -0
- package/src/modules/git/services/pr-prompts.ts +159 -0
- package/src/modules/git/services/pr.api.ts +39 -0
- package/src/modules/git/state/auto-update.context.ts +21 -0
- package/src/modules/git/state/git.context.ts +82 -0
- package/src/modules/layout/components/AppLayout.tsx +40 -0
- package/src/modules/layout/components/DemoBanner.tsx +57 -0
- package/src/modules/layout/components/MaintenanceOverlay.tsx +104 -0
- package/src/modules/layout/components/MobileChatLayout.tsx +153 -0
- package/src/modules/layout/components/ResizableThreePaneLayout.tsx +203 -0
- package/src/modules/layout/components/SlideOverlay.tsx +224 -0
- package/src/modules/layout/components/__tests__/MobileChatLayout.test.tsx +77 -0
- package/src/modules/layout/components/__tests__/ResizableThreePaneLayout.test.tsx +57 -0
- package/src/modules/layout/hooks/useMediaQuery.ts +23 -0
- package/src/modules/layout/state/__tests__/layout.context.test.tsx +39 -0
- package/src/modules/layout/state/layout.context.ts +46 -0
- package/src/modules/library/__tests__/DetailDialog.test.tsx +200 -0
- package/src/modules/library/__tests__/diff.test.ts +62 -0
- package/src/modules/library/__tests__/loadout.test.tsx +72 -0
- package/src/modules/library/__tests__/status.test.ts +117 -0
- package/src/modules/library/components/ChangeRequestDock.tsx +47 -0
- package/src/modules/library/components/CompareView.tsx +357 -0
- package/src/modules/library/components/DetailDialog.tsx +566 -0
- package/src/modules/library/components/GearIcon.tsx +12 -0
- package/src/modules/library/components/LibraryCard.tsx +132 -0
- package/src/modules/library/components/LibraryPage.tsx +254 -0
- package/src/modules/library/components/LoadoutSidebar.tsx +156 -0
- package/src/modules/library/components/StatusGem.tsx +21 -0
- package/src/modules/library/components/SuggestChange.tsx +171 -0
- package/src/modules/library/components/particles.ts +50 -0
- package/src/modules/library/hooks/useLibraryData.ts +119 -0
- package/src/modules/library/hooks/useSkillDetail.ts +74 -0
- package/src/modules/library/library.css +320 -0
- package/src/modules/library/services/library.api.ts +164 -0
- package/src/modules/library/state/loadout.tsx +129 -0
- package/src/modules/library/state/toast.tsx +42 -0
- package/src/modules/library/utils/diff.ts +102 -0
- package/src/modules/library/utils/status.ts +116 -0
- package/src/modules/pr/__tests__/PrApprovalBadge.test.tsx +93 -0
- package/src/modules/pr/__tests__/PrCancelButton.test.tsx +158 -0
- package/src/modules/pr/__tests__/PrCancelConfirmDialog.test.tsx +44 -0
- package/src/modules/pr/__tests__/PrMergeButton.test.tsx +360 -0
- package/src/modules/pr/__tests__/bucketize-comments.test.ts +85 -0
- package/src/modules/pr/__tests__/parsePatch.test.ts +104 -0
- package/src/modules/pr/__tests__/usePrViewerState.test.ts +72 -0
- package/src/modules/pr/components/OpenChangeRequestDialog.tsx +193 -0
- package/src/modules/pr/components/PrApprovalBadge.tsx +80 -0
- package/src/modules/pr/components/PrCancelButton.tsx +99 -0
- package/src/modules/pr/components/PrCancelConfirmDialog.tsx +119 -0
- package/src/modules/pr/components/PrCommentComposer.tsx +92 -0
- package/src/modules/pr/components/PrCommentThread.tsx +168 -0
- package/src/modules/pr/components/PrCommentsPanel.tsx +143 -0
- package/src/modules/pr/components/PrDiffPane.tsx +425 -0
- package/src/modules/pr/components/PrFileRow.tsx +164 -0
- package/src/modules/pr/components/PrFilesList.tsx +53 -0
- package/src/modules/pr/components/PrHeader.tsx +45 -0
- package/src/modules/pr/components/PrHeaderOverflowMenu.tsx +58 -0
- package/src/modules/pr/components/PrMergeButton.tsx +268 -0
- package/src/modules/pr/components/PrMergeConfirmDialog.tsx +112 -0
- package/src/modules/pr/components/PrRefreshFromTargetButton.tsx +110 -0
- package/src/modules/pr/components/PrViewer.tsx +364 -0
- package/src/modules/pr/hooks/usePrViewerState.ts +150 -0
- package/src/modules/pr/services/pr-approvals.api.ts +31 -0
- package/src/modules/pr/services/pr-cancel.api.ts +19 -0
- package/src/modules/pr/services/pr-comments.api.ts +45 -0
- package/src/modules/pr/services/pr-detail.api.ts +17 -0
- package/src/modules/pr/services/pr-merge.api.ts +53 -0
- package/src/modules/pr/services/pr-open.api.ts +30 -0
- package/src/modules/pr/state/pr-viewer.context.ts +34 -0
- package/src/modules/pr/utils/bucketize-comments.ts +55 -0
- package/src/modules/pr/utils/parsePatch.ts +57 -0
- package/src/modules/review/__tests__/review.api.test.ts +121 -0
- package/src/modules/review/components/BinaryChangePlaceholder.tsx +15 -0
- package/src/modules/review/components/DiffViewer.tsx +78 -0
- package/src/modules/review/components/MarkdownDiffViewer.tsx +263 -0
- package/src/modules/review/components/ReviewFileRow.tsx +114 -0
- package/src/modules/review/components/ReviewPanel.tsx +260 -0
- package/src/modules/review/components/ReviewPanelSurface.tsx +52 -0
- package/src/modules/review/components/__tests__/ReviewPanel.test.tsx +106 -0
- package/src/modules/review/hooks/__tests__/useReviewState.test.ts +88 -0
- package/src/modules/review/hooks/useReviewState.ts +256 -0
- package/src/modules/review/services/review.api.ts +72 -0
- package/src/modules/review/state/ReviewProvider.tsx +28 -0
- package/src/modules/review/state/review.context.ts +29 -0
- package/src/modules/secrets-vault/components/ConnectToolsPage.tsx +488 -0
- package/src/modules/secrets-vault/components/SecretsPage.tsx +276 -0
- package/src/modules/secrets-vault/components/ToolSecretsPanel.tsx +362 -0
- package/src/modules/secrets-vault/components/__tests__/SecretsPage.test.tsx +51 -0
- package/src/modules/secrets-vault/services/connect.api.ts +113 -0
- package/src/modules/secrets-vault/services/secrets.api.ts +82 -0
- package/src/modules/secrets-vault/services/tool-secrets.api.ts +116 -0
- package/src/modules/toolbar/components/AdminMenu.tsx +250 -0
- package/src/modules/toolbar/components/AppSwitcher.tsx +108 -0
- package/src/modules/toolbar/components/ExternalAgentAccessPage.tsx +548 -0
- package/src/modules/toolbar/components/Toolbar.tsx +123 -0
- package/src/modules/toolbar/components/__tests__/AppSwitcher.test.tsx +122 -0
- package/src/modules/toolbar/components/__tests__/Toolbar.test.tsx +353 -0
- package/src/modules/toolbar/services/external-api-keys.api.ts +65 -0
- package/src/modules/tools/ToolsExplorerPage.tsx +380 -0
- package/src/modules/workflow/hooks/useEventBusSubscription.ts +24 -0
- package/src/modules/workflow/hooks/useFileLock.ts +430 -0
- package/src/modules/workflow/services/lock.api.ts +139 -0
- package/src/modules/workflow/state/EventBusFocusBinder.tsx +25 -0
- package/src/modules/workflow/state/EventBusProvider.tsx +232 -0
- package/src/modules/workflow/state/event-bus.context.ts +75 -0
- package/src/modules/workspace/__tests__/testFixtures.ts +54 -0
- package/src/modules/workspace/__tests__/useWorkspaceState.test.ts +91 -0
- package/src/modules/workspace/components/EditorTabs.tsx +384 -0
- package/src/modules/workspace/components/FileExplorer.tsx +1068 -0
- package/src/modules/workspace/components/FileRoute.tsx +392 -0
- package/src/modules/workspace/components/FileViewer.tsx +906 -0
- package/src/modules/workspace/components/__tests__/EditorTabs.test.tsx +241 -0
- package/src/modules/workspace/components/__tests__/FileExplorer.test.tsx +666 -0
- package/src/modules/workspace/components/__tests__/FileRoute.test.tsx +330 -0
- package/src/modules/workspace/components/__tests__/FileViewer.test.tsx +492 -0
- package/src/modules/workspace/components/renderers/CsvRenderer.tsx +174 -0
- package/src/modules/workspace/components/renderers/DocxRenderer.tsx +87 -0
- package/src/modules/workspace/components/renderers/HtmlRenderer.tsx +231 -0
- package/src/modules/workspace/components/renderers/ImageRenderer.tsx +50 -0
- package/src/modules/workspace/components/renderers/KbMarkdownView.tsx +287 -0
- package/src/modules/workspace/components/renderers/MarkdownRenderer.tsx +252 -0
- package/src/modules/workspace/components/renderers/MermaidDiagram.tsx +268 -0
- package/src/modules/workspace/components/renderers/PdfRenderer.tsx +81 -0
- package/src/modules/workspace/components/renderers/TextRenderer.tsx +86 -0
- package/src/modules/workspace/components/renderers/ToolForm.tsx +404 -0
- package/src/modules/workspace/components/renderers/ToolRenderer.tsx +417 -0
- package/src/modules/workspace/components/renderers/XlsxRenderer.tsx +157 -0
- package/src/modules/workspace/components/renderers/__tests__/CsvRenderer.test.ts +57 -0
- package/src/modules/workspace/components/renderers/__tests__/KbMarkdownView.test.tsx +95 -0
- package/src/modules/workspace/components/renderers/__tests__/MarkdownRenderer.test.tsx +328 -0
- package/src/modules/workspace/components/renderers/__tests__/PdfRenderer.test.tsx +167 -0
- package/src/modules/workspace/components/renderers/__tests__/htmlSandbox.test.ts +318 -0
- package/src/modules/workspace/components/renderers/csvUtils.ts +76 -0
- package/src/modules/workspace/components/renderers/htmlSandbox.ts +332 -0
- package/src/modules/workspace/components/renderers/index.ts +39 -0
- package/src/modules/workspace/components/renderers/types.ts +27 -0
- package/src/modules/workspace/hooks/__tests__/useWorkspaceState.test.tsx +298 -0
- package/src/modules/workspace/hooks/useWorkspaceState.ts +1315 -0
- package/src/modules/workspace/routing/__tests__/kb-routes.test.tsx +99 -0
- package/src/modules/workspace/routing/kb-routes.ts +266 -0
- package/src/modules/workspace/services/__tests__/workspace.api.test.ts +72 -0
- package/src/modules/workspace/services/workspace.api.ts +185 -0
- package/src/modules/workspace/state/workspace.context.ts +235 -0
- package/src/modules/workspace/utils/__tests__/frontmatter.test.ts +107 -0
- package/src/modules/workspace/utils/diff.ts +53 -0
- package/src/modules/workspace/utils/fileTree.ts +179 -0
- package/src/modules/workspace/utils/frontmatter.ts +80 -0
- package/src/modules/workspace/utils/readDroppedEntries.ts +119 -0
- package/src/modules/workspace/utils/tab-persistence.ts +23 -0
- package/src/shared/components/Dialog.tsx +198 -0
- package/src/shared/components/PageShell.tsx +51 -0
- package/src/shared/components/useModalLayer.ts +35 -0
- package/src/shared/markdown/Markdown.tsx +62 -0
- package/src/test-setup.ts +59 -0
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
import { useRef, type PointerEvent } from 'react';
|
|
2
|
+
import { GearIcon } from './GearIcon';
|
|
3
|
+
import { StatusGem } from './StatusGem';
|
|
4
|
+
import type { AttentionStatus } from '../utils/status';
|
|
5
|
+
|
|
6
|
+
export interface LibraryCardProps {
|
|
7
|
+
kind: 'skill' | 'integration';
|
|
8
|
+
id: string;
|
|
9
|
+
name: string;
|
|
10
|
+
description: string;
|
|
11
|
+
owned: boolean;
|
|
12
|
+
/** Rendered in the footer ONLY when it needs attention (mock rule). */
|
|
13
|
+
status: AttentionStatus;
|
|
14
|
+
picked: boolean;
|
|
15
|
+
/** Card-body click: toggle loadout membership (rect feeds the particle flight). */
|
|
16
|
+
onToggle(fromRect: DOMRect): void;
|
|
17
|
+
/** Top-right info button: open the detail dialog. */
|
|
18
|
+
onInfo(): void;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* One gallery card. Deliberately icon/emoji-free (approved design). Skills get
|
|
23
|
+
* the green top accent strip; integrations the gear chrome (4 corner gears +
|
|
24
|
+
* 1 center, slow-spinning on hover). 3D tilt + glare follow the pointer.
|
|
25
|
+
*/
|
|
26
|
+
export function LibraryCard({
|
|
27
|
+
kind,
|
|
28
|
+
id,
|
|
29
|
+
name,
|
|
30
|
+
description,
|
|
31
|
+
owned,
|
|
32
|
+
status,
|
|
33
|
+
picked,
|
|
34
|
+
onToggle,
|
|
35
|
+
onInfo,
|
|
36
|
+
}: LibraryCardProps) {
|
|
37
|
+
const ref = useRef<HTMLDivElement>(null);
|
|
38
|
+
|
|
39
|
+
function onPointerMove(e: PointerEvent<HTMLDivElement>) {
|
|
40
|
+
const el = ref.current;
|
|
41
|
+
if (!el) return;
|
|
42
|
+
const r = el.getBoundingClientRect();
|
|
43
|
+
const px = (e.clientX - r.left) / r.width;
|
|
44
|
+
const py = (e.clientY - r.top) / r.height;
|
|
45
|
+
el.style.transform = `translateY(-12px) scale(1.045) rotateX(${(0.5 - py) * 10}deg) rotateY(${(px - 0.5) * 10}deg)`;
|
|
46
|
+
el.style.setProperty('--lib-mx', `${px * 100}%`);
|
|
47
|
+
el.style.setProperty('--lib-my', `${py * 100}%`);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
function onPointerLeave() {
|
|
51
|
+
if (ref.current) ref.current.style.transform = '';
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
const needsAttention = kind === 'integration' && status.state !== 'ok';
|
|
55
|
+
|
|
56
|
+
return (
|
|
57
|
+
<div
|
|
58
|
+
ref={ref}
|
|
59
|
+
data-testid={`library-card-${kind}-${id}`}
|
|
60
|
+
role="button"
|
|
61
|
+
tabIndex={0}
|
|
62
|
+
aria-pressed={picked}
|
|
63
|
+
aria-label={`${name} — ${picked ? 'remove from loadout' : 'add to loadout'}`}
|
|
64
|
+
className={`lib-card ${kind === 'skill' ? 'lib-card-skill' : 'lib-card-tool'} ${picked ? 'lib-card-picked' : ''} flex min-h-[180px] flex-col gap-2.5 p-4`}
|
|
65
|
+
onPointerMove={onPointerMove}
|
|
66
|
+
onPointerLeave={onPointerLeave}
|
|
67
|
+
onClick={() => {
|
|
68
|
+
const el = ref.current;
|
|
69
|
+
if (el) onToggle(el.getBoundingClientRect());
|
|
70
|
+
}}
|
|
71
|
+
onKeyDown={(e) => {
|
|
72
|
+
if (e.key === 'Enter' || e.key === ' ') {
|
|
73
|
+
e.preventDefault();
|
|
74
|
+
const el = ref.current;
|
|
75
|
+
if (el) onToggle(el.getBoundingClientRect());
|
|
76
|
+
}
|
|
77
|
+
}}
|
|
78
|
+
>
|
|
79
|
+
{kind === 'integration' && (
|
|
80
|
+
<div className="lib-gears">
|
|
81
|
+
<GearIcon />
|
|
82
|
+
<GearIcon />
|
|
83
|
+
<GearIcon />
|
|
84
|
+
<GearIcon />
|
|
85
|
+
<GearIcon />
|
|
86
|
+
</div>
|
|
87
|
+
)}
|
|
88
|
+
<div className="lib-card-glare" />
|
|
89
|
+
<button
|
|
90
|
+
type="button"
|
|
91
|
+
aria-label={`Details for ${name}`}
|
|
92
|
+
title="Details"
|
|
93
|
+
className={`absolute right-2.5 top-2.5 z-[3] flex h-6 w-6 items-center justify-center rounded-full border bg-white/85 font-serif text-xs font-bold italic transition-all hover:scale-110 hover:border-[#0d9488] hover:bg-white hover:text-[#0f766e] ${picked ? 'border-[#9dd8cd] text-slate-500' : 'border-slate-200 text-slate-400'}`}
|
|
94
|
+
onClick={(e) => {
|
|
95
|
+
e.stopPropagation();
|
|
96
|
+
onInfo();
|
|
97
|
+
}}
|
|
98
|
+
>
|
|
99
|
+
i
|
|
100
|
+
</button>
|
|
101
|
+
<div className="pr-6">
|
|
102
|
+
<div className="text-[14.5px] font-bold tracking-[.01em] text-slate-800">{name}</div>
|
|
103
|
+
<div className="mt-0.5 flex items-center gap-1.5 text-[10.5px] uppercase tracking-[.08em] text-slate-400">
|
|
104
|
+
{kind === 'skill' ? 'Skill' : 'Integration'}
|
|
105
|
+
{owned && (
|
|
106
|
+
<span className="rounded-full border border-[#f0dda6] bg-[#fdf3d8] px-1.5 text-[9.5px] font-bold tracking-[.05em] text-[#92600a]">
|
|
107
|
+
OWNER
|
|
108
|
+
</span>
|
|
109
|
+
)}
|
|
110
|
+
</div>
|
|
111
|
+
</div>
|
|
112
|
+
<div className="relative flex-1 text-xs text-slate-500">{description}</div>
|
|
113
|
+
{needsAttention && (
|
|
114
|
+
<div
|
|
115
|
+
className={`flex items-center border-t pt-2.5 ${picked ? 'border-[#bde4dc]' : 'border-slate-200'}`}
|
|
116
|
+
>
|
|
117
|
+
<span className="flex items-center gap-1.5 text-[11px] font-semibold text-slate-500">
|
|
118
|
+
<StatusGem state={status.state} />
|
|
119
|
+
{status.text}
|
|
120
|
+
</span>
|
|
121
|
+
</div>
|
|
122
|
+
)}
|
|
123
|
+
<div className="lib-hover-cta">
|
|
124
|
+
{picked ? (
|
|
125
|
+
<span className="lib-hc-remove">− Remove</span>
|
|
126
|
+
) : (
|
|
127
|
+
<span className="lib-hc-add">+ Add to loadout</span>
|
|
128
|
+
)}
|
|
129
|
+
</div>
|
|
130
|
+
</div>
|
|
131
|
+
);
|
|
132
|
+
}
|
|
@@ -0,0 +1,254 @@
|
|
|
1
|
+
import { useMemo, useState } from 'react';
|
|
2
|
+
import { useNavigate } from 'react-router-dom';
|
|
3
|
+
import '../library.css';
|
|
4
|
+
import { LoadoutProvider, useLoadout, type LoadoutKind } from '../state/loadout';
|
|
5
|
+
import { LibraryToastProvider, useLibraryToast } from '../state/toast';
|
|
6
|
+
import { useLibraryData } from '../hooks/useLibraryData';
|
|
7
|
+
import {
|
|
8
|
+
filterLibraryItems,
|
|
9
|
+
neededToolsFor,
|
|
10
|
+
skillStatus,
|
|
11
|
+
toolStatus,
|
|
12
|
+
type AttentionStatus,
|
|
13
|
+
type LibraryCategory,
|
|
14
|
+
} from '../utils/status';
|
|
15
|
+
import { LibraryCard } from './LibraryCard';
|
|
16
|
+
import { LoadoutSidebar, type LoadoutRow } from './LoadoutSidebar';
|
|
17
|
+
import { DetailDialog, type DetailTarget } from './DetailDialog';
|
|
18
|
+
import { flyParticles } from './particles';
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* The Library — the core skills / integrations / loadout view (the Skills &
|
|
22
|
+
* Tools app surface at `/skills-and-tools`, registered in the core shell).
|
|
23
|
+
* Game-style visual direction from
|
|
24
|
+
* the approved mock `mocks/mock-a2-game-library.html`: teal accent, status
|
|
25
|
+
* gems, tilting cards, loadout sidebar with particle flight. All data is real
|
|
26
|
+
* (skills catalog, secrets-vault connection status, workflow change
|
|
27
|
+
* requests); only the loadout itself is a documented client-side stub.
|
|
28
|
+
*/
|
|
29
|
+
export function LibraryPage() {
|
|
30
|
+
return (
|
|
31
|
+
<LoadoutProvider>
|
|
32
|
+
<LibraryToastProvider>
|
|
33
|
+
<LibraryPageInner />
|
|
34
|
+
</LibraryToastProvider>
|
|
35
|
+
</LoadoutProvider>
|
|
36
|
+
);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
interface GalleryItem {
|
|
40
|
+
kind: 'skill' | 'integration';
|
|
41
|
+
id: string;
|
|
42
|
+
name: string;
|
|
43
|
+
description: string;
|
|
44
|
+
owned: boolean;
|
|
45
|
+
status: AttentionStatus;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
function LibraryPageInner() {
|
|
49
|
+
const data = useLibraryData();
|
|
50
|
+
const loadout = useLoadout();
|
|
51
|
+
const toast = useLibraryToast();
|
|
52
|
+
const navigate = useNavigate();
|
|
53
|
+
const [category, setCategory] = useState<LibraryCategory>('skills');
|
|
54
|
+
const [query, setQuery] = useState('');
|
|
55
|
+
const [detail, setDetail] = useState<DetailTarget | null>(null);
|
|
56
|
+
|
|
57
|
+
const items: GalleryItem[] = useMemo(() => {
|
|
58
|
+
const skillItems: GalleryItem[] = data.skills.map((s) => ({
|
|
59
|
+
kind: 'skill',
|
|
60
|
+
id: s.name,
|
|
61
|
+
name: s.name,
|
|
62
|
+
description: s.description,
|
|
63
|
+
owned: data.ownedSkills.has(s.name),
|
|
64
|
+
status: skillStatus(
|
|
65
|
+
neededToolsFor({ allowedTools: data.allowedToolsBySkill.get(s.name) }, data.tools),
|
|
66
|
+
),
|
|
67
|
+
}));
|
|
68
|
+
const toolItems: GalleryItem[] = data.tools.map((t) => ({
|
|
69
|
+
kind: 'integration',
|
|
70
|
+
id: t.slug,
|
|
71
|
+
name: t.name,
|
|
72
|
+
// The browser tool surface exposes no human description for a `.tool`
|
|
73
|
+
// manual yet (see report) — the card stays clean, detail lives in ⓘ.
|
|
74
|
+
description: '',
|
|
75
|
+
owned: t.canWrite,
|
|
76
|
+
status: toolStatus(t),
|
|
77
|
+
}));
|
|
78
|
+
return [...skillItems, ...toolItems];
|
|
79
|
+
}, [data.skills, data.tools, data.ownedSkills, data.allowedToolsBySkill]);
|
|
80
|
+
|
|
81
|
+
const visible = useMemo(
|
|
82
|
+
() => filterLibraryItems(items, category, query),
|
|
83
|
+
[items, category, query],
|
|
84
|
+
);
|
|
85
|
+
|
|
86
|
+
const counts = useMemo(
|
|
87
|
+
() => ({
|
|
88
|
+
skills: items.filter((i) => i.kind === 'skill').length,
|
|
89
|
+
integrations: items.filter((i) => i.kind === 'integration').length,
|
|
90
|
+
owned: items.filter((i) => i.owned).length,
|
|
91
|
+
}),
|
|
92
|
+
[items],
|
|
93
|
+
);
|
|
94
|
+
|
|
95
|
+
const rows: LoadoutRow[] = useMemo(() => {
|
|
96
|
+
const byKey = new Map(items.map((i) => [`${i.kind}:${i.id}`, i]));
|
|
97
|
+
const pick = (kind: LoadoutKind, ids: string[]) =>
|
|
98
|
+
ids
|
|
99
|
+
.map((id) => byKey.get(`${kind}:${id}`))
|
|
100
|
+
.filter((i): i is GalleryItem => i !== undefined)
|
|
101
|
+
.map((i) => ({ kind, id: i.id, name: i.name, status: i.status }));
|
|
102
|
+
return [...pick('skill', loadout.skills), ...pick('integration', loadout.integrations)];
|
|
103
|
+
}, [items, loadout.skills, loadout.integrations]);
|
|
104
|
+
|
|
105
|
+
const attentionCount = rows.filter((r) => r.status.state !== 'ok').length;
|
|
106
|
+
|
|
107
|
+
function toggleItem(item: GalleryItem, fromRect?: DOMRect) {
|
|
108
|
+
const added = loadout.toggle(item.kind, item.id);
|
|
109
|
+
if (added) {
|
|
110
|
+
toast(
|
|
111
|
+
item.status.state === 'ok'
|
|
112
|
+
? `${item.name} added — ready to go`
|
|
113
|
+
: `${item.name} added — needs a quick sign-in`,
|
|
114
|
+
);
|
|
115
|
+
if (fromRect) flyParticles(fromRect, item.kind, item.id);
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
function openDetail(item: GalleryItem) {
|
|
120
|
+
if (item.kind === 'skill') {
|
|
121
|
+
const skill = data.skills.find((s) => s.name === item.id);
|
|
122
|
+
if (skill) setDetail({ kind: 'skill', skill, owned: item.owned });
|
|
123
|
+
} else {
|
|
124
|
+
const tool = data.tools.find((t) => t.slug === item.id);
|
|
125
|
+
if (tool) setDetail({ kind: 'integration', tool });
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
const chip = (cat: LibraryCategory, label: string, count: number) => (
|
|
130
|
+
<button
|
|
131
|
+
key={cat}
|
|
132
|
+
type="button"
|
|
133
|
+
aria-pressed={category === cat}
|
|
134
|
+
className={`flex items-center gap-1.5 rounded-full border px-4 py-1.5 text-[12.5px] font-semibold transition-all ${
|
|
135
|
+
category === cat
|
|
136
|
+
? 'border-[#7fd0c4] bg-gradient-to-br from-[#e6f7f4] to-[#d5f1ec] text-[#0f766e] shadow-[0_2px_10px_rgba(13,148,136,0.22)]'
|
|
137
|
+
: 'border-slate-200 bg-white text-slate-500 hover:border-[#7fd0c4] hover:text-slate-800'
|
|
138
|
+
}`}
|
|
139
|
+
onClick={() => setCategory(cat)}
|
|
140
|
+
>
|
|
141
|
+
{label}
|
|
142
|
+
<span
|
|
143
|
+
className={`rounded-full px-1.5 text-[10.5px] font-bold ${
|
|
144
|
+
category === cat ? 'bg-[#0d948826]' : 'bg-slate-900/5'
|
|
145
|
+
}`}
|
|
146
|
+
>
|
|
147
|
+
{count}
|
|
148
|
+
</span>
|
|
149
|
+
</button>
|
|
150
|
+
);
|
|
151
|
+
|
|
152
|
+
return (
|
|
153
|
+
<div className="flex h-full min-h-0 bg-[#eef1f6] text-slate-800">
|
|
154
|
+
<LoadoutSidebar
|
|
155
|
+
rows={rows}
|
|
156
|
+
onOpen={(row) => {
|
|
157
|
+
const item = items.find((i) => i.kind === row.kind && i.id === row.id);
|
|
158
|
+
if (item) openDetail(item);
|
|
159
|
+
}}
|
|
160
|
+
onRemove={(row) => loadout.remove(row.kind, row.id)}
|
|
161
|
+
attentionCount={attentionCount}
|
|
162
|
+
onFinishSetup={() => navigate('/connect')}
|
|
163
|
+
/>
|
|
164
|
+
|
|
165
|
+
<main
|
|
166
|
+
className="min-w-0 flex-1 overflow-y-auto px-8 py-6"
|
|
167
|
+
style={{
|
|
168
|
+
background:
|
|
169
|
+
'radial-gradient(900px 500px at 85% -10%, rgba(13,148,136,.08), transparent 60%), radial-gradient(700px 500px at -10% 110%, rgba(59,130,246,.06), transparent 55%)',
|
|
170
|
+
}}
|
|
171
|
+
>
|
|
172
|
+
<div className="mb-1 flex items-center gap-4">
|
|
173
|
+
<div>
|
|
174
|
+
<h1 className="text-[26px] font-bold tracking-tight">Library</h1>
|
|
175
|
+
<div className="text-[13px] text-slate-500">
|
|
176
|
+
Click a card to add it to your loadout · open a card's details for more.
|
|
177
|
+
</div>
|
|
178
|
+
</div>
|
|
179
|
+
<div className="ml-auto flex w-64 items-center gap-2 rounded-[11px] border border-slate-200 bg-white px-3.5 py-2 shadow-[0_1px_4px_rgba(22,35,58,0.05)]">
|
|
180
|
+
<input
|
|
181
|
+
className="w-full bg-transparent text-[13px] outline-none placeholder:text-slate-400"
|
|
182
|
+
placeholder="Search the library…"
|
|
183
|
+
aria-label="Search the library"
|
|
184
|
+
value={query}
|
|
185
|
+
onChange={(e) => setQuery(e.target.value)}
|
|
186
|
+
/>
|
|
187
|
+
</div>
|
|
188
|
+
</div>
|
|
189
|
+
|
|
190
|
+
<div className="mb-5 mt-4 flex gap-2">
|
|
191
|
+
{chip('skills', 'Skills', counts.skills)}
|
|
192
|
+
{chip('integrations', 'Integrations', counts.integrations)}
|
|
193
|
+
{chip('owned', 'Owned by me', counts.owned)}
|
|
194
|
+
</div>
|
|
195
|
+
|
|
196
|
+
{data.error ? (
|
|
197
|
+
<div className="rounded-xl border border-[#f3c4c4] bg-[#fdecec] px-4 py-3 text-sm text-[#c53030]">
|
|
198
|
+
{data.error}
|
|
199
|
+
<button type="button" className="ml-3 font-bold underline" onClick={data.reload}>
|
|
200
|
+
Try again
|
|
201
|
+
</button>
|
|
202
|
+
</div>
|
|
203
|
+
) : data.loading ? (
|
|
204
|
+
<div className="py-16 text-center text-sm text-slate-400">Loading the library…</div>
|
|
205
|
+
) : visible.length === 0 ? (
|
|
206
|
+
<div className="py-16 text-center text-sm text-slate-400">Nothing here matches yet.</div>
|
|
207
|
+
) : (
|
|
208
|
+
<div className="lib-grid grid grid-cols-[repeat(auto-fill,minmax(228px,1fr))] gap-5 pb-14">
|
|
209
|
+
{visible.map((item) => (
|
|
210
|
+
<LibraryCard
|
|
211
|
+
key={`${item.kind}:${item.id}`}
|
|
212
|
+
kind={item.kind}
|
|
213
|
+
id={item.id}
|
|
214
|
+
name={item.name}
|
|
215
|
+
description={item.description}
|
|
216
|
+
owned={item.owned}
|
|
217
|
+
status={item.status}
|
|
218
|
+
picked={loadout.isIn(item.kind, item.id)}
|
|
219
|
+
onToggle={(rect) => toggleItem(item, rect)}
|
|
220
|
+
onInfo={() => openDetail(item)}
|
|
221
|
+
/>
|
|
222
|
+
))}
|
|
223
|
+
</div>
|
|
224
|
+
)}
|
|
225
|
+
</main>
|
|
226
|
+
|
|
227
|
+
{detail && (
|
|
228
|
+
<DetailDialog
|
|
229
|
+
target={detail}
|
|
230
|
+
tools={data.tools}
|
|
231
|
+
skills={data.skills}
|
|
232
|
+
allowedToolsBySkill={data.allowedToolsBySkill}
|
|
233
|
+
crs={data.crs}
|
|
234
|
+
myCrNumbers={data.myCrNumbers}
|
|
235
|
+
inLoadout={
|
|
236
|
+
detail.kind === 'skill'
|
|
237
|
+
? loadout.isIn('skill', detail.skill.name)
|
|
238
|
+
: loadout.isIn('integration', detail.tool.slug)
|
|
239
|
+
}
|
|
240
|
+
onToggleLoadout={() => {
|
|
241
|
+
const item = items.find(
|
|
242
|
+
(i) =>
|
|
243
|
+
i.kind === (detail.kind === 'skill' ? 'skill' : 'integration') &&
|
|
244
|
+
i.id === (detail.kind === 'skill' ? detail.skill.name : detail.tool.slug),
|
|
245
|
+
);
|
|
246
|
+
if (item) toggleItem(item);
|
|
247
|
+
}}
|
|
248
|
+
onClose={() => setDetail(null)}
|
|
249
|
+
onDataChanged={data.reload}
|
|
250
|
+
/>
|
|
251
|
+
)}
|
|
252
|
+
</div>
|
|
253
|
+
);
|
|
254
|
+
}
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
import { useEffect, useRef, useState } from 'react';
|
|
2
|
+
import { StatusGem } from './StatusGem';
|
|
3
|
+
import type { LoadoutKind } from '../state/loadout';
|
|
4
|
+
import type { AttentionStatus } from '../utils/status';
|
|
5
|
+
|
|
6
|
+
export interface LoadoutRow {
|
|
7
|
+
kind: LoadoutKind;
|
|
8
|
+
id: string;
|
|
9
|
+
name: string;
|
|
10
|
+
status: AttentionStatus;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
interface LoadoutSidebarProps {
|
|
14
|
+
rows: LoadoutRow[];
|
|
15
|
+
onOpen(row: LoadoutRow): void;
|
|
16
|
+
onRemove(row: LoadoutRow): void;
|
|
17
|
+
/** How many loadout items still need attention; drives the CTA. */
|
|
18
|
+
attentionCount: number;
|
|
19
|
+
onFinishSetup(): void;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* The loadout sidebar (deck-tracker style). Collapses to a slim vertical rail
|
|
24
|
+
* when empty; rows animate in, hover swaps the status gem for a remove button,
|
|
25
|
+
* and SKILLS / INTEGRATIONS group labels appear only when both kinds are
|
|
26
|
+
* present. The count pulses on every change.
|
|
27
|
+
*/
|
|
28
|
+
export function LoadoutSidebar({
|
|
29
|
+
rows,
|
|
30
|
+
onOpen,
|
|
31
|
+
onRemove,
|
|
32
|
+
attentionCount,
|
|
33
|
+
onFinishSetup,
|
|
34
|
+
}: LoadoutSidebarProps) {
|
|
35
|
+
const total = rows.length;
|
|
36
|
+
const skills = rows.filter((r) => r.kind === 'skill');
|
|
37
|
+
const integrations = rows.filter((r) => r.kind === 'integration');
|
|
38
|
+
const both = skills.length > 0 && integrations.length > 0;
|
|
39
|
+
|
|
40
|
+
// Pulse the count on change (mock's `.pulse` re-trigger).
|
|
41
|
+
const [pulse, setPulse] = useState(false);
|
|
42
|
+
const prevTotal = useRef(total);
|
|
43
|
+
useEffect(() => {
|
|
44
|
+
if (prevTotal.current !== total) {
|
|
45
|
+
prevTotal.current = total;
|
|
46
|
+
setPulse(true);
|
|
47
|
+
const t = setTimeout(() => setPulse(false), 220);
|
|
48
|
+
return () => clearTimeout(t);
|
|
49
|
+
}
|
|
50
|
+
}, [total]);
|
|
51
|
+
|
|
52
|
+
if (total === 0) {
|
|
53
|
+
return (
|
|
54
|
+
<aside
|
|
55
|
+
aria-label="Your loadout (empty)"
|
|
56
|
+
className="flex h-full w-14 shrink-0 flex-col items-center gap-3 border-r border-slate-200 bg-gradient-to-b from-white to-[#fafbfd] py-4 shadow-[6px_0_30px_rgba(22,35,58,0.06)] transition-[width] duration-300"
|
|
57
|
+
>
|
|
58
|
+
<div className="flex h-[26px] w-[26px] items-center justify-center rounded-full bg-[#f0f3f7] text-xs font-bold text-slate-400 shadow-[inset_0_0_0_1px_#e2e8f0]">
|
|
59
|
+
0
|
|
60
|
+
</div>
|
|
61
|
+
<div className="text-[10.5px] font-bold uppercase tracking-[.2em] text-slate-400 [writing-mode:vertical-rl]">
|
|
62
|
+
Loadout
|
|
63
|
+
</div>
|
|
64
|
+
</aside>
|
|
65
|
+
);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
const renderRow = (row: LoadoutRow) => (
|
|
69
|
+
<div
|
|
70
|
+
key={`${row.kind}:${row.id}`}
|
|
71
|
+
data-loadout-key={`${row.kind}:${row.id}`}
|
|
72
|
+
role="button"
|
|
73
|
+
tabIndex={0}
|
|
74
|
+
className="lib-slot relative mb-2 flex h-[46px] cursor-pointer items-center gap-2.5 overflow-hidden rounded-[11px] border border-[#d2e9e4] bg-gradient-to-r from-[#e6f7f4] via-[#e6f7f459] to-transparent px-2.5 transition-colors hover:border-[#7fd0c4]"
|
|
75
|
+
onClick={() => onOpen(row)}
|
|
76
|
+
onKeyDown={(e) => {
|
|
77
|
+
if (e.key === 'Enter') onOpen(row);
|
|
78
|
+
}}
|
|
79
|
+
>
|
|
80
|
+
<div className="min-w-0">
|
|
81
|
+
<div className="truncate text-[12.5px] font-semibold text-slate-800">{row.name}</div>
|
|
82
|
+
<div className="text-[10.5px] text-slate-400">{row.status.text}</div>
|
|
83
|
+
</div>
|
|
84
|
+
<span className="lib-slot-gem ml-auto shrink-0">
|
|
85
|
+
<StatusGem state={row.status.state} />
|
|
86
|
+
</span>
|
|
87
|
+
<button
|
|
88
|
+
type="button"
|
|
89
|
+
aria-label={`Remove ${row.name} from loadout`}
|
|
90
|
+
title="Remove from loadout"
|
|
91
|
+
className="lib-slot-kick absolute right-2 top-1/2 flex h-6 w-6 -translate-y-1/2 items-center justify-center rounded-full border border-slate-200 bg-white text-xs font-bold text-slate-400 hover:scale-110 hover:border-[#f3c4c4] hover:bg-[#fdecec] hover:text-[#c53030]"
|
|
92
|
+
onClick={(e) => {
|
|
93
|
+
e.stopPropagation();
|
|
94
|
+
onRemove(row);
|
|
95
|
+
}}
|
|
96
|
+
>
|
|
97
|
+
✕
|
|
98
|
+
</button>
|
|
99
|
+
</div>
|
|
100
|
+
);
|
|
101
|
+
|
|
102
|
+
return (
|
|
103
|
+
<aside
|
|
104
|
+
aria-label="Your loadout"
|
|
105
|
+
className="flex h-full w-72 shrink-0 flex-col border-r border-slate-200 bg-gradient-to-b from-white to-[#fafbfd] p-4 shadow-[6px_0_30px_rgba(22,35,58,0.06)] transition-[width] duration-300"
|
|
106
|
+
>
|
|
107
|
+
<div className="mb-3 flex items-baseline justify-between">
|
|
108
|
+
<h2 className="whitespace-nowrap text-[15px] font-bold uppercase tracking-[.06em] text-[#0f766e]">
|
|
109
|
+
Your loadout
|
|
110
|
+
</h2>
|
|
111
|
+
<div className={`text-[13px] font-bold text-slate-500 ${pulse ? 'lib-count-pulse' : ''}`}>
|
|
112
|
+
{total}
|
|
113
|
+
</div>
|
|
114
|
+
</div>
|
|
115
|
+
|
|
116
|
+
<div className="-mx-1.5 flex-1 overflow-y-auto px-1.5 pb-1">
|
|
117
|
+
{both && (
|
|
118
|
+
<div className="mx-1 mb-2 mt-1 text-[10px] font-bold uppercase tracking-[.14em] text-slate-400">
|
|
119
|
+
Skills
|
|
120
|
+
</div>
|
|
121
|
+
)}
|
|
122
|
+
{skills.map(renderRow)}
|
|
123
|
+
{both && (
|
|
124
|
+
<div className="mx-1 mb-2 mt-3 text-[10px] font-bold uppercase tracking-[.14em] text-slate-400">
|
|
125
|
+
Integrations
|
|
126
|
+
</div>
|
|
127
|
+
)}
|
|
128
|
+
{integrations.map(renderRow)}
|
|
129
|
+
<div className="flex h-[46px] items-center justify-center rounded-[11px] border-[1.5px] border-dashed border-[#cbd7e4] text-[11.5px] tracking-[.05em] text-slate-400">
|
|
130
|
+
◇ pick more from the library
|
|
131
|
+
</div>
|
|
132
|
+
</div>
|
|
133
|
+
|
|
134
|
+
<div className="mt-3">
|
|
135
|
+
{attentionCount > 0 ? (
|
|
136
|
+
<>
|
|
137
|
+
<button
|
|
138
|
+
type="button"
|
|
139
|
+
className="w-full rounded-xl bg-gradient-to-br from-[#0d9488] to-[#0f766e] p-3 text-sm font-bold tracking-[.03em] text-white shadow-[0_6px_20px_rgba(13,148,136,0.22),inset_0_1px_0_rgba(255,255,255,0.35)] transition-transform hover:-translate-y-0.5 active:translate-y-0 active:scale-[.98]"
|
|
140
|
+
onClick={onFinishSetup}
|
|
141
|
+
>
|
|
142
|
+
Finish setup ({attentionCount})
|
|
143
|
+
</button>
|
|
144
|
+
<div className="mt-2 flex items-center justify-center gap-1.5 text-[11.5px] text-[#b45309]">
|
|
145
|
+
Some items need a quick sign-in first
|
|
146
|
+
</div>
|
|
147
|
+
</>
|
|
148
|
+
) : (
|
|
149
|
+
<div className="rounded-xl border border-[#d2e9e4] bg-[#e6f7f4] p-3 text-center text-[12px] font-semibold text-[#0f766e]">
|
|
150
|
+
Everything in your loadout is ready
|
|
151
|
+
</div>
|
|
152
|
+
)}
|
|
153
|
+
</div>
|
|
154
|
+
</aside>
|
|
155
|
+
);
|
|
156
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { GemState } from '../utils/status';
|
|
2
|
+
|
|
3
|
+
const GLYPH: Record<GemState, string> = {
|
|
4
|
+
ok: '✓',
|
|
5
|
+
warn: '!',
|
|
6
|
+
err: '✕',
|
|
7
|
+
off: '·',
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Glossy status gem from the approved mock — emerald / amber / red / gray with
|
|
12
|
+
* a text glyph. Text glyphs (not an icon set) are part of the approved visual
|
|
13
|
+
* language; the state text next to it carries the accessible meaning.
|
|
14
|
+
*/
|
|
15
|
+
export function StatusGem({ state, className = '' }: { state: GemState; className?: string }) {
|
|
16
|
+
return (
|
|
17
|
+
<span className={`lib-gem lib-gem-${state} ${className}`.trim()} aria-hidden="true">
|
|
18
|
+
{GLYPH[state]}
|
|
19
|
+
</span>
|
|
20
|
+
);
|
|
21
|
+
}
|