Skip to content

Commit

Permalink
[pre-commit.ci] auto fixes from pre-commit.com hooks
Browse files Browse the repository at this point in the history
for more information, see https://pre-commit.ci
  • Loading branch information
pre-commit-ci[bot] committed Sep 14, 2023
1 parent 53a345a commit 993b752
Show file tree
Hide file tree
Showing 9 changed files with 141 additions and 142 deletions.
3 changes: 1 addition & 2 deletions taxonium_component/src/Deck.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ function Deck({
[hoverDetails]
);

const { layers, layerFilter, keyStuff,triggerSVGdownload } = useLayers({
const { layers, layerFilter, keyStuff, triggerSVGdownload } = useLayers({
data,
search,
viewState,
Expand Down Expand Up @@ -316,7 +316,6 @@ function Deck({
// of the browser
triggerSVGdownload={triggerSVGdownload}
deckSize={deckSize}

zoomReset={zoomReset}
zoomIncrement={zoomIncrement}
zoomAxis={zoomAxis}
Expand Down
12 changes: 7 additions & 5 deletions taxonium_component/src/components/DeckButtons.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export const DeckButtons = ({
zoomReset,
settings,
deckSize,
triggerSVGdownload
triggerSVGdownload,
}) => {
return (
<div
Expand Down Expand Up @@ -104,10 +104,12 @@ export const DeckButtons = ({
>
<MdOutlineZoomOutMap className="mx-auto w-5 h-5 inline-block " />
</TaxButton>
<SnapshotButton svgFunction={triggerSVGdownload}
pixelFunction={snapshot}
deckSize={deckSize}/>

<SnapshotButton
svgFunction={triggerSVGdownload}
pixelFunction={snapshot}
deckSize={deckSize}
/>

<div className="">
<div>
<TaxButton
Expand Down
2 changes: 0 additions & 2 deletions taxonium_component/src/components/SearchPanel.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -340,9 +340,7 @@ function SearchPanel({
</Select>
</div>
{colorBy.colorByField === "genotype" && (

<div className="space-x-2">

<label className="space-x-2">
<span>Gene</span>
<Select
Expand Down
59 changes: 38 additions & 21 deletions taxonium_component/src/components/SnapshotButton.jsx
Original file line number Diff line number Diff line change
@@ -1,46 +1,63 @@
import React, { useState, Fragment } from 'react';
import { Dialog, Transition } from '@headlessui/react';
import { BiCamera } from 'react-icons/bi';
import TaxButton from './TaxButton';
import React, { useState, Fragment } from "react";
import { Dialog, Transition } from "@headlessui/react";
import { BiCamera } from "react-icons/bi";
import TaxButton from "./TaxButton";

const SnapshotButton = ({svgFunction, pixelFunction, deckSize}) => {
const SnapshotButton = ({ svgFunction, pixelFunction, deckSize }) => {
const [isOpen, setIsOpen] = useState(false);

function snapshot(option) {
if (option === 'pixels') {
if (option === "pixels") {
pixelFunction();
} else if (option === 'SVG') {
} else if (option === "SVG") {
svgFunction(deckSize);
}
setIsOpen(false);
}

return (
<>
<TaxButton
onClick={() => setIsOpen(true)}
title="Take screenshot"
>
<TaxButton onClick={() => setIsOpen(true)} title="Take screenshot">
<BiCamera className="mx-auto w-5 h-5 inline-block" />
</TaxButton>

<Transition.Root show={isOpen} as={Fragment}>
<Dialog as="div" static className="fixed inset-0 z-10 overflow-y-auto" open={isOpen} onClose={setIsOpen}>
<Dialog
as="div"
static
className="fixed inset-0 z-10 overflow-y-auto"
open={isOpen}
onClose={setIsOpen}
>
<div className="min-h-screen px-4 text-center">
<Dialog.Overlay className="fixed inset-0 bg-black opacity-30" />

<span className="inline-block h-screen align-middle" aria-hidden="true">&#8203;</span>


<span
className="inline-block h-screen align-middle"
aria-hidden="true"
>
&#8203;
</span>

<div className="inline-block w-full max-w-md p-6 my-8 overflow-hidden text-left align-middle transition-all transform bg-white shadow-xl rounded-2xl">
<Dialog.Title as="h3" className="text-lg font-medium leading-6 text-gray-900">
<Dialog.Title
as="h3"
className="text-lg font-medium leading-6 text-gray-900"
>
Choose format
</Dialog.Title>

<div className="mt-4">
<button onClick={() => snapshot('pixels')} className="text-blue-600 hover:text-blue-800">
<button
onClick={() => snapshot("pixels")}
className="text-blue-600 hover:text-blue-800"
>
Pixels
</button>
<button onClick={() => snapshot('SVG')} className="ml-4 text-blue-600 hover:text-blue-800">
<button
onClick={() => snapshot("SVG")}
className="ml-4 text-blue-600 hover:text-blue-800"
>
SVG
</button>
</div>
Expand All @@ -50,6 +67,6 @@ const SnapshotButton = ({svgFunction, pixelFunction, deckSize}) => {
</Transition.Root>
</>
);
}
};

export default SnapshotButton;
export default SnapshotButton;
31 changes: 15 additions & 16 deletions taxonium_component/src/components/TaxButton.jsx
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@

const TaxButton = ({ children, onClick, title }) => {
return (
<button
className=" w-12 h-10 bg-gray-100 p-1 rounded border-gray-300 text-gray-700 opacity-70 hover:opacity-100 mr-1 z-50 mt-auto mb-1
return (
<button
className=" w-12 h-10 bg-gray-100 p-1 rounded border-gray-300 text-gray-700 opacity-70 hover:opacity-100 mr-1 z-50 mt-auto mb-1
shadow-md "
onClick={onClick}
title={title}
style={{
pointerEvents: "auto",
}}
>
{children}
</button>
);
};
export default TaxButton;
onClick={onClick}
title={title}
style={{
pointerEvents: "auto",
}}
>
{children}
</button>
);
};

export default TaxButton;
22 changes: 8 additions & 14 deletions taxonium_component/src/hooks/useLayers.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {
ScatterplotLayer,
PolygonLayer,
TextLayer,
SolidPolygonLayer
SolidPolygonLayer,
} from "@deck.gl/layers";

import { useMemo, useCallback } from "react";
Expand Down Expand Up @@ -120,7 +120,6 @@ const useLayers = ({
}
}, [data.base_data, getX]);


const detailed_scatter_data = useMemo(() => {
return detailed_data.nodes.filter(
(node) =>
Expand Down Expand Up @@ -163,7 +162,7 @@ const useLayers = ({
getRadius: 3,
// radius in pixels
// we had to get rid of the below because it was messing up the genotype colours
// getRadius: (d) =>
// getRadius: (d) =>
// getNodeColorField(d, detailed_data) === hoveredKey ? 4 : 3,
getLineColor: [100, 100, 100],
opacity: 0.6,
Expand Down Expand Up @@ -240,14 +239,14 @@ const useLayers = ({
id: "fillin-scatter",
data: minimap_scatter_data,
getFillColor: (d) => toRGB(getNodeColorField(d, base_data)),
}
};

const main_line_layer = {
layerType: "LineLayer",
...line_layer_horiz_common_props,
id: "main-line-horiz",
data: detailed_data.nodes,
}
};

const main_line_layer2 = {
layerType: "LineLayer",
Expand Down Expand Up @@ -404,7 +403,7 @@ const useLayers = ({
};

const minimap_line_horiz = {
layerType: "LineLayer",
layerType: "LineLayer",
id: "minimap-line-horiz",
getPolygonOffset: ({ layerIndex }) => [0, -4000],
data: base_data.nodes,
Expand Down Expand Up @@ -472,9 +471,9 @@ const useLayers = ({

const lineColor = search.getLineColor(i);

return {
return {
layerType: "ScatterplotLayer",

data: data,
id: "main-search-scatter-" + spec.key,
getPosition: (d) => [d[xType], d.y],
Expand Down Expand Up @@ -549,11 +548,9 @@ const useLayers = ({
},
[isCurrentlyOutsideBounds]
);


const processedLayers = layers.map((layer) => {
if (layer.layerType === "ScatterplotLayer") {

return new ScatterplotLayer(layer);
}
if (layer.layerType === "LineLayer") {
Expand All @@ -571,10 +568,7 @@ const useLayers = ({
console.log("could not map layer spec for ", layer);
});

const { triggerSVGdownload} = getSVGfunction(layers,viewState);



const { triggerSVGdownload } = getSVGfunction(layers, viewState);

return { layers: processedLayers, layerFilter, keyStuff, triggerSVGdownload };
};
Expand Down
6 changes: 3 additions & 3 deletions taxonium_component/src/hooks/useTreenomeLayers.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -427,7 +427,7 @@ const useTreenomeLayers = (
};

const dynamic_browser_background_layer = {
layerType :"SolidPolygonLayer",
layerType: "SolidPolygonLayer",
id: "browser-loaded-dynamic-background",
data: dynamic_background_data,
modelMatrix: modelMatrixFixedX,
Expand Down Expand Up @@ -459,7 +459,7 @@ const useTreenomeLayers = (
getPolygonOffset: myGetPolygonOffset,
};

const selected_node_layer = ({
const selected_node_layer = {
layerType: "PolygonLayer",
id: "browser-loaded-selected-node",
data: selected_node_data,
Expand All @@ -472,7 +472,7 @@ const useTreenomeLayers = (
getFillColor: [240, 240, 240],
pickable: false,
getPolygonOffset: myGetPolygonOffset,
});
};
layers.push(browser_background_layer);
layers.push(dynamic_browser_background_sublayer);
layers.push(dynamic_browser_background_layer);
Expand Down
9 changes: 3 additions & 6 deletions taxonium_component/src/stories/Taxonium.stories.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -128,20 +128,17 @@ export const NexusTree = {
},
};





export const JSONLgenetic = {
args: {
sourceData: {
status: "url_supplied",
filename: "https://cov2tree.nyc3.cdn.digitaloceanspaces.com/tfci-taxonium.jsonl.gz",
filename:
"https://cov2tree.nyc3.cdn.digitaloceanspaces.com/tfci-taxonium.jsonl.gz",
filetype: "jsonl",
},
},
parameters: {
// More on how to position stories at: https://storybook.js.org/docs/react/configure/story-layout
layout: "padded",
},
};
};
Loading

0 comments on commit 993b752

Please sign in to comment.