Spaces:
Running
Running
Joel Woodfield commited on
Commit ·
bb56561
1
Parent(s): 0eee87a
Improve layout
Browse files- src/ConvolutionVisualizer.tsx +34 -33
src/ConvolutionVisualizer.tsx
CHANGED
|
@@ -93,36 +93,38 @@ function Sidebar({
|
|
| 93 |
|
| 94 |
return (
|
| 95 |
<div className="flex flex-col items-center border-l border-gray-200 p-4 gap-4">
|
| 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 |
<KernelEditor
|
| 127 |
useColor={useColor}
|
| 128 |
colorKernel={colorKernel}
|
|
@@ -302,11 +304,10 @@ function KernelEditor({
|
|
| 302 |
const loadedPresetLabel = useColor ? loadedColorPreset : loadedGrayPreset;
|
| 303 |
|
| 304 |
return (
|
| 305 |
-
<div className="w-full max-w-sm
|
| 306 |
-
<h3 className="text-sm font-semibold mb-2">Kernel</h3>
|
| 307 |
<div className="flex items-end gap-2 mb-3">
|
| 308 |
<Dropdown
|
| 309 |
-
label="Preset"
|
| 310 |
options={useColor ? colorPresetNames : grayPresetNames}
|
| 311 |
activeOption={useColor ? selectedColorPreset : selectedGrayPreset}
|
| 312 |
onChange={(option) => {
|
|
|
|
| 93 |
|
| 94 |
return (
|
| 95 |
<div className="flex flex-col items-center border-l border-gray-200 p-4 gap-4">
|
| 96 |
+
<div className="flex border-b border-gray-200 p-4 gap-4 pb-10">
|
| 97 |
+
<input
|
| 98 |
+
ref={imageFileInputRef}
|
| 99 |
+
type="file"
|
| 100 |
+
accept="image/*"
|
| 101 |
+
onChange={(e) => {
|
| 102 |
+
const file = e.target.files?.[0];
|
| 103 |
+
if (!file) return;
|
| 104 |
+
|
| 105 |
+
const reader = new FileReader();
|
| 106 |
+
reader.onload = () => {
|
| 107 |
+
const result = reader.result;
|
| 108 |
+
if (typeof result !== "string") {
|
| 109 |
+
return;
|
| 110 |
+
}
|
| 111 |
+
setImage(result);
|
| 112 |
+
};
|
| 113 |
+
reader.readAsDataURL(file);
|
| 114 |
+
}}
|
| 115 |
+
style={{ display: "none" }}
|
| 116 |
+
/>
|
| 117 |
+
<Button
|
| 118 |
+
label="Upload Image"
|
| 119 |
+
onClick={() => imageFileInputRef.current?.click()}
|
| 120 |
+
/>
|
| 121 |
+
<Radio
|
| 122 |
+
label="Color option"
|
| 123 |
+
options={["Grayscale", "Color"] as const}
|
| 124 |
+
activeOption={useColor ? "Color" : "Grayscale"}
|
| 125 |
+
onChange={(option) => setUseColor(option === "Color")}
|
| 126 |
+
/>
|
| 127 |
+
</div>
|
| 128 |
<KernelEditor
|
| 129 |
useColor={useColor}
|
| 130 |
colorKernel={colorKernel}
|
|
|
|
| 304 |
const loadedPresetLabel = useColor ? loadedColorPreset : loadedGrayPreset;
|
| 305 |
|
| 306 |
return (
|
| 307 |
+
<div className="flex flex-col items-center w-full max-w-sm rounded p-3">
|
|
|
|
| 308 |
<div className="flex items-end gap-2 mb-3">
|
| 309 |
<Dropdown
|
| 310 |
+
label="Kernel Preset"
|
| 311 |
options={useColor ? colorPresetNames : grayPresetNames}
|
| 312 |
activeOption={useColor ? selectedColorPreset : selectedGrayPreset}
|
| 313 |
onChange={(option) => {
|