-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Lots of added colour customisability (#519)
Adds the ability to customise the label colors and line colors of the tree using settings. Also adds the ability to display searches as points instead of as circles. Adds the ability to change point colors by clicking on legend Fixes issues with buttons passing events through to deck below.
- Loading branch information
1 parent
941f03a
commit 5dc16ea
Showing
15 changed files
with
561 additions
and
151 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
import React, { useState } from "react"; | ||
import { SketchPicker } from "react-color"; | ||
|
||
const rgbToList = (rgb) => { | ||
return [rgb.r, rgb.g, rgb.b]; | ||
}; | ||
const listToRgb = (list) => { | ||
const color = { r: list[0], g: list[1], b: list[2] }; | ||
return color; | ||
}; | ||
|
||
function ColorPicker({ color, setColor }) { | ||
const rgbColor = listToRgb(color); | ||
const [showPicker, setShowPicker] = useState(false); | ||
|
||
const togglePicker = () => { | ||
setShowPicker(!showPicker); | ||
}; | ||
|
||
const handleClose = () => { | ||
setShowPicker(false); | ||
}; | ||
|
||
const handleColorChange = (newColor) => { | ||
setColor(rgbToList(newColor.rgb)); | ||
}; | ||
|
||
if (!showPicker) { | ||
return ( | ||
<div className="inline-block"> | ||
<div | ||
style={{ | ||
padding: "5px", | ||
background: "#fff", | ||
borderRadius: "1px", | ||
boxShadow: "0 0 0 1px rgba(0,0,0,.1)", | ||
display: "inline-block", | ||
cursor: "pointer", | ||
}} | ||
onClick={togglePicker} | ||
> | ||
<div | ||
style={{ | ||
width: "36px", | ||
height: "14px", | ||
borderRadius: "2px", | ||
background: `rgba(${rgbColor.r},${rgbColor.g},${rgbColor.b},${ | ||
rgbColor.a || 1 | ||
})`, | ||
}} | ||
/> | ||
</div> | ||
</div> | ||
); | ||
} | ||
|
||
return ( | ||
<div | ||
style={{ | ||
position: "absolute", | ||
zIndex: "2", | ||
}} | ||
> | ||
<div | ||
style={{ | ||
position: "fixed", | ||
top: "0px", | ||
right: "0px", | ||
bottom: "0px", | ||
left: "0px", | ||
}} | ||
onClick={handleClose} | ||
/> | ||
<SketchPicker | ||
color={rgbColor} | ||
onChange={handleColorChange} | ||
presetColors={[]} | ||
disableAlpha={true} | ||
/> | ||
</div> | ||
); | ||
} | ||
|
||
export default ColorPicker; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import React from "react"; | ||
import Modal from "react-modal"; | ||
import ColorPicker from "./ColorPicker"; | ||
|
||
const modalStyle = { | ||
content: { | ||
top: "50%", | ||
left: "50%", | ||
transform: "translate(-50%, -50%)", | ||
backgroundColor: "#fafafa", | ||
border: "1px solid #e2e8f0", | ||
borderRadius: "8px", | ||
padding: "20px", | ||
maxWidth: "400px", | ||
}, | ||
overlay: { | ||
backgroundColor: "rgba(100, 100, 100, 0.3)", | ||
zIndex: 1000, | ||
}, | ||
}; | ||
|
||
const ColorSettingModal = ({ isOpen, setIsOpen, color, setColor, title }) => { | ||
return ( | ||
<Modal | ||
isOpen={isOpen} | ||
style={modalStyle} | ||
onRequestClose={() => setIsOpen(false)} | ||
contentLabel={title} | ||
> | ||
<h2 className="font-medium mb-5 text-lg">{title}</h2> | ||
|
||
<div className="space-y-3"> | ||
<div> | ||
<label> | ||
Select Color: | ||
<ColorPicker color={color} setColor={setColor} /> | ||
</label> | ||
</div> | ||
</div> | ||
</Modal> | ||
); | ||
}; | ||
|
||
export default ColorSettingModal; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
5dc16ea
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.
Successfully deployed to the following URLs:
cov2tree – ./
cov2tree.org
taxodium.org
taxonium.org
mpx.taxonium.org
vbigtree.vercel.app
www.taxodium.org
visualtreeoflife.taxonium.org
www.cov2tree.org
www.taxonium.org
taxonomy.taxonium.org
cov2tree-theosanderson.vercel.app
cov2tree-git-master-theosanderson.vercel.app