Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 17 additions & 34 deletions packages/plugin-game-theory/src/GameTheoryExplorer.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { useState, useMemo, useCallback } from "react";
import { useGameTheoryData } from "./useGameTheoryData";
import type { GTNode } from "./useGameTheoryData";
import { useTheme } from "@trustgraph/trustkit";
import { useTheme, Button, Select } from "@trustgraph/trustkit";
import type { Theme } from "@trustgraph/trustkit";

const GT_SPINNER_ID = "gt-spinner-keyframes";
Expand Down Expand Up @@ -57,7 +57,8 @@ const NODE_SIZE = 30;
/* Helper: Section header */
/* ------------------------------------------------------------------ */

function Section({ title, color, borderColor, sz, children }: { title: string; color: string; borderColor?: string; sz: (px: number) => number; children: React.ReactNode }) {
function Section({ title, color, borderColor, children }: { title: string; color: string; borderColor?: string; children: React.ReactNode }) {
const { theme, sz } = useTheme();
return (
<div style={{ marginBottom: sz(16) }}>
<div style={{
Expand Down Expand Up @@ -1135,7 +1136,7 @@ export function GameTheoryExplorer(_props: GameTheoryExplorerProps) {
</div>
)}
{actions.length > 0 && (
<Section title="Actions" color={theme.text.subtle} sz={sz}>
<Section title="Actions" color={theme.text.subtle}>
<div style={{ display: "flex", flexWrap: "wrap", gap: 4 }}>
{actions.map(au => (
<span key={au} style={{
Expand All @@ -1150,7 +1151,7 @@ export function GameTheoryExplorer(_props: GameTheoryExplorerProps) {
</Section>
)}
{payoffUris.length > 0 && (
<Section title="Payoffs" color={theme.text.subtle} sz={sz}>
<Section title="Payoffs" color={theme.text.subtle}>
<div style={{ display: "flex", flexWrap: "wrap", gap: 6 }}>
{payoffUris.map(pu => {
const plUri = data.payoffPlayer.get(pu);
Expand Down Expand Up @@ -1250,38 +1251,28 @@ export function GameTheoryExplorer(_props: GameTheoryExplorerProps) {
alignItems: "center",
}}>
{([["tree", "\u229E Game Tree"], ["matrix", "\u229E Payoff Matrix"], ["sandbox", "\u229E Sandbox"]] as const).map(([m, label]) => (
<button
<Button
key={m}
size="sm"
active={mode === m}
onClick={() => setMode(m as ExplorerMode)}
style={{
padding: "5px 14px", borderRadius: 5, border: "none", cursor: "pointer",
background: mode === m ? theme.surface.cardHover : "transparent",
color: mode === m ? theme.text.primary : theme.text.faint,
fontFamily: theme.font.mono, fontSize: sz(11),
fontWeight: mode === m ? 600 : 400, transition: "all 0.15s",
}}
>
{label}
</button>
</Button>
))}

<div style={{ flex: 1 }} />

{games.length > 1 && (
<select
<Select
value={activeGameUri || ""}
onChange={e => setSelectedGameUri(e.target.value || null)}
style={{
background: theme.surface.cardHover, border: `1px solid ${theme.border.medium}`,
borderRadius: 4, padding: "3px 8px", color: theme.text.secondary,
fontFamily: theme.font.mono, fontSize: sz(10),
outline: "none",
}}
onChange={v => setSelectedGameUri(v || null)}
style={{ fontSize: sz(10) }}
>
{games.map(g => (
<option key={g.uri} value={g.uri}>{g.label}</option>
))}
</select>
</Select>
)}
</div>

Expand Down Expand Up @@ -1333,22 +1324,14 @@ export function GameTheoryExplorer(_props: GameTheoryExplorerProps) {
}}>
Parameter Sandbox
</div>
<button
onClick={resetOverrides}
style={{
padding: "2px 8px", borderRadius: 3, border: `1px solid ${theme.border.medium}`,
background: theme.surface.cardHover, color: theme.text.muted,
fontFamily: theme.font.mono, fontSize: sz(9),
cursor: "pointer",
}}
>
<Button size="sm" onClick={resetOverrides}>
Reset
</button>
</Button>
</div>

{/* Probability sliders */}
{chanceActions.length > 0 && (
<Section title="Probabilities" color={theme.palette.cyan} sz={sz}>
<Section title="Probabilities" color={theme.palette.cyan}>
{chanceActions.map(ca => {
const val = probOverrides.get(ca.actionUri) ?? data.probabilities.get(ca.actionUri) ?? 0;
return (
Expand Down Expand Up @@ -1380,7 +1363,7 @@ export function GameTheoryExplorer(_props: GameTheoryExplorerProps) {

{/* Payoff sliders */}
{payoffEntries.length > 0 && (
<Section title="Payoffs" color={theme.palette.amber} sz={sz}>
<Section title="Payoffs" color={theme.palette.amber}>
{payoffEntries.map(pe => {
const val = utilOverrides.get(pe.payoffUri) ?? data.utilities.get(pe.payoffUri) ?? 0;
const col = playerColorMap.get(pe.playerUri) || theme.text.muted;
Expand Down
19 changes: 5 additions & 14 deletions packages/plugin-hwsec/src/HwSecExplorer.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { useState, useMemo, useCallback } from "react";
import { useTheme, LoadingState } from "@trustgraph/trustkit";
import { useTheme, LoadingState, Input } from "@trustgraph/trustkit";
import type { Theme } from "@trustgraph/trustkit";
import { useHwSecData } from "./useHwSecData";
import type { HwNode } from "./useHwSecData";
Expand Down Expand Up @@ -77,7 +77,7 @@ function securityKindLabel(kind: string): string {
}

function Section({ title, color, children }: { title: string; color: string; children: React.ReactNode }) {
const { sz } = useTheme();
const { theme, sz } = useTheme();
return (
<div style={{ marginBottom: 18 }}>
<div style={{
Expand Down Expand Up @@ -735,20 +735,11 @@ export function HwSecExplorer(_props: HwSecExplorerProps) {
Hardware Security Explorer
</div>

<input
type="text"
<Input
placeholder="Search entities..."
value={searchTerm}
onChange={e => setSearchTerm(e.target.value)}
style={{
flex: 1, maxWidth: 300,
padding: "5px 10px", borderRadius: 6,
background: "rgba(255,255,255,0.03)",
border: `1px solid ${theme.border.default}`,
color: theme.text.primary, fontSize: sz(11),
fontFamily: theme.font.sans,
outline: "none",
}}
onChange={setSearchTerm}
style={{ flex: 1, maxWidth: 300, fontSize: sz(11) }}
/>

<div style={{
Expand Down
26 changes: 7 additions & 19 deletions packages/plugin-innovation/src/components/GtmAdvisor.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { useState, useMemo, useCallback, useRef, useEffect } from "react";
import { useTheme, StreamingResponse } from "@trustgraph/trustkit";
import { useTheme, StreamingResponse, Button, Input } from "@trustgraph/trustkit";
import type { Theme } from "@trustgraph/trustkit";
import { useInference } from "@trustgraph/react-state";
import type { IINode } from "../useInnovationData";
Expand Down Expand Up @@ -112,18 +112,13 @@ function EntityPicker({
>✕</span>
</div>
) : (
<input
<Input
value={search}
onChange={e => { setSearch(e.target.value); setOpen(true); }}
onChange={v => { setSearch(v); setOpen(true); }}
onFocus={() => setOpen(true)}
placeholder={placeholder}
autoFocus={open}
style={{
width: "100%", padding: "8px 12px", borderRadius: 6, fontSize: sz(13),
background: "rgba(255,255,255,0.04)", border: `1px solid ${theme.border.default}`,
color: theme.text.primary, outline: "none",
fontFamily: theme.font.sans,
}}
style={{ fontSize: sz(13) }}
/>
)}
{open && matches.length > 0 && (
Expand Down Expand Up @@ -846,20 +841,13 @@ export function GtmAdvisor(props: GtmAdvisorProps) {
Use AI to synthesise the above intelligence into an actionable GTM plan
</div>
</div>
<button
<Button
onClick={handleGenerate}
disabled={isStreaming}
style={{
padding: "8px 20px", borderRadius: 6, cursor: "pointer",
background: isStreaming ? "rgba(255,255,255,0.04)" : `${theme.palette.emerald}22`,
color: isStreaming ? theme.text.faint : theme.palette.emerald,
fontSize: sz(12), fontWeight: 600, border: `1px solid ${theme.palette.emerald}44`,
fontFamily: theme.font.mono,
transition: "all 0.15s",
}}
color={theme.palette.emerald}
>
{isStreaming ? "Generating..." : "Generate"}
</button>
</Button>
</div>
)}

Expand Down
42 changes: 13 additions & 29 deletions packages/plugin-innovation/src/components/InnovationExplorer.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { useState, useMemo, useCallback } from "react";
import { useTheme, LoadingState } from "@trustgraph/trustkit";
import { useTheme, LoadingState, Button, Input } from "@trustgraph/trustkit";
import type { Theme } from "@trustgraph/trustkit";
import { useInnovationData } from "../useInnovationData";
import type { IINode } from "../useInnovationData";
Expand Down Expand Up @@ -141,7 +141,7 @@ function matchesCategory(node: IINode, cat: CategoryFilter): boolean {
}

function Section({ title, color, children }: { title: string; color: string; children: React.ReactNode }) {
const { sz } = useTheme();
const { theme, sz } = useTheme();
return (
<div style={{ marginBottom: 16 }}>
<div style={{
Expand Down Expand Up @@ -473,19 +473,14 @@ export function InnovationExplorer(_props: InnovationExplorerProps) {
fontFamily: theme.font.mono, fontSize: sz(11),
}}>
{([["browse", "⊞ Browse"], ["pathfinder", "⇢ Pathfinder"], ["gtm", "🚀 GTM Advisor"]] as const).map(([m, label]) => (
<button
<Button
key={m}
size="sm"
active={mode === m}
onClick={() => setMode(m)}
style={{
padding: "5px 14px", borderRadius: 5, border: "none", cursor: "pointer",
background: mode === m ? "rgba(255,255,255,0.08)" : "transparent",
color: mode === m ? theme.text.primary : theme.text.faint,
fontFamily: theme.font.mono, fontSize: sz(11),
fontWeight: mode === m ? 600 : 400, transition: "all 0.15s",
}}
>
{label}
</button>
</Button>
))}
</div>

Expand Down Expand Up @@ -541,34 +536,23 @@ export function InnovationExplorer(_props: InnovationExplorerProps) {

{/* Search */}
<div style={{ padding: "10px 12px 6px", borderBottom: `1px solid ${theme.border.subtle}` }}>
<input
<Input
value={searchTerm}
onChange={e => setSearchTerm(e.target.value)}
onChange={setSearchTerm}
placeholder="Search entities..."
style={{
width: "100%", padding: "7px 10px", borderRadius: 6, fontSize: sz(12),
background: "rgba(255,255,255,0.04)", border: `1px solid ${theme.border.default}`,
color: theme.text.primary, outline: "none",
fontFamily: theme.font.sans,
}}
/>
{/* Category filters */}
<div style={{ display: "flex", flexWrap: "wrap", gap: 4, marginTop: 8, marginBottom: 4 }}>
{CATEGORIES.map(c => (
<button
<Button
key={c.key}
size="sm"
active={category === c.key}
onClick={() => setCategory(c.key)}
style={{
padding: "3px 8px", borderRadius: 4, fontSize: sz(10), border: "none",
cursor: "pointer",
background: category === c.key ? `${c.color}22` : "transparent",
color: category === c.key ? c.color : theme.text.faint,
fontFamily: theme.font.mono,
transition: "all 0.15s",
}}
style={category === c.key ? { background: `${c.color}22`, color: c.color } : { color: theme.text.faint }}
>
{c.label}
</button>
</Button>
))}
</div>
</div>
Expand Down
29 changes: 7 additions & 22 deletions packages/plugin-innovation/src/components/PathFinder.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { useState, useMemo, useCallback, useRef, useEffect } from "react";
import { useTheme } from "@trustgraph/trustkit";
import { useTheme, Button, Input } from "@trustgraph/trustkit";
import type { Theme } from "@trustgraph/trustkit";
import type { IINode } from "../useInnovationData";

Expand Down Expand Up @@ -121,18 +121,13 @@ function EntityPicker({
>✕</span>
</div>
) : (
<input
<Input
value={search}
onChange={e => { setSearch(e.target.value); setOpen(true); }}
onChange={v => { setSearch(v); setOpen(true); }}
onFocus={() => setOpen(true)}
placeholder={placeholder}
autoFocus={open}
style={{
width: "100%", padding: "8px 12px", borderRadius: 6, fontSize: sz(13),
background: "rgba(255,255,255,0.04)", border: `1px solid ${theme.border.default}`,
color: theme.text.primary, outline: "none",
fontFamily: theme.font.sans,
}}
style={{ fontSize: sz(13) }}
/>
)}
{open && matches.length > 0 && (
Expand Down Expand Up @@ -755,23 +750,13 @@ export function PathFinder({ nodes, abbreviations, adjacency, onSelectNode }: Pa
/>
</div>
<div style={{ paddingTop: 16 }}>
<button
<Button
onClick={handleFind}
disabled={!startUri || !endUri || startUri === endUri || searching}
style={{
padding: "8px 20px", borderRadius: 6,
background: startUri && endUri && startUri !== endUri
? `${theme.palette.emerald}22` : "rgba(255,255,255,0.04)",
color: startUri && endUri && startUri !== endUri
? theme.palette.emerald : theme.text.faint,
fontSize: sz(12), fontWeight: 600, cursor: "pointer",
fontFamily: theme.font.mono,
transition: "all 0.15s",
border: `1px solid ${startUri && endUri ? theme.palette.emerald + "44" : theme.border.default}`,
}}
color={theme.palette.emerald}
>
{searching ? "Searching..." : "Find Paths"}
</button>
</Button>
</div>
</div>

Expand Down
Loading
Loading