docs(ui): add base for ui component showcase in docs (#4414)

This commit is contained in:
Alireza authored and GitHub committed 2024-10-15 09:53:26 -04:00
1 parent 9125cec333
commit 465df5c573
48 files changed
+5160 -4740

No files matched your search

-1
View File
@@ -1 +0,0 @@
This is our playground for designing and developing the next generation of the platform's UI. You probably don't need to be here.
-134
View File
@@ -1,134 +0,0 @@
import React from 'react';
import { createRoot } from 'react-dom/client';
import '../tailwind.css';
function Colors() {
return (
<main>
<h2>Primary color</h2>
<div className="row">
<div className="example2">
<div className="bg-primary h-16 w-16 rounded"></div>
</div>
<div className="example2">
<div className="bg-primary/80 h-16 w-16 rounded"></div>
</div>
<div className="example2">
<div className="bg-primary/60 h-16 w-16 rounded"></div>
</div>
<div className="example2">
<div className="bg-primary/40 h-16 w-16 rounded"></div>
</div>
<div className="example2">
<div className="bg-primary/20 h-16 w-16 rounded"></div>
</div>
<div className="example2">
<div className="bg-infosecondary h-16 w-16 rounded"></div>
</div>
<div className="example2">
<div className="bg-highlight h-16 w-16 rounded"></div>
</div>
<div className="example2">
<div className="bg-highlight h-16 w-16 rounded"></div>
</div>
<div className="example2">
<div className="h-16 w-16 rounded bg-white"></div>
</div>
<div className="example2">
<div className="h-16 w-16 rounded bg-white"></div>
</div>
<div className="example2">
<div className="h-16 w-16 rounded bg-white"></div>
</div>
</div>
<h2>New colors</h2>
<div className="row">
<div className="example2">
<div className="bg-highlight h-16 w-16 rounded"></div>
</div>
<div className="example2">
<div className="bg-bkg-low h-16 w-16 rounded"></div>
</div>
<div className="example2">
<div className="bg-bkg-med h-16 w-16 rounded"></div>
</div>
<div className="example2">
<div className="bg-bkg-full h-16 w-16 rounded"></div>
</div>
</div>
<h2>Core colors</h2>
<div className="row">
<div className="example2">
<div className="bg-background h-16 w-16 rounded"></div>
</div>
<div className="example2">
<div className="bg-foreground h-16 w-16 rounded"></div>
</div>
<div className="example2">
<div className="bg-card h-16 w-16 rounded"></div>
</div>
<div className="example2">
<div className="bg-card-foreground h-16 w-16 rounded"></div>
</div>
<div className="example2">
<div className="bg-popover h-16 w-16 rounded"></div>
</div>
<div className="example2">
<div className="bg-popover-foreground h-16 w-16 rounded"></div>
</div>
<div className="example2">
<div className="bg-primary h-16 w-16 rounded"></div>
</div>
<div className="example2">
<div className="bg-primary-foreground h-16 w-16 rounded"></div>
</div>
<div className="example2">
<div className="bg-secondary h-16 w-16 rounded"></div>
</div>
<div className="example2">
<div className="bg-secondary-foreground h-16 w-16 rounded"></div>
</div>
<div className="example2">
<div className="bg-muted h-16 w-16 rounded"></div>
</div>
<div className="example2">
<div className="bg-muted-foreground h-16 w-16 rounded"></div>
</div>
<div className="example2">
<div className="bg-accent h-16 w-16 rounded"></div>
</div>
<div className="example2">
<div className="bg-accent-foreground h-16 w-16 rounded"></div>
</div>
<div className="example2">
<div className="destructive h-16 w-16 rounded"></div>
</div>
<div className="example2">
<div className="destructive-foreground h-16 w-16 rounded"></div>
</div>
<div className="example2">
<div className="bg-border h-16 w-16 rounded"></div>
</div>
</div>
<h2>Borders</h2>
<div className="row">
<div className="example2">
<div className="bg-border h-16 w-16 rounded"></div>
</div>
<div className="example2">
<div className="bg-input h-16 w-16 rounded"></div>
</div>
<div className="example2">
<div className="bg-ring h-16 w-16 rounded"></div>
</div>
</div>
</main>
);
}
const container = document.getElementById('root');
const root = createRoot(container);
root.render(React.createElement(Colors));
-40
View File
@@ -1,40 +0,0 @@
import React from 'react';
import { createRoot } from 'react-dom/client';
import '../tailwind.css';
const App: React.FC = () => (
<div className="container mx-auto p-4">
<h1 className="mb-4 text-2xl font-bold">Home Page</h1>
<nav className="space-x-4">
<a
href="playground.html"
className="text-blue-500 hover:text-blue-700"
>
Playground
</a>
<a
href="patterns.html"
className="text-blue-500 hover:text-blue-700"
>
Patterns
</a>
<a
href="viewer.html"
className="text-blue-500 hover:text-blue-700"
>
Viewer
</a>
<a
href="colors.html"
className="text-blue-500 hover:text-blue-700"
>
Colors
</a>
</nav>
</div>
);
const container = document.getElementById('root');
const root = createRoot(container);
root.render(React.createElement(App));
@@ -1,171 +0,0 @@
// src/_pages/patterns.tsx
import React, { useState } from 'react';
import { createRoot } from 'react-dom/client';
import '../tailwind.css';
import { Button } from '../components/Button';
import {
Select,
SelectGroup,
SelectValue,
SelectTrigger,
SelectContent,
SelectLabel,
SelectItem,
SelectSeparator,
SelectScrollUpButton,
SelectScrollDownButton,
} from '../components/Select';
import {
DropdownMenu,
DropdownMenuTrigger,
DropdownMenuContent,
DropdownMenuItem,
DropdownMenuSeparator,
DropdownMenuLabel,
DropdownMenuSub,
DropdownMenuSubTrigger,
DropdownMenuSubContent,
DropdownMenuPortal,
} from '../components/DropdownMenu';
import { Icons } from '../components/Icons/Icons';
import DataRow from '../_prototypes/DataRow/DataRow';
import dataList from '../_prototypes/DataRow/dataList.json';
import actionOptionsMap from '../_prototypes/DataRow/actionOptionsMap';
import {
Accordion,
AccordionItem,
AccordionTrigger,
AccordionContent,
} from '../components/Accordion/Accordion';
import { Slider } from '../components/Slider';
import { Switch } from '../components/Switch';
import { Label } from '../components/Label';
import { Input } from '../components/Input';
import { Tabs, TabsList, TabsTrigger, TabsContent } from '../components/Tabs';
import { ChevronDownIcon } from '@radix-ui/react-icons';
interface DataItem {
id: number;
title: string;
description: string;
optionalField?: string;
colorHex?: string;
details?: string;
series?: string;
}
interface ListGroup {
type: string;
items: DataItem[];
}
function Patterns() {
const [selectedRowId, setSelectedRowId] = useState<string | null>(null);
const handleAction = (id: string, action: string) => {
console.log(`Action "${action}" triggered for item with id: ${id}`);
// Implement actual action logic here
};
const handleRowSelect = (id: string) => {
setSelectedRowId(prevSelectedId => (prevSelectedId === id ? null : id));
};
const organSegmentationGroup = dataList.find(
(listGroup: ListGroup) => listGroup.type === 'Organ Segmentation'
);
const roiToolsGroup = dataList.find((listGroup: ListGroup) => listGroup.type === 'ROI Tools');
if (!organSegmentationGroup) {
return <div className="text-red-500">Organ Segmentation data not found.</div>;
}
if (!roiToolsGroup) {
return <div className="text-red-500">ROI Tools data not found.</div>;
}
return (
<div className="my-4 flex max-w-6xl justify-end py-6">
{/* Simulated Panel List for "Segmentation" */}
<div className="w-64 space-y-0">
<Accordion
type="multiple"
defaultValue={['measurements-list', 'measurements-additional']}
collapsible
>
{/* Segmentation Tools */}
<AccordionItem value="measurements-list">
<AccordionTrigger className="bg-popover hover:bg-accent text-muted-foreground my-0.5 flex h-7 w-full items-center justify-between rounded py-2 pr-1 pl-2 font-normal">
<span>Measurements</span>
</AccordionTrigger>
<AccordionContent>
<div className="mx-2 my-0">
<div className="text-foreground text-sm">2024-Jan-01</div>
<div className="text-muted-foreground border-input border-b-2 pb-1 text-sm">
Study title lorem ipsum
</div>
</div>
<div className="flex h-9 w-full items-center rounded pr-0.5">
<div className="flex space-x-1">
<Button
size="sm"
variant="ghost"
className="pl-1.5"
>
<Icons.Download />
<span className="pl-1">CSV</span>
</Button>
<Button
size="sm"
variant="ghost"
className="pl-0.5"
>
<Icons.Add />
Create DICOM SR
</Button>
</div>
</div>
<div className="space-y-px">
{roiToolsGroup.items.map((item, index) => {
const compositeId = `${roiToolsGroup.type}-${item.id}-panel`; // Ensure unique composite ID
return (
<DataRow
key={`panel-${compositeId}`} // Prefix to ensure uniqueness
number={index + 1}
title={item.title}
description={item.description}
optionalField={item.optionalField}
colorHex={item.colorHex}
details={item.details}
series={item.series} // Pass the new series field
actionOptions={actionOptionsMap[roiToolsGroup.type] || ['Action']}
onAction={(action: string) => handleAction(compositeId, action)}
isSelected={selectedRowId === compositeId}
onSelect={() => handleRowSelect(compositeId)}
/>
);
})}
</div>
</AccordionContent>
</AccordionItem>
{/* Additional Findings */}
<AccordionItem value="measurements-additional">
<AccordionTrigger className="bg-popover hover:bg-accent text-muted-foreground my-0.5 flex h-7 w-full items-center justify-between rounded py-2 pr-1 pl-2 font-normal">
<span>Additional Findings</span>
</AccordionTrigger>
<AccordionContent>
<div className="bg-muted mb-0.5 h-12 rounded-b pb-3"></div>
</AccordionContent>
</AccordionItem>
</Accordion>
</div>
</div>
);
}
const container = document.getElementById('root');
const root = createRoot(container!);
root.render(<Patterns />);
@@ -1,43 +0,0 @@
// src/_pages/patterns.tsx
import React from 'react';
import { createRoot } from 'react-dom/client';
import '../tailwind.css';
// component imports
import { Button } from '../components/Button';
import { Input } from '../components/Input';
import { Label } from '../components/Label';
import {
Select,
SelectGroup,
SelectValue,
SelectTrigger,
SelectContent,
SelectLabel,
SelectItem,
SelectSeparator,
SelectScrollUpButton,
SelectScrollDownButton,
} from '../components/Select';
import { Tabs, TabsList, TabsTrigger, TabsContent } from '../components/Tabs';
import Separator from '../components/Separator';
import { Switch } from '../components/Switch';
import { Checkbox } from '../components/Checkbox';
import { Toggle, toggleVariants } from '../components/Toggle';
import { Slider } from '../components/Slider';
import { ScrollArea, ScrollBar } from '../components/ScrollArea';
import { PanelSplit } from '../_prototypes/PanelSplit'; // Updated import path
function Patterns() {
return (
<div className="my-4 mx-auto max-w-6xl py-6">
<div className="text-3xl"> Patterns 1 </div>
<PanelSplit />;
</div>
);
}
const container = document.getElementById('root');
const root = createRoot(container);
root.render(React.createElement(Patterns));
@@ -1,316 +0,0 @@
import React, { useState } from 'react';
import { createRoot } from 'react-dom/client';
import '../tailwind.css';
import { Button } from '../components/Button';
import {
Select,
SelectGroup,
SelectValue,
SelectTrigger,
SelectContent,
SelectLabel,
SelectItem,
SelectSeparator,
SelectScrollUpButton,
SelectScrollDownButton,
} from '../components/Select';
import {
DropdownMenu,
DropdownMenuTrigger,
DropdownMenuContent,
DropdownMenuItem,
DropdownMenuSeparator,
DropdownMenuLabel,
DropdownMenuSub,
DropdownMenuSubTrigger,
DropdownMenuSubContent,
DropdownMenuPortal,
} from '../components/DropdownMenu';
import { Icons } from '../components/Icons/Icons';
import DataRow from '../_prototypes/DataRow/DataRow';
import dataList from '../_prototypes/DataRow/dataList.json';
import actionOptionsMap from '../_prototypes/DataRow/actionOptionsMap';
import {
Accordion,
AccordionItem,
AccordionTrigger,
AccordionContent,
} from '../components/Accordion/Accordion';
import { Slider } from '../components/Slider';
import { Switch } from '../components/Switch';
import { Label } from '../components/Label';
import { Input } from '../components/Input';
import { Tabs, TabsList, TabsTrigger, TabsContent } from '../components/Tabs';
import { ChevronDownIcon } from '@radix-ui/react-icons';
interface DataItem {
id: number;
title: string;
description: string;
optionalField?: string;
colorHex?: string;
details?: string;
series?: string;
}
interface ListGroup {
type: string;
items: DataItem[];
}
function Patterns() {
const [selectedRowId, setSelectedRowId] = useState<string | null>(null);
const [selectedTab, setSelectedTab] = useState<string>('Fill & Outline');
const handleAction = (id: string, action: string) => {
console.log(`Action "${action}" triggered for item with id: ${id}`);
// Implement actual action logic here
};
// Handle row selection
const handleRowSelect = (id: string) => {
setSelectedRowId(prevSelectedId => (prevSelectedId === id ? null : id));
};
const organSegmentationGroup = dataList.find(
(listGroup: ListGroup) => listGroup.type === 'Organ Segmentation'
);
if (!organSegmentationGroup) {
return <div className="text-red-500">Organ Segmentation data not found.</div>;
}
return (
<div className="my-4 flex max-w-6xl justify-end py-6">
<div className="w-64 space-y-0">
<Accordion
type="multiple"
defaultValue={['segmentation-tools', 'segmentation-list']}
collapsible
>
{/* Segmentation Tools */}
<AccordionItem value="segmentation-tools">
<AccordionTrigger className="bg-popover hover:bg-accent text-muted-foreground my-0.5 flex h-7 w-full items-center justify-between rounded py-2 pr-1 pl-2 font-normal">
<span>Segmentation Tools</span>
</AccordionTrigger>
<AccordionContent>
<div className="bg-muted mb-0.5 h-32 rounded-b pb-3"></div>
</AccordionContent>
</AccordionItem>
{/* Segmentation List */}
<AccordionItem value="segmentation-list">
<AccordionTrigger className="bg-popover hover:bg-accent text-muted-foreground my-0.5 flex h-7 w-full items-center justify-between rounded py-2 pr-1 pl-2 font-normal">
<span>Segmentation List</span>
</AccordionTrigger>
<AccordionContent>
<div className="mb-0">
{/* Header Controls */}
<div className="bg-muted flex h-10 w-full items-center space-x-1 rounded-t px-1.5">
<DropdownMenu>
<DropdownMenuTrigger asChild>
<Button
variant="ghost"
size="icon"
>
<Icons.More className="h-6 w-6" />
</Button>
</DropdownMenuTrigger>
<DropdownMenuContent align="start">
<DropdownMenuItem>
<Icons.Add className="text-foreground" />
<span className="pl-2">Create New Segmentation</span>
</DropdownMenuItem>
<DropdownMenuSeparator />
<DropdownMenuLabel>Current Segmentation</DropdownMenuLabel>
<DropdownMenuItem>
<Icons.Rename className="text-foreground" />
<span className="pl-2">Rename</span>
</DropdownMenuItem>
<DropdownMenuItem>
<Icons.Delete className="text-foreground" />
<span className="pl-2">Delete</span>
</DropdownMenuItem>
<DropdownMenuSub>
<DropdownMenuSubTrigger>
<Icons.Export className="text-foreground" />
<span className="pl-2">Export & Download</span>
</DropdownMenuSubTrigger>
<DropdownMenuPortal>
<DropdownMenuSubContent>
<DropdownMenuItem>Export DICOM SEG</DropdownMenuItem>
<DropdownMenuItem>Download DICOM SEG</DropdownMenuItem>
<DropdownMenuItem>Download DICOM RTSTRUCT</DropdownMenuItem>
</DropdownMenuSubContent>
</DropdownMenuPortal>
</DropdownMenuSub>
</DropdownMenuContent>
</DropdownMenu>
<Select>
<SelectTrigger className="w-full overflow-hidden">
<SelectValue placeholder="Segmentation 1" />
</SelectTrigger>
<SelectContent>
<SelectItem value="seg1">Segmentation 1</SelectItem>
<SelectItem value="seg2">Segmentation 2</SelectItem>
<SelectItem value="seg3">Segmentation Long Name 123</SelectItem>
</SelectContent>
</Select>
<Button
variant="ghost"
size="icon"
>
<Icons.Info className="h-6 w-6" />
</Button>
</div>
{/* Appearance Settings */}
<AccordionItem value="segmentation-display">
<AccordionTrigger className="bg-muted hover:bg-accent mt-0.5 flex h-7 w-full items-center justify-between rounded-b pr-1 pl-2 font-normal text-white">
<div className="flex space-x-2">
<Icons.Controls className="text-primary" />
<span className="text-primary pr-1">Appearance Settings</span>
</div>
</AccordionTrigger>
<AccordionContent>
<div className="bg-muted mb-0.5 space-y-2 rounded-b px-1.5 pt-0.5 pb-3">
<div className="mx-1 mb-2.5 mt-1 flex items-center justify-between space-x-4">
{/* Display Label with Selected Tab */}
<div className="text-muted-foreground text-xs">Show: {selectedTab}</div>
{/* Tabs Controls */}
<Tabs
value={selectedTab}
onValueChange={setSelectedTab}
>
<TabsList>
<TabsTrigger value="Fill & Outline">
<Icons.DisplayFillAndOutline className="text-primary" />
</TabsTrigger>
<TabsTrigger value="Outline Only">
<Icons.DisplayOutlineOnly className="text-primary" />
</TabsTrigger>
<TabsTrigger value="Fill Only">
<Icons.DisplayFillOnly className="text-primary" />
</TabsTrigger>
</TabsList>
</Tabs>
</div>
{/* Opacity Slider */}
<div className="my-2 flex items-center ">
<Label className="text-muted-foreground mx-1 w-14 flex-none whitespace-nowrap text-xs">
Opacity
</Label>
<Slider
className="mx-1 flex-1"
defaultValue={[85]}
max={100}
step={1}
/>
<Input
className="mx-1 w-10 flex-none"
placeholder="85"
/>
</div>
{/* Border Slider */}
<div className="my-2 flex items-center">
<Label className="text-muted-foreground mx-1 w-14 flex-none whitespace-nowrap text-xs">
Border
</Label>
<Slider
className="mx-1 flex-1"
defaultValue={[10]}
max={100}
step={1}
/>
<Input
className="mx-1 w-10 flex-none"
placeholder="2"
/>
</div>
{/* Sync Changes Switch */}
<div className="my-2 flex items-center pl-1 pb-1">
<Switch defaultChecked />
<Label className="text-muted-foreground mx-2 w-14 flex-none whitespace-nowrap text-xs">
Sync changes in all viewports
</Label>
</div>
<div className="border-input w-full border"></div>
{/* Display Inactive Segmentations Switch */}
<div className="my-2 flex items-center pl-1">
<Switch defaultChecked />
<Label className="text-muted-foreground mx-2 w-14 flex-none whitespace-nowrap text-xs">
Display inactive segmentations
</Label>
</div>
{/* Additional Opacity Slider */}
<div className="my-2 flex items-center ">
<Label className="text-muted-foreground mx-1 w-14 flex-none whitespace-nowrap text-xs">
Opacity
</Label>
<Slider
className="mx-1 flex-1"
defaultValue={[65]}
max={100}
step={1}
/>
<Input
className="mx-1 w-10 flex-none"
placeholder="65"
/>
</div>
</div>
</AccordionContent>
</AccordionItem>
{/* Action Buttons */}
<div className="my-px flex h-9 w-full items-center justify-between rounded pl-0.5 pr-7">
<Button
size="sm"
variant="ghost"
className="pr pl-0.5"
>
<Icons.Add />
Add Segment
</Button>
<Button
size="icon"
variant="ghost"
>
<Icons.Hide className="h-6 w-6" />
</Button>
</div>
</div>
{/* Data Rows */}
<div className="space-y-px">
{organSegmentationGroup.items.map((item, index) => {
const compositeId = `${organSegmentationGroup.type}-${item.id}-panel`;
return (
<DataRow
key={`panel-${compositeId}`}
number={index + 1}
title={item.title}
description={item.description}
optionalField={item.optionalField}
colorHex={item.colorHex}
details={item.details}
series={item.series}
actionOptions={actionOptionsMap[organSegmentationGroup.type] || ['Action']}
onAction={(action: string) => handleAction(compositeId, action)}
isSelected={selectedRowId === compositeId}
onSelect={() => handleRowSelect(compositeId)}
/>
);
})}
</div>
</AccordionContent>
</AccordionItem>
</Accordion>
</div>
</div>
);
}
const container = document.getElementById('root');
const root = createRoot(container!);
root.render(<Patterns />);
-316
View File
@@ -1,316 +0,0 @@
import React, { useState } from 'react';
import { createRoot } from 'react-dom/client';
import '../tailwind.css';
import { Button } from '../components/Button';
import {
Select,
SelectGroup,
SelectValue,
SelectTrigger,
SelectContent,
SelectLabel,
SelectItem,
SelectSeparator,
SelectScrollUpButton,
SelectScrollDownButton,
} from '../components/Select';
import {
DropdownMenu,
DropdownMenuTrigger,
DropdownMenuContent,
DropdownMenuItem,
DropdownMenuSeparator,
DropdownMenuLabel,
DropdownMenuSub,
DropdownMenuSubTrigger,
DropdownMenuSubContent,
DropdownMenuPortal,
} from '../components/DropdownMenu';
import { Icons } from '../components/Icons/Icons';
import DataRow from '../_prototypes/DataRow/DataRow';
import dataList from '../_prototypes/DataRow/dataList.json';
import actionOptionsMap from '../_prototypes/DataRow/actionOptionsMap';
import {
Accordion,
AccordionItem,
AccordionTrigger,
AccordionContent,
} from '../components/Accordion/Accordion';
import { Slider } from '../components/Slider';
import { Switch } from '../components/Switch';
import { Label } from '../components/Label';
import { Input } from '../components/Input';
import { Tabs, TabsList, TabsTrigger, TabsContent } from '../components/Tabs';
import { ChevronDownIcon } from '@radix-ui/react-icons';
interface DataItem {
id: number;
title: string;
description: string;
optionalField?: string;
colorHex?: string;
details?: string;
series?: string;
}
interface ListGroup {
type: string;
items: DataItem[];
}
function Patterns() {
const [selectedRowId, setSelectedRowId] = useState<string | null>(null);
const [selectedTab, setSelectedTab] = useState<string>('Fill & Outline');
const handleAction = (id: string, action: string) => {
console.log(`Action "${action}" triggered for item with id: ${id}`);
// Implement actual action logic here
};
// Handle row selection
const handleRowSelect = (id: string) => {
setSelectedRowId(prevSelectedId => (prevSelectedId === id ? null : id));
};
const organSegmentationGroup = dataList.find(
(listGroup: ListGroup) => listGroup.type === 'Organ Segmentation'
);
if (!organSegmentationGroup) {
return <div className="text-red-500">Organ Segmentation data not found.</div>;
}
return (
<div className="my-4 flex max-w-6xl justify-end py-6">
<div className="w-64 space-y-0">
<Accordion
type="multiple"
defaultValue={['segmentation-tools', 'segmentation-list']}
collapsible
>
{/* Segmentation Tools */}
<AccordionItem value="segmentation-tools">
<AccordionTrigger className="bg-popover hover:bg-accent text-muted-foreground my-0.5 flex h-7 w-full items-center justify-between rounded py-2 pr-1 pl-2 font-normal">
<span>Segmentation Tools</span>
</AccordionTrigger>
<AccordionContent>
<div className="bg-muted mb-0.5 h-32 rounded-b pb-3"></div>
</AccordionContent>
</AccordionItem>
{/* Segmentation List */}
<AccordionItem value="segmentation-list">
<AccordionTrigger className="bg-popover hover:bg-accent text-muted-foreground my-0.5 flex h-7 w-full items-center justify-between rounded py-2 pr-1 pl-2 font-normal">
<span>Segmentation List</span>
</AccordionTrigger>
<AccordionContent>
<div className="mb-0">
{/* Header Controls */}
<div className="bg-muted flex h-10 w-full items-center space-x-1 rounded-t px-1.5">
<DropdownMenu>
<DropdownMenuTrigger asChild>
<Button
variant="ghost"
size="icon"
>
<Icons.More className="h-6 w-6" />
</Button>
</DropdownMenuTrigger>
<DropdownMenuContent align="start">
<DropdownMenuItem>
<Icons.Add className="text-foreground" />
<span className="pl-2">Create New Segmentation</span>
</DropdownMenuItem>
<DropdownMenuSeparator />
<DropdownMenuLabel>Current Segmentation</DropdownMenuLabel>
<DropdownMenuItem>
<Icons.Rename className="text-foreground" />
<span className="pl-2">Rename</span>
</DropdownMenuItem>
<DropdownMenuItem>
<Icons.Delete className="text-foreground" />
<span className="pl-2">Delete</span>
</DropdownMenuItem>
<DropdownMenuSub>
<DropdownMenuSubTrigger>
<Icons.Export className="text-foreground" />
<span className="pl-2">Export & Download</span>
</DropdownMenuSubTrigger>
<DropdownMenuPortal>
<DropdownMenuSubContent>
<DropdownMenuItem>Export DICOM SEG</DropdownMenuItem>
<DropdownMenuItem>Download DICOM SEG</DropdownMenuItem>
<DropdownMenuItem>Download DICOM RTSTRUCT</DropdownMenuItem>
</DropdownMenuSubContent>
</DropdownMenuPortal>
</DropdownMenuSub>
</DropdownMenuContent>
</DropdownMenu>
<Select>
<SelectTrigger className="w-full overflow-hidden">
<SelectValue placeholder="Segmentation 1" />
</SelectTrigger>
<SelectContent>
<SelectItem value="seg1">Segmentation 1</SelectItem>
<SelectItem value="seg2">Segmentation 2</SelectItem>
<SelectItem value="seg3">Segmentation Long Name 123</SelectItem>
</SelectContent>
</Select>
<Button
variant="ghost"
size="icon"
>
<Icons.Info className="h-6 w-6" />
</Button>
</div>
{/* Appearance Settings */}
<AccordionItem value="segmentation-display">
<AccordionTrigger className="bg-muted hover:bg-accent mt-0.5 flex h-7 w-full items-center justify-between rounded-b pr-1 pl-2 font-normal text-white">
<div className="flex space-x-2">
<Icons.Controls className="text-primary" />
<span className="text-primary pr-1">Appearance Settings</span>
</div>
</AccordionTrigger>
<AccordionContent>
<div className="bg-muted mb-0.5 space-y-2 rounded-b px-1.5 pt-0.5 pb-3">
<div className="mx-1 mb-2.5 mt-1 flex items-center justify-between space-x-4">
{/* Display Label with Selected Tab */}
<div className="text-muted-foreground text-xs">Show: {selectedTab}</div>
{/* Tabs Controls */}
<Tabs
value={selectedTab}
onValueChange={setSelectedTab}
>
<TabsList>
<TabsTrigger value="Fill & Outline">
<Icons.DisplayFillAndOutline className="text-primary" />
</TabsTrigger>
<TabsTrigger value="Outline Only">
<Icons.DisplayOutlineOnly className="text-primary" />
</TabsTrigger>
<TabsTrigger value="Fill Only">
<Icons.DisplayFillOnly className="text-primary" />
</TabsTrigger>
</TabsList>
</Tabs>
</div>
{/* Opacity Slider */}
<div className="my-2 flex items-center ">
<Label className="text-muted-foreground mx-1 w-14 flex-none whitespace-nowrap text-xs">
Opacity
</Label>
<Slider
className="mx-1 flex-1"
defaultValue={[85]}
max={100}
step={1}
/>
<Input
className="mx-1 w-10 flex-none"
placeholder="85"
/>
</div>
{/* Border Slider */}
<div className="my-2 flex items-center">
<Label className="text-muted-foreground mx-1 w-14 flex-none whitespace-nowrap text-xs">
Border
</Label>
<Slider
className="mx-1 flex-1"
defaultValue={[10]}
max={100}
step={1}
/>
<Input
className="mx-1 w-10 flex-none"
placeholder="2"
/>
</div>
{/* Sync Changes Switch */}
<div className="my-2 flex items-center pl-1 pb-1">
<Switch defaultChecked />
<Label className="text-muted-foreground mx-2 w-14 flex-none whitespace-nowrap text-xs">
Sync changes in all viewports
</Label>
</div>
<div className="border-input w-full border"></div>
{/* Display Inactive Segmentations Switch */}
<div className="my-2 flex items-center pl-1">
<Switch defaultChecked />
<Label className="text-muted-foreground mx-2 w-14 flex-none whitespace-nowrap text-xs">
Display inactive segmentations
</Label>
</div>
{/* Additional Opacity Slider */}
<div className="my-2 flex items-center ">
<Label className="text-muted-foreground mx-1 w-14 flex-none whitespace-nowrap text-xs">
Opacity
</Label>
<Slider
className="mx-1 flex-1"
defaultValue={[65]}
max={100}
step={1}
/>
<Input
className="mx-1 w-10 flex-none"
placeholder="65"
/>
</div>
</div>
</AccordionContent>
</AccordionItem>
{/* Action Buttons */}
<div className="my-px flex h-9 w-full items-center justify-between rounded pl-0.5 pr-7">
<Button
size="sm"
variant="ghost"
className="pr pl-0.5"
>
<Icons.Add />
Add Segment
</Button>
<Button
size="icon"
variant="ghost"
>
<Icons.Hide className="h-6 w-6" />
</Button>
</div>
</div>
{/* Data Rows */}
<div className="space-y-px">
{organSegmentationGroup.items.map((item, index) => {
const compositeId = `${organSegmentationGroup.type}-${item.id}-panel`; // Ensure unique composite ID
return (
<DataRow
key={`panel-${compositeId}`} // Prefix to ensure uniqueness
number={index + 1}
title={item.title}
description={item.description}
optionalField={item.optionalField}
colorHex={item.colorHex}
details={item.details}
series={item.series}
actionOptions={actionOptionsMap[organSegmentationGroup.type] || ['Action']}
onAction={(action: string) => handleAction(compositeId, action)}
isSelected={selectedRowId === compositeId}
onSelect={() => handleRowSelect(compositeId)}
/>
);
})}
</div>
</AccordionContent>
</AccordionItem>
</Accordion>
</div>
</div>
);
}
const container = document.getElementById('root');
const root = createRoot(container!);
root.render(<Patterns />);
-411
View File
@@ -1,411 +0,0 @@
import React from 'react';
import { createRoot } from 'react-dom/client';
import '../tailwind.css';
import { Button } from '../components/Button';
import { Input } from '../components/Input';
import { Label } from '../components/Label';
import {
Select,
SelectGroup,
SelectValue,
SelectTrigger,
SelectContent,
SelectLabel,
SelectItem,
SelectSeparator,
SelectScrollUpButton,
SelectScrollDownButton,
} from '../components/Select';
import { Tabs, TabsList, TabsTrigger, TabsContent } from '../components/Tabs';
import { Separator } from '../components/Separator';
import { Switch } from '../components/Switch';
import { Checkbox } from '../components/Checkbox';
import { Toggle, toggleVariants } from '../components/Toggle';
import { Slider } from '../components/Slider';
import { ScrollArea, ScrollBar } from '../components/ScrollArea';
import {
DropdownMenu,
DropdownMenuTrigger,
DropdownMenuContent,
DropdownMenuItem,
DropdownMenuCheckboxItem,
DropdownMenuRadioItem,
DropdownMenuLabel,
DropdownMenuSeparator,
DropdownMenuShortcut,
DropdownMenuGroup,
DropdownMenuPortal,
DropdownMenuSub,
DropdownMenuSubContent,
DropdownMenuSubTrigger,
DropdownMenuRadioGroup,
} from '../components/DropdownMenu';
import { BackgroundColorSelect } from '../components/BackgroundColorSelect';
// import { Tooltip, TooltipTrigger, TooltipContent, TooltipProvider } from '../components/Tooltip';
// import type { Metadata } from 'next';
// import Script from 'next/script';
// import BackgroundColorSelector from '@/components/backgroundcolor';
// import { useState, useEffect } from 'react';
// import { Inter } from 'next/font/google';
// import { ThemeProvider } from '@/components/themeprovider';
// import { Button2 } from '@/components/ui/button2';
// import { Switch } from '@/components/ui/switch';
// import { Slider } from '@/components/ui/slider';
// import { ScrollArea } from '@/components/ui/scroll-area';
// import { Tabs, TabsContent, TabsList, TabsTrigger } from '@/components/ui/tabs';
// import { Separator } from '@/components/ui/separator';
// import { Toggle } from '@/components/ui/toggle';
// import { Checkbox } from '@/components/ui/checkbox';
// import {
// Select,
// SelectContent,
// SelectItem,
// SelectTrigger,
// SelectValue,
// } from '@/components/ui/select';
// import { Input } from '@/components/ui/input';
// import { Label } from '@/components/ui/label';
// import icons from '../../components/icons';
// import SegRow from '@/components/segrow';
export default function Playground() {
return (
<main className="my-4 mx-auto max-w-6xl py-6">
<BackgroundColorSelect />
<h2 className="section-header">Button default</h2>
<div className="row">
<div className="example">
<Button
className=""
variant="default"
>
Primary Button
</Button>
</div>
<div className="example">
<Button variant="secondary">Secondary Button</Button>
</div>
<div className="example">
<Button variant="ghost">Ghost Button</Button>
</div>
<div className="example">
<Button
variant="ghost"
size="icon"
>
?
</Button>
</div>
<div className="example">
<Button variant="link">Link</Button>
</div>
</div>
<h2 className="section-header">Button small</h2>
<div className="row">
<div className="example">
<Button
className=""
variant="default"
size="sm"
>
Primary Button
</Button>
</div>
<div className="example">
<Button
variant="secondary"
size="sm"
>
Secondary Button
</Button>
</div>
<div className="example">
<Button
variant="ghost"
size="sm"
>
Ghost Button
</Button>
</div>
<div className="example">
<Button
variant="ghost"
size="icon"
>
?
</Button>
</div>
<div className="example">
<Button
variant="link"
size="sm"
>
Link
</Button>
</div>
</div>
<h2 className="section-header">Button large</h2>
<div className="row">
<div className="example">
<Button
className=""
variant="default"
size="lg"
>
Primary Button
</Button>
</div>
<div className="example">
<Button
variant="secondary"
size="lg"
>
Secondary Button
</Button>
</div>
<div className="example">
<Button
variant="ghost"
size="lg"
>
Ghost Button
</Button>
</div>
<div className="example">
<Button
variant="ghost"
size="icon"
>
?
</Button>
</div>
<div className="example">
<Button
variant="link"
size="lg"
>
Link
</Button>
</div>
</div>
<h2 className="section-header">Input</h2>
<div className="row">
<div className="example">
<div className="inline-block">
<div className="mr-4 inline-block">
<Label>Patient Weight</Label>
</div>
<div className="inline-block">
<Input placeholder="(kg)" />
</div>
</div>
</div>
</div>
<h2 className="section-header">Color swatches</h2>
<div className="row">
<div className="example2">
<div className="bg-actions h-16 w-16 rounded"></div>
</div>
<div className="example2">
<div className="bg-infosecondary h-16 w-16 rounded"></div>
</div>
<div className="example2">
<div className="bg-highlight h-16 w-16 rounded"></div>
</div>
<div className="example2">
<div className="h-16 w-16 rounded bg-white"></div>
</div>
<div className="example2">
<div className="h-16 w-16 rounded bg-white"></div>
</div>
<div className="example2">
<div className="h-16 w-16 rounded bg-white"></div>
</div>
</div>
<h2 className="section-header">Typography</h2>
<div className="row">
<div className="example text-base text-white">Standard text size (text-base) 14px</div>
<div className="example text-sm text-white">Small text size (text-sm) 13px</div>
<div className="example text-xs text-white">Extra small text size (text-xs) 12px</div>
</div>
<h2 className="section-header">Typography large</h2>
<div className="row">
<div className="example text-lg text-white">Large text size (text-lg) 16px</div>
<div className="example text-xl text-white">Small text size (text-xl) 18px</div>
<div className="example text-2xl text-white">Extra small text size (text-2xl) 20px</div>
</div>
<h2 className="section-header">Tabs</h2>
<div className="row">
<div className="example">
<Tabs className="w-[400px]">
<TabsList>
<TabsTrigger value="circle">Circle</TabsTrigger>
<Separator orientation="vertical" />
<TabsTrigger value="sphere">Sphere</TabsTrigger>
<Separator orientation="vertical" />
<TabsTrigger value="square">Square</TabsTrigger>
</TabsList>
</Tabs>
</div>
</div>
<h2 className="section-header">Select</h2>
<div className="row">
<div className="example">
<Select>
<SelectTrigger className="w-[180px]">
<SelectValue placeholder="Theme" />
</SelectTrigger>
<SelectContent>
<SelectItem value="light">Light</SelectItem>
<SelectItem value="dark">Dark</SelectItem>
<SelectItem value="system">System</SelectItem>
</SelectContent>
</Select>
</div>
</div>
<h2 className="section-header">Dropdown Menu</h2>
<div className="row">
<div className="example">
<DropdownMenu>
<DropdownMenuTrigger>
<Button>Open Basic</Button>
</DropdownMenuTrigger>
<DropdownMenuContent>
<DropdownMenuItem>Item 1</DropdownMenuItem>
<DropdownMenuItem>Item 2</DropdownMenuItem>
<DropdownMenuItem>Long name Item 3</DropdownMenuItem>
</DropdownMenuContent>
</DropdownMenu>
</div>
<div className="example">
<DropdownMenu>
<DropdownMenuTrigger asChild>
<Button>Open Align Start</Button>
</DropdownMenuTrigger>
<DropdownMenuContent align="start">
<DropdownMenuItem>Item 1</DropdownMenuItem>
<DropdownMenuItem>Item 2</DropdownMenuItem>
<DropdownMenuItem>Long name Item 3</DropdownMenuItem>
</DropdownMenuContent>
</DropdownMenu>
</div>
<div className="example">
<DropdownMenu>
<DropdownMenuTrigger asChild>
<Button>Open Align End</Button>
</DropdownMenuTrigger>
<DropdownMenuContent align="end">
<DropdownMenuItem>Item 1</DropdownMenuItem>
<DropdownMenuItem>Item 2</DropdownMenuItem>
<DropdownMenuItem>Long name Item 3</DropdownMenuItem>
</DropdownMenuContent>
</DropdownMenu>
</div>
<div className="example">
<DropdownMenu>
<DropdownMenuTrigger asChild>
<Button>Open Align Top</Button>
</DropdownMenuTrigger>
<DropdownMenuContent
side="top"
align="start"
>
<DropdownMenuItem onSelect={() => console.log('Item 1')}>Item 1</DropdownMenuItem>
<DropdownMenuItem onSelect={() => console.log('Item 2')}>Item 2</DropdownMenuItem>
<DropdownMenuItem onSelect={() => console.log('Item 3')}>
Long name Item 3
</DropdownMenuItem>
</DropdownMenuContent>
</DropdownMenu>
</div>
</div>
<h2 className="section-header">Switch</h2>
<div className="row">
<div className="example">
<Switch />
</div>
</div>
<h2 className="section-header">Checkbox</h2>
<div className="row">
<div className="example">
<div className="items-top flex space-x-2">
<Checkbox id="terms1" />
<div className="grid gap-1.5 pt-0.5 leading-none">
<Label>Display inactive segmentations</Label>
</div>
</div>
</div>
</div>
<h2 className="section-header">Toggle</h2>
<div className="row">
<div className="example">
<Toggle>Hello</Toggle>
</div>
</div>
<h2 className="section-header">Slider</h2>
<div className="row">
<div className="example">
<div className="w-40 px-5">
<Slider
className="w-full"
defaultValue={[50]}
max={100}
step={1}
/>
</div>
</div>
</div>
<h2 className="section-header">Accordion</h2>
<div className="row">
<div className="example">
<div className="w-40 px-5">
<Slider
className="w-full"
defaultValue={[50]}
max={100}
step={1}
/>
</div>
</div>
</div>
<h2 className="section-header">Scroll Area</h2>
<div className="row">
<div className="example">
<ScrollArea className="border-input bg-background h-[150px] w-[350px] rounded-md border p-2 text-sm text-white">
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor
incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud
exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure
dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.
Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt
mollit anim id est laborum. Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed
do eiusmod tempor incididunt ut labore et dolore magna aliqua.
</ScrollArea>
</div>
</div>
</main>
);
}
const container = document.getElementById('root');
const root = createRoot(container);
root.render(React.createElement(Playground));
-17
View File
@@ -1,17 +0,0 @@
import React from 'react';
import { createRoot } from 'react-dom/client';
import '../tailwind.css';
// component imports
function Viewer() {
return (
<div className="h-full w-full">
<div className="text-3xl"> Viewer </div>
</div>
);
}
const container = document.getElementById('root');
const root = createRoot(container);
root.render(React.createElement(Viewer));
@@ -1,11 +0,0 @@
// src/_prototypes/DataRow/actionOptionsMap.ts
const actionOptionsMap: { [key: string]: string[] } = {
Measurement: ['Rename', 'Lock', 'Delete'],
Segmentation: ['Rename', 'Lock', 'Export', 'Delete'],
'ROI Tools': ['Rename', 'Lock', 'Delete'],
'Organ Segmentation': ['Rename', 'Lock', 'Export', 'Delete'],
// Add more types and their corresponding actions as needed
};
export default actionOptionsMap;
@@ -1,200 +0,0 @@
[
{
"type": "Measurement",
"items": [
{
"id": 1,
"title": "Measurement Label",
"description": "Description for Measurement One.",
"optionalField": "Optional Info 1",
"details": "Data"
},
{
"id": 2,
"title": "Measurement Label",
"description": "Description for Measurement Two.",
"details": "Data"
}
]
},
{
"type": "Segmentation",
"items": [
{
"id": 3,
"title": "Segmentation One",
"colorHex": "#FF5733",
"description": "Description for Segmentation One."
},
{
"id": 4,
"title": "Segmentation Two",
"colorHex": "#FF5733",
"description": "Description for Segmentation Two."
},
{
"id": 5,
"title": "Segmentation Three",
"colorHex": "#FF5733",
"description": "Description for Segmentation Three."
}
]
},
{
"type": "ROI Tools",
"items": [
{
"id": 6,
"title": "Linear",
"description": "Description for Linear.",
"details": "49.2 mm",
"series": "S:2 I:1"
},
{
"id": 7,
"title": "Bidirectional",
"description": "Description for Bidirectional.",
"details": "L: 34.5 mm\nW: 23.0 mm",
"series": "S:2 I:2"
},
{
"id": 8,
"title": "Ellipse",
"description": "Description for Ellipse.",
"details": "2641 mm²\nMax: 1087 HU",
"series": "S:2 I:4"
},
{
"id": 9,
"title": "Rectangle",
"description": "Description for Rectangle.",
"details": "1426 mm²\nMax: 718 HU",
"series": "S:2 I:5"
},
{
"id": 10,
"title": "Circle",
"description": "Description for Circle.",
"details": "7339 mm²\nMax: 871 HU",
"series": "S:2 I:6"
},
{
"id": 11,
"title": "Freehand ROI",
"description": "Description for Freehand ROI.",
"details": "Mean: 215 HU\nMax: 947 HU\nArea: 839 mm²",
"series": "S:2 I:7"
},
{
"id": 12,
"title": "Spline Tool",
"description": "Description for Spline Tool.",
"details": "Area: 203 mm²",
"series": "S:2 I:8"
},
{
"id": 13,
"title": "Livewire Tool",
"description": "Description for Livewire Tool.",
"details": "",
"series": "S:2 I:3"
},
{
"id": 14,
"title": "Annotation Lorem ipsum dolor sit amet long measurement name continues here",
"description": "Description for Annotation.",
"details": "",
"series": "S:2 I:3"
}
]
},
{
"type": "Organ Segmentation",
"items": [
{
"id": 15,
"title": "Spleen",
"description": "Description for Spleen.",
"colorHex": "#6B8E23"
},
{
"id": 16,
"title": "Kidney",
"description": "Description for Kidney.",
"colorHex": "#4682B4"
},
{
"id": 17,
"title": "Kidney very long title name lorem ipsum dolor sit amet segmentation",
"description": "Description for Kidney.",
"colorHex": "#9ACD32"
},
{
"id": 18,
"title": "Gallbladder",
"description": "Description for Gallbladder.",
"colorHex": "#20B2AA"
},
{
"id": 19,
"title": "Esophagus",
"description": "Description for Esophagus.",
"colorHex": "#DAA520"
},
{
"id": 20,
"title": "Liver",
"description": "Description for Liver.",
"colorHex": "#CD5C5C"
},
{
"id": 21,
"title": "Stomach",
"description": "Description for Stomach.",
"colorHex": "#778899"
},
{
"id": 22,
"title": "Abdominal aorta",
"description": "Description for Abdominal Aorta.",
"colorHex": "#B8860B"
},
{
"id": 23,
"title": "Inferior vena cava",
"description": "Description for Inferior Vena Cava.",
"colorHex": "#556B2F"
},
{
"id": 24,
"title": "Portal vein",
"description": "Description for Portal Vein.",
"colorHex": "#8B4513"
},
{
"id": 25,
"title": "Pancreas",
"description": "Description for Pancreas.",
"colorHex": "#2F4F4F"
},
{
"id": 26,
"title": "Adrenal gland",
"description": "Description for Adrenal Gland.",
"colorHex": "#708090"
},
{
"id": 27,
"title": "Adrenal gland",
"description": "Description for Adrenal Gland.",
"colorHex": "#6A5ACD"
},
{
"id": 28,
"title": "New Seg Test New Seg Test New Seg Test New Seg Test New Seg Test New Seg Test ",
"description": "Description for New Seg Test.",
"colorHex": "#4682B4"
}
]
}
]
Whitespace-only changes.
@@ -1,15 +0,0 @@
// src/_prototypes/DataRow/types.ts
export interface DataItem {
id: number;
title: string;
description: string;
optionalField?: string;
colorHex?: string;
details?: string;
}
export interface ListGroup {
type: string;
items: DataItem[];
}
@@ -1,213 +0,0 @@
import React from 'react';
import { Item, VisibilityState, AvailabilityState } from './types';
import { Button } from '../../components/Button'; // Updated import path
interface ItemListProps {
items: Item[];
onSelectItem: (item: Item) => void;
selectedItem: Item | null;
onToggleVisibility: (itemId: number) => void; // Prop for visibility toggle
onAddItem: (itemId: number) => void; // Prop for add button
}
/**
* ItemList Component
*
* Displays a list of items that can be selected, toggled for visibility,
* and added (changing availability).
*
* @param items - Array of items to display.
* @param onSelectItem - Callback when an item is selected.
* @param selectedItem - The currently selected item.
* @param onToggleVisibility - Callback when an item's visibility is toggled.
* @param onAddItem - Callback when an item's availability is changed to 'loaded'.
*/
const ItemList: React.FC<ItemListProps> = ({
items,
onSelectItem,
selectedItem,
onToggleVisibility,
onAddItem,
}) => {
return (
<ul
aria-label="Item List"
className="space-y-1"
>
{items.map(item => (
<li key={item.id}>
<div className="flex items-center">
{/* Conditionally render the Add button for 'available' items */}
{item.availability === 'available' && (
<Button
variant="ghost"
size="icon"
onClick={e => {
e.stopPropagation(); // Prevent parent onClick
onAddItem(item.id);
}}
aria-label={`Add ${item.name}`}
className="ml-1 mr-1"
>
{/* Plus Icon */}
<svg
width="16px"
height="16px"
viewBox="0 0 24 24"
fill="none"
xmlns="http://www.w3.org/2000/svg"
>
<path
d="M12 5V19"
stroke="#348CFD"
strokeWidth="2"
strokeLinecap="round"
strokeLinejoin="round"
/>
<path
d="M5 12H19"
stroke="#348CFD"
strokeWidth="2"
strokeLinecap="round"
strokeLinejoin="round"
/>
</svg>
</Button>
)}
{/* All items are now rendered as clickable rows */}
<button
onClick={() => onSelectItem(item)}
className={`text-foreground flex h-7 w-full flex-grow cursor-pointer items-center justify-between rounded p-1 text-sm ${
item.id === selectedItem?.id ? 'bg-primary/20' : 'bg-muted hover:bg-primary/30'
} focus-visible:ring-ring focus-visible:outline-none focus-visible:ring-1`}
aria-pressed={item.id === selectedItem?.id}
>
<span className="ml-1">{item.name}</span>
{/* Conditionally render the "Available" label for 'available' items */}
{item.availability === 'available' && (
<span className="text-muted-foreground text-xs">Available</span>
)}
{/* Conditionally render the visibility icon for 'loaded' items */}
{item.availability === 'loaded' && (
<Button
variant="ghost"
size="icon"
onClick={e => {
e.stopPropagation(); // Prevent parent onClick
onToggleVisibility(item.id);
}}
aria-label={
item.visibility === 'Visible' ? `Hide ${item.name}` : `Show ${item.name}`
}
>
{item.visibility === 'Visible' ? (
// SVG Icon for "Visible"
<svg
width="24px"
height="24px"
viewBox="0 0 24 24"
>
<g
stroke="none"
strokeWidth="1"
fill="none"
fillRule="evenodd"
>
<rect
x="0"
y="0"
width="24"
height="24"
></rect>
<circle
stroke="#348CFD"
strokeLinecap="round"
strokeLinejoin="round"
cx="12.4986195"
cy="11.8041442"
r="2.58684689"
></circle>
<path
d="M20.906611,11.5617197 C20.0470387,10.5861089 16.6094888,7 12.4986195,7
C8.38775024,7 4.95020027,10.5861089 4.090628,11.5617197
C3.96979067,11.7007491 3.96979067,11.9075393 4.090628,12.0465687
C4.95020027,13.0221796 8.38775024,16.6082885 12.4986195,16.6082885
C16.6094888,16.6082885 20.0470387,13.0221796 20.906611,12.0465687
C21.0274483,11.9075393 21.0274483,11.7007491 20.906611,11.5617197 Z"
stroke="#348CFD"
strokeLinecap="round"
strokeLinejoin="round"
></path>
</g>
</svg>
) : (
// SVG Icon for "Hidden"
<svg
width="24px"
height="24px"
viewBox="0 0 24 24"
>
<g
stroke="none"
strokeWidth="1"
fill="none"
fillRule="evenodd"
>
<path
d="M18.0567826,8.96286957
C19.1471229,9.75269568 20.1356859,10.674229 21,11.7065217
C21,11.7065217 17.1949565,16.5108696 12.5,16.5108696
C11.7479876,16.5066962 11.0007435,16.3911225 10.2826087,16.167913"
stroke="#348CFD"
strokeLinecap="round"
strokeLinejoin="round"
></path>
<path
d="M6.93286957,14.4413043
C5.84666081,13.6535964 4.86162018,12.7350857 4,11.7065217
C4,11.7065217 7.80504348,6.90217391 12.5,6.90217391
C13.1235541,6.90480509 13.7443251,6.98550531 14.3478261,7.1423913"
stroke="#348CFD"
strokeLinecap="round"
strokeLinejoin="round"
></path>
<path
d="M9.54347826,11.7065217
C9.54347826,10.0736799 10.8671581,8.75 12.5,8.75"
stroke="#348CFD"
strokeLinecap="round"
strokeLinejoin="round"
></path>
<path
d="M15.4565217,11.7065217
C15.4565217,13.3393636 14.1328419,14.6630435 12.5,14.6630435"
stroke="#348CFD"
strokeLinecap="round"
strokeLinejoin="round"
></path>
<line
x1="19.7065217"
y1="4.5"
x2="5.29347826"
y2="18.9130435"
stroke="#348CFD"
strokeLinecap="round"
strokeLinejoin="round"
></line>
</g>
</svg>
)}
</Button>
)}
</button>
</div>
</li>
))}
</ul>
);
};
export default ItemList;
@@ -1,331 +0,0 @@
import React, { useState, useEffect } from 'react';
import ItemList from './ItemList';
import PropertiesPanel from './PropertiesPanel';
import { Item, DisplayMode, VisibilityState, AvailabilityState } from './types';
import { ScrollArea } from '../../components/ScrollArea';
const PanelSplit: React.FC = () => {
const [selectedItem, setSelectedItem] = useState<Item | null>(null);
const [items, setItems] = useState<Item[]>([
{
id: 1,
name: 'All Items',
controlsAll: true, // Master item
displayMode: 'Fill & Outline', // Default display mode
visibility: 'Visible', // Default visibility
availability: 'loaded', // Set to 'loaded'
properties: [
{
key: 'opacity',
label: 'Opacity',
type: 'slider',
value: 50,
min: 1,
max: 100,
step: 1,
},
{
key: 'outline',
label: 'Outline',
type: 'slider',
value: 5,
min: 1,
max: 10,
step: 1,
},
{
key: 'displayInactiveSegments',
label: 'Display inactive segments',
type: 'boolean',
value: false,
},
],
},
{
id: 2,
name: 'List item 1',
series: 'Series A',
displayMode: 'Fill & Outline', // Default display mode
visibility: 'Visible', // Default visibility
availability: 'loaded', // Set to 'loaded'
properties: [
{
key: 'opacity',
label: 'Opacity',
type: 'slider',
value: 70,
min: 1,
max: 100,
step: 1,
},
{
key: 'outline',
label: 'Outline',
type: 'slider',
value: 7,
min: 1,
max: 10,
step: 1,
},
],
},
{
id: 3,
name: 'List item 2',
series: 'Series B',
displayMode: 'Fill & Outline', // Default display mode
visibility: 'Visible', // Default visibility
availability: 'loaded', // Set to 'loaded'
properties: [
{
key: 'opacity',
label: 'Opacity',
type: 'slider',
value: 70,
min: 1,
max: 100,
step: 1,
},
{
key: 'outline',
label: 'Outline',
type: 'slider',
value: 7,
min: 1,
max: 10,
step: 1,
},
],
},
{
id: 4,
name: 'List item 3',
series: 'Series C',
displayMode: 'Fill & Outline', // Default display mode
visibility: 'Visible', // Visibility will not be shown initially
availability: 'available', // Set to 'available'
properties: [
{
key: 'opacity',
label: 'Opacity',
type: 'slider',
value: 80,
min: 1,
max: 100,
step: 1,
},
{
key: 'outline',
label: 'Outline',
type: 'slider',
value: 8,
min: 1,
max: 10,
step: 1,
},
],
},
// Add more items as needed
]);
// Set the master item as selected by default on mount
useEffect(() => {
if (items.length > 0 && !selectedItem) {
setSelectedItem(items.find(item => item.controlsAll) || items[0]);
}
}, [items, selectedItem]);
/**
* Handles updating a property's value.
*
* @param itemId - The ID of the item being updated.
* @param propertyKey - The key identifying the property.
* @param newValue - The new value for the property.
*/
const handleUpdateProperty = (itemId: number, propertyKey: string, newValue: any) => {
const masterItem = items.find(item => item.controlsAll);
if (masterItem && itemId === masterItem.id) {
if (propertyKey === 'displayMode') {
// Update displayMode for all items
setItems(prevItems =>
prevItems.map(item => ({
...item,
displayMode: newValue, // Set to the new displayMode
properties: item.properties.map(prop =>
prop.key === propertyKey ? { ...prop, value: newValue } : prop
),
}))
);
// Also update the selectedItem if it's the master
setSelectedItem(prevSelected =>
prevSelected
? {
...prevSelected,
displayMode: newValue,
properties: prevSelected.properties.map(prop =>
prop.key === propertyKey ? { ...prop, value: newValue } : prop
),
}
: prevSelected
);
} else if (propertyKey === 'visibility') {
// Update visibility for all items
setItems(prevItems =>
prevItems.map(item => ({
...item,
visibility: newValue, // Set to the new visibility
}))
);
// Also update the selectedItem if it's the master
setSelectedItem(prevSelected =>
prevSelected
? {
...prevSelected,
visibility: newValue,
}
: prevSelected
);
} else {
// Update other properties for all items
setItems(prevItems =>
prevItems.map(item => ({
...item,
properties: item.properties.map(prop =>
prop.key === propertyKey ? { ...prop, value: newValue } : prop
),
}))
);
// Also update the selectedItem if it's the master
setSelectedItem(prevSelected =>
prevSelected
? {
...prevSelected,
properties: prevSelected.properties.map(prop =>
prop.key === propertyKey ? { ...prop, value: newValue } : prop
),
}
: prevSelected
);
}
} else {
if (propertyKey === 'displayMode') {
// Update displayMode only for the selected item
setItems(prevItems =>
prevItems.map(item => (item.id === itemId ? { ...item, displayMode: newValue } : item))
);
// Update selectedItem
setSelectedItem(prevSelected =>
prevSelected ? { ...prevSelected, displayMode: newValue } : prevSelected
);
} else if (propertyKey === 'visibility') {
// Toggle visibility only for the selected item
setItems(prevItems =>
prevItems.map(item => (item.id === itemId ? { ...item, visibility: newValue } : item))
);
// Update selectedItem
setSelectedItem(prevSelected =>
prevSelected ? { ...prevSelected, visibility: newValue } : prevSelected
);
} else if (propertyKey === 'availability') {
// Update availability only for the selected item
setItems(prevItems =>
prevItems.map(item => (item.id === itemId ? { ...item, availability: newValue } : item))
);
// Update selectedItem
setSelectedItem(prevSelected =>
prevSelected ? { ...prevSelected, availability: newValue } : prevSelected
);
} else {
// Update only the selected item's properties
setItems(prevItems =>
prevItems.map(item =>
item.id === itemId
? {
...item,
properties: item.properties.map(prop =>
prop.key === propertyKey ? { ...prop, value: newValue } : prop
),
}
: item
)
);
// Update selectedItem
setSelectedItem(prevSelected =>
prevSelected
? {
...prevSelected,
properties: prevSelected.properties.map(prop =>
prop.key === propertyKey ? { ...prop, value: newValue } : prop
),
}
: prevSelected
);
}
}
};
/**
* Handles selecting an item from the list.
*
* @param item - The item being selected.
*/
const handleSelectItem = (item: Item) => {
setSelectedItem(item);
};
/**
* Handles toggling the visibility of an item.
*
* @param itemId - The ID of the item being toggled.
*/
const handleToggleVisibility = (itemId: number) => {
const item = items.find(item => item.id === itemId);
if (item) {
const newVisibility: VisibilityState = item.visibility === 'Visible' ? 'Hidden' : 'Visible';
handleUpdateProperty(itemId, 'visibility', newVisibility);
}
};
/**
* Handles adding an item (changing availability from 'available' to 'loaded').
*
* @param itemId - The ID of the item being added.
*/
const handleAddItem = (itemId: number) => {
handleUpdateProperty(itemId, 'availability', 'loaded');
};
return (
<div className="flex h-full w-[262px] flex-col">
{/* Top: List of Selectable Items */}
<ScrollArea className="bg-muted h-[132px] rounded-t border-gray-300 p-1">
<ItemList
items={items}
onSelectItem={handleSelectItem}
selectedItem={selectedItem}
onToggleVisibility={handleToggleVisibility} // Pass the toggle handler
onAddItem={handleAddItem} // Pass the add handler
/>
</ScrollArea>
{/* Bottom: Properties of Selected Item */}
<ScrollArea className="bg-popover max-h-[400px] flex-grow overflow-auto rounded p-1">
<PropertiesPanel
selectedItem={selectedItem}
onUpdateProperty={handleUpdateProperty}
onAddItem={handleAddItem} // Pass the add handler
/>
</ScrollArea>
</div>
);
};
export default PanelSplit;
@@ -1,337 +0,0 @@
import React from 'react';
import { Item, Property, DisplayMode, AvailabilityState } from './types';
import { Label } from '../../components/Label';
import { Slider } from '../../components/Slider';
import { Input } from '../../components/Input';
import { Switch } from '../../components/Switch';
import { Tabs, TabsList, TabsTrigger, TabsContent } from '../../components/Tabs';
import { Button } from '../../components/Button';
interface PropertiesPanelProps {
selectedItem: Item | null;
onUpdateProperty: (itemId: number, propertyKey: string, newValue: any) => void;
onAddItem: (itemId: number) => void; // Prop for adding item
}
/**
* PropertiesPanel Component
*
* Displays and manages the properties of the selected item.
* Renders different content based on the item's availability state.
*
* @param selectedItem - The currently selected item.
* @param onUpdateProperty - Callback to handle property updates.
* @param onAddItem - Callback to handle adding the item.
*/
const PropertiesPanel: React.FC<PropertiesPanelProps> = ({
selectedItem,
onUpdateProperty,
onAddItem,
}) => {
if (!selectedItem) {
return (
<div className="text-gray-500">
<p>No item selected.</p>
</div>
);
}
if (selectedItem.availability === 'available') {
return (
<div className="flex flex-col items-center p-1.5 text-sm">
{/* "Add this item" Button */}
<Button
onClick={() => onAddItem(selectedItem.id)}
className="mb-4 mt-2"
variant="default"
>
Add this item
</Button>
{/* Divider */}
<div className="border-primary/30 mb-2 w-full border-b"></div>
{/* Series Name */}
<div className="text-foreground w-full text-left">
Series: <span className="text-muted-foreground">{selectedItem.series}</span>
</div>
</div>
);
}
if (selectedItem.availability === 'loaded') {
/**
* Handles changes to a property's value.
*
* @param property - The property being updated.
* @param newValue - The new value for the property.
*/
const handleChange = (property: Property, newValue: any) => {
console.log(`Updating property '${property.key}' to`, newValue); // Debug log
onUpdateProperty(selectedItem.id, property.key, newValue);
};
// Determine if the selected item is the master
const isMaster = selectedItem.controlsAll;
/**
* Handles changes to the display mode via Tabs.
*
* @param newDisplayMode - The new display mode selected.
*/
const handleDisplayModeChange = (newDisplayMode: DisplayMode) => {
console.log(`Display mode changed to`, newDisplayMode); // Debug log
onUpdateProperty(selectedItem.id, 'displayMode', newDisplayMode);
};
return (
<div className="p-1.5 text-sm">
<div className="items-top mb-2.5 flex justify-between">
<div className="text-foreground text-sm font-semibold">
Properties <br />
<span className="text-muted-foreground font-normal">{selectedItem.name}</span>
</div>
{/* Tabs component for Outline and Fill control */}
<Tabs
value={selectedItem.displayMode}
onValueChange={handleDisplayModeChange}
className="ml-auto"
>
<TabsList>
<TabsTrigger value="Fill & Outline">
{/* SVG Icon for Fill & Outline */}
<svg
width="18px"
height="18px"
viewBox="0 0 18 18"
>
<g
id="view-outline-fill"
stroke="none"
strokeWidth="1"
fill="none"
fillRule="evenodd"
>
<g id="Group-13">
<rect
id="Rectangle"
x="0"
y="0"
width="18"
height="18"
></rect>
<rect
id="Rectangle"
stroke="#348CFD"
x="1.5"
y="1.5"
width="15"
height="15"
rx="1"
></rect>
<rect
id="Rectangle"
fill="#348CFD"
x="3.5"
y="3.5"
width="11"
height="11"
rx="1"
></rect>
</g>
</g>
</svg>
</TabsTrigger>
<TabsTrigger value="Outline Only">
{/* SVG Icon for Outline Only */}
<svg
width="18px"
height="18px"
viewBox="0 0 18 18"
>
<g
id="view-outline"
stroke="none"
strokeWidth="1"
fill="none"
fillRule="evenodd"
>
<g id="Group-13">
<rect
id="Rectangle"
x="0"
y="0"
width="18"
height="18"
></rect>
<rect
id="Rectangle"
stroke="#348CFD"
x="1.5"
y="1.5"
width="15"
height="15"
rx="1"
></rect>
</g>
</g>
</svg>
</TabsTrigger>
<TabsTrigger value="Fill Only">
{/* SVG Icon for Fill Only */}
<svg
width="18px"
height="18px"
viewBox="0 0 18 18"
>
<g
id="view-fill"
stroke="none"
strokeWidth="1"
fill="none"
fillRule="evenodd"
>
<g id="Group-13">
<rect
id="Rectangle"
x="0"
y="0"
width="18"
height="18"
></rect>
<rect
id="Rectangle"
fill="#348CFD"
x="2"
y="2"
width="14"
height="14"
rx="1"
></rect>
</g>
</g>
</svg>
</TabsTrigger>
</TabsList>
{/* Display dynamic text under the tabs */}
<div className="mt-0">
<TabsContent value="Fill & Outline">
<p className="text-muted-foreground text-xxs text-center">Fill & Outline</p>
</TabsContent>
<TabsContent value="Outline Only">
<p className="text-muted-foreground text-xxs text-center">Outline Only</p>
</TabsContent>
<TabsContent value="Fill Only">
<p className="text-muted-foreground text-xxs text-center">Fill Only</p>
</TabsContent>
</div>
</Tabs>
</div>
{/* Properties List */}
<div className="mb-3 space-y-3">
{selectedItem.properties.map(prop => (
<div
key={prop.key}
className="flex items-center justify-between space-x-4"
>
{/* Label takes up space and doesn't wrap */}
<Label
htmlFor={prop.key}
className="flex-grow whitespace-nowrap"
>
{prop.label}
</Label>
{/* Flex container for input elements, with spacing */}
<div className="flex items-center space-x-3">
{renderPropertyInput(prop, handleChange)}
</div>
</div>
))}
</div>
{/* Conditionally render the details section for non-master items */}
{!isMaster && (
<div className="text-foreground mb-1">
<div className="border-primary/30 mb-2 w-full border-b"></div>
Series: <span className="text-muted-foreground">{selectedItem.series}</span>
</div>
)}
</div>
);
}
// For other availability states, you can add additional conditions if needed
return (
<div className="text-gray-500">
<p>No properties available for the selected item.</p>
</div>
);
};
/**
* Renders the appropriate input component based on the property's type.
*
* @param prop - The property to render.
* @param handleChange - Function to handle value changes.
* @returns JSX Element corresponding to the property type.
*/
const renderPropertyInput = (
prop: Property,
handleChange: (prop: Property, value: any) => void
) => {
switch (prop.type) {
case 'slider':
return (
<>
<Slider
id={prop.key}
value={[prop.value as number]} // Pass as an array for Radix UI Slider
min={prop.min}
max={prop.max}
step={prop.step}
onValueChange={values => {
console.log(`Slider '${prop.key}' changed to`, values[0]); // Debug log
handleChange(prop, values[0]);
}}
className="w-28"
/>
<Input
type="number"
id={prop.key}
value={prop.value as number}
min={prop.min}
max={prop.max}
step={prop.step}
onChange={e => {
const newVal = Number(e.target.value);
console.log(`Input '${prop.key}' changed to`, newVal); // Debug log
handleChange(prop, newVal);
}}
className="w-14"
/>
</>
);
case 'boolean':
return (
<Switch
id={prop.key}
checked={prop.value as boolean}
onCheckedChange={checked => {
console.log(`Switch '${prop.key}' toggled to`, checked); // Debug log
handleChange(prop, checked);
}}
/>
);
// Add more cases if you have other property types
default:
return null;
}
};
export default PropertiesPanel;
@@ -1,7 +0,0 @@
import PanelSplit from './PanelSplit';
import ItemList from './ItemList';
import PropertiesPanel from './PropertiesPanel';
export { default as PanelSplit } from './PanelSplit';
export { default as PropertiesPanel } from './PropertiesPanel';
export { default as ItemList } from './ItemList';
@@ -1,24 +0,0 @@
export interface Property {
key: string;
label: string;
type: 'slider' | 'boolean' | string; // Extend types as needed
value: any;
min?: number;
max?: number;
step?: number;
}
export type DisplayMode = 'Fill & Outline' | 'Outline Only' | 'Fill Only';
export type VisibilityState = 'Visible' | 'Hidden';
export type AvailabilityState = 'loaded' | 'available' | 'not available';
export interface Item {
id: number;
name: string;
controlsAll?: boolean; // Indicates if the item is the master
series?: string; // Optional, only for non-master items
displayMode: DisplayMode; // Existing property for display mode
visibility: VisibilityState; // Existing property for visibility
availability: AvailabilityState; // New property for availability
properties: Property[];
}
@@ -1,2 +1 @@
// src/components/BackgroundColorSelect/index.ts
export { default as BackgroundColorSelect } from './BackgroundColorSelect';
@@ -0,0 +1 @@
export { default as DataRow } from './DataRow';
@@ -1,10 +1,11 @@
import React from 'react';
import { Code } from 'lucide-react';
type IconProps = React.HTMLAttributes<SVGElement>;
export const Icons = {
// Usage example: <Icons.ArrowLeft />
Code: Code,
Add: (props: IconProps) => (
<svg
width="24px"
@@ -19,6 +19,7 @@ const Input = React.forwardRef<HTMLInputElement, InputProps>(
);
}
);
Input.displayName = 'Input';
export { Input };
+10
View File
@@ -23,6 +23,7 @@ import {
DialogTitle,
DialogDescription,
} from './Dialog';
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from './Select';
import { Combobox } from './Combobox';
import { Popover, PopoverContent, PopoverTrigger, PopoverAnchor } from './Popover';
@@ -68,6 +69,8 @@ import {
DropdownMenuRadioGroup,
} from './DropdownMenu';
import { Onboarding } from './Onboarding';
import { BackgroundColorSelect } from './BackgroundColorSelect';
import { DataRow } from './DataRow';
export {
Button,
@@ -147,4 +150,11 @@ export {
DropdownMenuSubTrigger,
DropdownMenuRadioGroup,
Onboarding,
BackgroundColorSelect,
DataRow,
Select,
SelectContent,
SelectItem,
SelectTrigger,
SelectValue,
};
+62
View File
@@ -1,4 +1,5 @@
import {
BackgroundColorSelect,
Button,
buttonVariants,
ThemeWrapper,
@@ -33,7 +34,37 @@ import {
DisplaySetMessageListTooltip,
Toolbox,
ToolboxUI,
ScrollArea,
Label,
Slider,
Input,
Switch,
Checkbox,
Onboarding,
PopoverAnchor,
PopoverContent,
PopoverTrigger,
Select,
SelectTrigger,
SelectContent,
SelectItem,
SelectValue,
DataRow,
DropdownMenu,
DropdownMenuTrigger,
DropdownMenuContent,
DropdownMenuItem,
DropdownMenuCheckboxItem,
DropdownMenuRadioItem,
DropdownMenuLabel,
DropdownMenuSeparator,
DropdownMenuShortcut,
DropdownMenuGroup,
DropdownMenuPortal,
DropdownMenuSub,
DropdownMenuSubContent,
DropdownMenuSubTrigger,
DropdownMenuRadioGroup,
} from './components';
import { useNotification, NotificationProvider } from './contextProviders';
@@ -45,6 +76,7 @@ export {
Command,
Popover,
Combobox,
Checkbox,
buttonVariants,
ThemeWrapper,
Calendar,
@@ -77,5 +109,35 @@ export {
DisplaySetMessageListTooltip,
Toolbox,
ToolboxUI,
ScrollArea,
Label,
Slider,
Input,
Switch,
Onboarding,
PopoverAnchor,
PopoverContent,
PopoverTrigger,
Select,
SelectTrigger,
SelectContent,
SelectItem,
SelectValue,
DataRow,
BackgroundColorSelect,
DropdownMenu,
DropdownMenuTrigger,
DropdownMenuContent,
DropdownMenuItem,
DropdownMenuCheckboxItem,
DropdownMenuRadioItem,
DropdownMenuLabel,
DropdownMenuSeparator,
DropdownMenuShortcut,
DropdownMenuGroup,
DropdownMenuPortal,
DropdownMenuSub,
DropdownMenuSubContent,
DropdownMenuSubTrigger,
DropdownMenuRadioGroup,
};