Skip to content

Commit

Permalink
make layers work again
Browse files Browse the repository at this point in the history
  • Loading branch information
TheMooseman committed Jan 6, 2025
1 parent 31b7d09 commit bdd3856
Show file tree
Hide file tree
Showing 5 changed files with 1,297 additions and 1,658 deletions.
5 changes: 1 addition & 4 deletions examples/src/app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,7 @@ export function App() {
path="/omezarr"
element={<OmezarrDemo />}
/>
{/* <Route
path="/layers"
element={<LayersDemo />}
/> */}
<Route path="/layers" />
</Routes>
</BrowserRouter>
);
Expand Down
6 changes: 2 additions & 4 deletions examples/src/home.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,10 @@ export function Home() {
<a href="/omezarr">OMEZARR</a>
<br />
</li>
{/* layers is not in the AC to be converted to a react component
maybe we'll convert it at some point though so I'll leave this here
<li>
<li>
<a href="/layers">Layers</a>
<br />
</li> */}
</li>
</ul>
</>
);
Expand Down
2 changes: 1 addition & 1 deletion examples/src/layers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import {
} from './data-sources/scatterplot/dynamic-grid';
import type { OptionalTransform } from './data-sources/types';
import type { CacheEntry, AnnotationLayer, Layer } from './types';
import { AppUi } from './app';
import { AppUi } from './layers/app';
import { createRoot } from 'react-dom/client';
import {
createZarrSliceGrid,
Expand Down
58 changes: 58 additions & 0 deletions examples/src/layers/app.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
import React from 'react';
import { SliceViewLayer } from '../ui/slice-ui';
import type { Demo } from '../layers';
import { AnnotationGrid } from '../ui/annotation-grid';
import { ContactSheetUI } from '../ui/contact-sheet';
import { ScatterplotUI } from '../ui/scatterplot-ui';
import { Button } from '@czi-sds/components';

export function AppUi(props: { demo: Demo }) {
const { demo } = props;
return (
<div>
<Button
onClick={() => {
demo.requestSnapshot(3000);
}}
>
{'📷'}
</Button>
<label>{`Layer ${demo.selectedLayer}`}</label>
<Button
onClick={() => {
demo.selectLayer(demo.selectedLayer - 1);
}}
>
{'<-'}
</Button>
<Button
onClick={() => {
demo.selectLayer(demo.selectedLayer + 1);
}}
>
{'->'}
</Button>
<LayerUi demo={demo} />
</div>
);
}
function LayerUi(props: { demo: Demo }) {
const { demo } = props;
const layer = demo.layers[demo.selectedLayer];
if (layer) {
switch (layer.type) {
case 'annotationGrid':
return <AnnotationGrid demo={demo} />;
case 'volumeGrid':
return <ContactSheetUI demo={demo} />;
case 'volumeSlice':
return <SliceViewLayer demo={demo} />;
case 'scatterplot':
case 'scatterplotGrid':
return <ScatterplotUI demo={demo} />;
default:
return null;
}
}
return <SliceViewLayer demo={props.demo} />;
}
Loading

0 comments on commit bdd3856

Please sign in to comment.