-
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.
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
- Loading branch information
1 parent
a20f794
commit ee15a66
Showing
6 changed files
with
102 additions
and
92 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,46 +1,47 @@ | ||
import React, { useState } from 'react'; | ||
import { SketchPicker } from 'react-color'; | ||
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]}; | ||
const color = { r: list[0], g: list[1], b: list[2] }; | ||
console.log("COLOR", color); | ||
return color; | ||
|
||
}; | ||
|
||
function ColorPicker({ color,setColor }) { | ||
|
||
const rgbColor = listToRgb(color); | ||
function ColorPicker({ color, setColor }) { | ||
const rgbColor = listToRgb(color); | ||
|
||
|
||
const [showPicker, setShowPicker] = useState(false); | ||
const [showPicker, setShowPicker] = useState(false); | ||
|
||
const togglePicker = () => { | ||
setShowPicker(!showPicker); | ||
}; | ||
const togglePicker = () => { | ||
setShowPicker(!showPicker); | ||
}; | ||
|
||
const handleColorChange = (newColor) => { | ||
setColor(rgbToList(newColor.rgb)); | ||
setShowPicker(false); | ||
}; | ||
if(showPicker) return ( | ||
<div className="block mt-2"> | ||
<SketchPicker color={rgbColor} onChange={handleColorChange} /> | ||
</div> | ||
) | ||
const handleColorChange = (newColor) => { | ||
setColor(rgbToList(newColor.rgb)); | ||
setShowPicker(false); | ||
}; | ||
if (showPicker) | ||
return ( | ||
<div className="inline-block mt-2 ml-2"> | ||
<div | ||
className="w-4 h-4 cursor-pointer" | ||
style={{ backgroundColor: `rgba(${rgbColor.r},${rgbColor.g},${rgbColor.b},${rgbColor.a || 1})` }} | ||
onClick={togglePicker} | ||
></div> | ||
|
||
</div> | ||
<div className="block mt-2"> | ||
<SketchPicker color={rgbColor} onChange={handleColorChange} /> | ||
</div> | ||
); | ||
return ( | ||
<div className="inline-block mt-2 ml-2"> | ||
<div | ||
className="w-4 h-4 cursor-pointer" | ||
style={{ | ||
backgroundColor: `rgba(${rgbColor.r},${rgbColor.g},${rgbColor.b},${ | ||
rgbColor.a || 1 | ||
})`, | ||
}} | ||
onClick={togglePicker} | ||
></div> | ||
</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
38 changes: 19 additions & 19 deletions
38
taxonium_component/src/components/SearchDisplayToggle.jsx
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 |
---|---|---|
@@ -1,26 +1,26 @@ | ||
import React from 'react'; | ||
import { toast } from 'react-hot-toast'; | ||
import { FaCircle, FaRegCircle } from 'react-icons/fa'; | ||
import React from "react"; | ||
import { toast } from "react-hot-toast"; | ||
import { FaCircle, FaRegCircle } from "react-icons/fa"; | ||
|
||
const SearchDisplayToggle = ({ settings }) => { | ||
const { displaySearchesAsPoints, setDisplaySearchesAsPoints } = settings; | ||
const toggleDisplay = () => { | ||
// Toggle the displaySearchesAsPoints value | ||
setDisplaySearchesAsPoints(!displaySearchesAsPoints); | ||
const { displaySearchesAsPoints, setDisplaySearchesAsPoints } = settings; | ||
const toggleDisplay = () => { | ||
// Toggle the displaySearchesAsPoints value | ||
setDisplaySearchesAsPoints(!displaySearchesAsPoints); | ||
|
||
// Show a toast message based on the new value | ||
if (!displaySearchesAsPoints) { | ||
toast.success('Displaying searches as points'); | ||
} else { | ||
toast.success('Displaying searches as circles'); | ||
} | ||
}; | ||
// Show a toast message based on the new value | ||
if (!displaySearchesAsPoints) { | ||
toast.success("Displaying searches as points"); | ||
} else { | ||
toast.success("Displaying searches as circles"); | ||
} | ||
}; | ||
|
||
return ( | ||
<button onClick={toggleDisplay} aria-label="Toggle Display Mode"> | ||
{displaySearchesAsPoints ? <FaCircle /> : <FaRegCircle />} | ||
</button> | ||
); | ||
return ( | ||
<button onClick={toggleDisplay} aria-label="Toggle Display Mode"> | ||
{displaySearchesAsPoints ? <FaCircle /> : <FaRegCircle />} | ||
</button> | ||
); | ||
}; | ||
|
||
export default SearchDisplayToggle; |
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