-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: React Examples Components (DT-7024) #49
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Routing works! Let's get the Layers app showing too, since that's an important one.
There is a type error that keeps Vite from building, easy fix though.
I'll poke at this again once it's fully baked!
examples/src/home.tsx
Outdated
<a href="/omezarr">OMEZARR</a> | ||
<br /> | ||
</li> | ||
{/* layers is not in the AC to be converted to a react component |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's at least let it render like it was, since there's a good Markdown page explaining how to use it in the docs still so we want it working.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you remove examples/public/layers.html
? Only examples/layers.html
is needed.
Looking great, everything works! The demos don't render until you interact with the page, like a scroll event, and then they pop up. That would be nice to fix, or we can add a message on the screen for now.
camera={{ ...exampleSettings.camera, view }} | ||
wheel={zoom} | ||
/> | ||
<div style={{ display: 'flex', flexDirection: 'row' }}> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you add some text to the page encouraging users to scroll to get the demos to appear? Alternatively, we figure out why it takes interaction to make these show up properly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In bkp we solve that problem with an "onComplete" callback with a hook, but lets wait to look into this deeper in another ticket
examples/src/dzi/dzi-viewer.tsx
Outdated
@@ -63,6 +56,7 @@ export function DziView(props: Props) { | |||
} | |||
return () => { | |||
if (cnvs.current) { | |||
// eslint-disable-next-line react-hooks/exhaustive-deps |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is out of place? This isn't disabling the useEffect
dependency lint issues. We also still need to actually integrate a linter soon 😅
}; | ||
|
||
return omezarr && settings ? ( | ||
<RenderServerProvider> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This might be why the omezarr demo requires interaction like a scroll to show up. Always return the provider, then do the ternary inside it as children
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
that fixes it, yep!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
examples/src/layers/examples.ts
Outdated
const colorByGene: ColumnRequest = { name: '88', type: 'QUANTITATIVE' }; | ||
const scottpoc = 'https://tissuecyte-ome-zarr-poc.s3.amazonaws.com/40_128_128/1145081396'; | ||
|
||
export const examples: Record<string, any> = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
export const examples: Record<string, any> = { | |
export const examples = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
dont erase types with any...
examples/src/layers/examples.ts
Outdated
plane: 'xy', | ||
slices: 4, | ||
} as ZarrSliceGridConfig, | ||
['structureAnnotation']: { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what happened here? why do these all have [' '] wrappings?
whats wrong with structureAnnotation: {...}
examples/src/dzi/use-dzi-image.ts
Outdated
onComplete?: (imgSize: vec2) => void; | ||
} | ||
|
||
function decodeDzi(s: string, url: string): DziImage | undefined { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is is a nice-ish function that shows how to decode the dzi xml/json metadata "format".
I think you should add some documentation, and maybe clean up or explain the url.split('.dzi') stuff
examples/src/dzi/use-dzi-image.ts
Outdated
callback(images); | ||
} | ||
|
||
export function useDziImages({ imageUrls, onComplete }: useDziImageProps) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
useDziImages and getImages are unused, stateful, clunky - lets remove them?
const size = sizeInUnits('xy', v.multiscales[0].axes, v.multiscales[0].datasets[0]); | ||
if (size) { | ||
console.log(size); | ||
setView(Box2D.create([0, 0], [size[0], size[1]])); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
setView(Box2D.create([0, 0], [size[0], size[1]])); | |
setView(Box2D.create([0, 0], size)); |
* @param {string} name - name will show up in console log | ||
* @param {Object} props - entire props object of the component being tested | ||
*/ | ||
export function useWhyDidYouUpdate<P extends object>(name: string, props: P) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove this file?
examples/src/layers/examples.ts
Outdated
import type { ZarrSliceGridConfig } from '~/data-sources/ome-zarr/slice-grid'; | ||
import type { ScatterplotGridConfig, ScatterPlotGridSlideConfig } from '~/data-sources/scatterplot/dynamic-grid'; | ||
|
||
const slide32 = 'MQ1B9QBZFIPXQO6PETJ'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok this whole file is unused - it was nice that it was pulled out of the code for the layers example logic, but the types got a bit messed up.
either fix the types and use it, or delete it and keep the actual values on line 745 of src/layers.ts
@@ -61,6 +61,7 @@ | |||
"lodash": "^4.17.21", | |||
"react": "^18.3.0", | |||
"react-dom": "^18.3.0", | |||
"react-router": "^7.0.2", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
are a handful of static, independant pages worth pulling in this dependency?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suppose it does let us delete the kinda gross repetetative {demo-name.html} files....
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lets keep it, seems fine
}); | ||
}, []); | ||
|
||
const zoom = (e: WheelEvent) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought part of the improvements we were going to add was around the cameras - currently the dzi demo cant pan, only zoom. Perhaps we could consolidate their zoom and pan handlers and have both working on both?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I made simple functions for zoom and pan rather than wrap it in a hook just so it's more transparent for anyone reading the examples. I think it's easier to understand but I can move them into separate hooks if you think that's better.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not asking for hooks...
one of the learnings from integrating these components was that the hard-coded cameras in different spaces was confusing. My ask here is that you share the zoom & pan interactions (event handlers) between the two components, if possible.
right now, the dzi and omezarr components have different capabilities, but there is no reason for that to be the case, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cleanup please, consider camera event handing consolidation
examples/src/dzi/decode-dzi.ts
Outdated
// At the end of the file you can see two examples of the metadata format you might see, one as XML and another as JSON | ||
/** | ||
* This function helps decode xml metadata for a dzi file. | ||
* @param s xml string |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
* @param s xml string | |
* @param s the contents of the @param url - expected to be an XML document describing a DZI image |
examples/src/common/camera.ts
Outdated
* @param view your current view | ||
* @param screenSize the size of your canvas/screen | ||
* @param zoomScale the scale you want to apply to your view | ||
* @param mousePos the offsetX and offsetY of your mouse |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
none of these comments are helpful are they?
a parameter named screenSize is obviously the size of the screen - maybe give the units?
mousePos - is this in pixels, or the data space?
view - what is this? obviously its the current view. this is a box, in dataspace, that gets mapped to the screen or canvas.
examples/src/common/camera.ts
Outdated
* @param zoomScale the scale you want to apply to your view | ||
* @param mousePos the offsetX and offsetY of your mouse | ||
*/ | ||
export function zoom(view: box2D, screenSize: vec2, zoomScale: number, mousePos: vec2) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
other than the unhelpful docs, these are excellent - thanks for unifying the camera logic!
return undefined; | ||
} | ||
|
||
/* Example XML |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is looking good, thanks for the cleanup. Since these are examples for others to follow, could you spend some time on the javadoc to explain things? "@param view the current view" is not helping anyone
What
Create react components for our examples(excluding layers).
How
PR Checklist
main
?