File size: 4,883 Bytes
80bcac8 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 | 'use client'
import { useAppStore } from '@/store'
import { PADDING_MODES } from '@/lib/kernels'
import { Select, Card, CardContent, Slider, Button } from '@/components/ui'
import { cn } from '@/utils/helpers'
import { Settings, Layers, Grid } from 'lucide-react'
export function OverlayControls() {
const { settings, updateSettings, toggleOverlay, setPadding } = useAppStore()
const { showOverlay, padding } = settings
return (
<Card className="w-full">
<CardContent className="p-4 space-y-4">
<h3 className="font-medium flex items-center gap-2">
<Settings className="h-4 w-4" />
Visualization Overlays
</h3>
<div className="grid grid-cols-2 gap-2">
{Object.entries(showOverlay).map(([key, value]) => (
<label key={key} className="flex items-center gap-2 cursor-pointer">
<input
type="checkbox"
checked={value}
onChange={() => toggleOverlay(key as keyof typeof showOverlay)}
className="rounded border-gray-300"
/>
<span className="text-sm capitalize">{key.replace(/([A-Z])/g, ' $1')}</span>
</label>
))}
</div>
</CardContent>
</Card>
)
}
export function PaddingControls() {
const { settings, setPadding } = useAppStore()
const { padding } = settings
return (
<Card className="w-full">
<CardContent className="p-4 space-y-4">
<h3 className="font-medium flex items-center gap-2">
<Grid className="h-4 w-4" />
Padding Strategy
</h3>
<Select
value={padding}
onChange={(e) => setPadding(e.target.value as typeof padding)}
options={PADDING_MODES.map((p) => ({ value: p.value, label: p.label }))}
placeholder="Select padding mode"
/>
<div className="text-sm text-gray-500 dark:text-gray-400">
{PADDING_MODES.find((p) => p.value === padding)?.description}
</div>
{/* Padding visualization would go here */}
</CardContent>
</Card>
)
}
export function KernelInfoPanel() {
const { selectedKernel } = useAppStore()
if (!selectedKernel) {
return (
<Card className="w-full">
<CardContent className="p-4 text-center text-gray-500">
No kernel selected
</CardContent>
</Card>
)
}
const { name, category, matrix, size, normalize, description, formula, reference } = selectedKernel
return (
<Card className="w-full">
<CardContent className="p-4 space-y-4">
<div className="flex items-start justify-between gap-4">
<div>
<h3 className="font-medium">{name}</h3>
<div className="flex items-center gap-2 mt-1">
<span className="px-2 py-0.5 text-xs bg-blue-100 text-blue-800 rounded dark:bg-blue-900/30 dark:text-blue-300">
{category}
</span>
<span className="px-2 py-0.5 text-xs bg-gray-100 text-gray-800 rounded dark:bg-gray-800 dark:text-gray-300">
{size}×{size}
</span>
{normalize && (
<span className="px-2 py-0.5 text-xs bg-green-100 text-green-800 rounded dark:bg-green-900/30 dark:text-green-300">
Normalized
</span>
)}
</div>
</div>
</div>
<p className="text-sm text-gray-600 dark:text-gray-400">{description}</p>
{formula && (
<div className="p-3 bg-gray-50 dark:bg-gray-800 rounded font-mono text-sm">
<span className="text-gray-500">Formula: </span>
<span>{formula}</span>
</div>
)}
<div className="space-y-2">
<h4 className="text-sm font-medium">Kernel Matrix</h4>
<div className="grid gap-1" style={{ gridTemplateColumns: `repeat(${size}, 1fr)` }}>
{matrix.map((row, i) =>
row.map((val, j) => (
<div
key={`${i}-${j}`}
className={cn(
'p-2 text-center text-sm font-mono rounded',
val > 0 ? 'bg-green-50 text-green-800 dark:bg-green-900/30 dark:text-green-300' : 'bg-red-50 text-red-800 dark:bg-red-900/30 dark:text-red-300'
)}
>
{val.toFixed(val === Math.round(val) ? 0 : 2)}
</div>
))
)}
</div>
</div>
{reference && (
<a
href={reference}
target="_blank"
rel="noopener noreferrer"
className="text-sm text-blue-600 hover:underline flex items-center gap-1"
>
<Layers className="h-3 w-3" />
Reference
</a>
)}
</CardContent>
</Card>
)
} |