-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #86 from enjalot/full-screen-merge
Full screen explore redesign
- Loading branch information
Showing
25 changed files
with
1,540 additions
and
462 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,88 +1,61 @@ | ||
import React from 'react'; | ||
|
||
export default function ClusterFilter({ | ||
clusterLabels, | ||
slide, | ||
slideAnnotations, | ||
setSlide, | ||
clusterLabel, | ||
setClusterLabel, | ||
handleLabelUpdate, | ||
newClusterLabel, | ||
setNewClusterLabel, | ||
handleNewCluster | ||
setFilteredIndices, | ||
clusterLabels, | ||
cluster, | ||
clusterIndices, | ||
setCluster, | ||
}) { | ||
const handleSlideChange = (e) => { | ||
if (e.target.value === "-1") { | ||
setSlide(null); | ||
return; | ||
} | ||
const cl = clusterLabels.find((cluster) => cluster.cluster === +e.target.value); | ||
if (cl) setSlide(cl); | ||
}; | ||
const handleClusterChange = (e) => { | ||
if (e.target.value === '-1') { | ||
setCluster(null); | ||
return; | ||
} | ||
const cl = clusterLabels.find((cluster) => cluster.cluster === +e.target.value); | ||
if (cl) setCluster(cl); | ||
}; | ||
|
||
const handleUpdateLabelSubmit = (e) => { | ||
e.preventDefault(); | ||
handleLabelUpdate(slide.cluster, clusterLabel); | ||
}; | ||
|
||
const handleNewLabelSubmit = (e) => { | ||
e.preventDefault(); | ||
const formData = new FormData(e.target); | ||
const newLabel = formData.get("new-label"); | ||
console.log("new label", newLabel); | ||
handleNewCluster(newLabel); | ||
}; | ||
|
||
return ( | ||
<div className={`clusters-select filter-row ${slideAnnotations.length ? "active" : ""}`}> | ||
<div className="filter-cell left"> | ||
<select onChange={handleSlideChange} value={slide?.cluster >= 0 ? slide.cluster : -1}> | ||
<option value="-1">Filter by cluster</option> | ||
{clusterLabels?.map((cluster, index) => ( | ||
<option key={index} value={cluster.cluster}> | ||
{cluster.cluster}: {cluster.label} | ||
</option> | ||
))} | ||
</select> | ||
</div> | ||
<div className="filter-cell middle"> | ||
{slideAnnotations.length ? ( | ||
<span> | ||
{slideAnnotations.length} rows | ||
<button className="deselect" onClick={() => setSlide(null)}> | ||
X | ||
</button> | ||
</span> | ||
) : null} | ||
</div> | ||
<div className="filter-cell right"> | ||
{slide ? ( | ||
<form onSubmit={handleUpdateLabelSubmit}> | ||
<input | ||
className="update-cluster-label" | ||
type="text" | ||
id="update-label" | ||
value={clusterLabel} | ||
onChange={(e) => setClusterLabel(e.target.value)} | ||
/> | ||
<button type="submit">✍️</button> | ||
</form> | ||
) : ( | ||
<form onSubmit={handleNewLabelSubmit}> | ||
<input | ||
type="text" | ||
id="new-label" | ||
name="new-label" | ||
className="new-cluster-label" | ||
value={newClusterLabel} | ||
onChange={(e) => setNewClusterLabel(e.target.value)} | ||
placeholder="New Cluster" | ||
/> | ||
<button type="submit">➕️ Cluster</button> | ||
</form> | ||
)} | ||
</div> | ||
</div> | ||
); | ||
return ( | ||
<div className={`clusters-select filter-row ${clusterIndices?.length ? 'active' : ''}`}> | ||
<div className="filter-cell left"> | ||
<select onChange={handleClusterChange} value={cluster?.cluster >= 0 ? cluster.cluster : -1}> | ||
<option value="-1">Filter by cluster</option> | ||
{clusterLabels?.map((cluster, index) => ( | ||
<option key={index} value={cluster.cluster}> | ||
{cluster.cluster}: {cluster.label} | ||
</option> | ||
))} | ||
</select> | ||
</div> | ||
<div className="filter-cell middle"> | ||
{clusterIndices?.length ? ( | ||
<span> | ||
{clusterIndices.length} rows | ||
<button | ||
className="deselect" | ||
onClick={() => { | ||
setCluster(null); | ||
setFilteredIndices([]); | ||
}} | ||
> | ||
X | ||
</button> | ||
</span> | ||
) : ( | ||
<span> | ||
0 rows | ||
<button | ||
style={{ visibility: 'hidden' }} | ||
className="deselect" | ||
disabled | ||
onClick={() => setCluster(null)} | ||
> | ||
X | ||
</button> | ||
</span> | ||
)} | ||
</div> | ||
</div> | ||
); | ||
} |
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,47 @@ | ||
.filter-actions-container { | ||
display: flex; | ||
flex-direction: row; | ||
gap: .5rem; | ||
} | ||
|
||
.filter-actions-row { | ||
display: flex; | ||
flex-direction: row; | ||
gap: 0.5rem; | ||
margin-top: 0.5rem; | ||
} | ||
|
||
.filter-actions-button { | ||
border-radius: 4px !important; | ||
padding: 0.25rem 0.5rem !important; | ||
font-size: 0.875rem !important; | ||
} | ||
|
||
.filter-actions-button.active { | ||
background-color: var(--interactions---primary-color-interaction-primary) !important; | ||
color: white !important; | ||
} | ||
|
||
.filter-actions-button:focus { | ||
outline: none !important; | ||
} | ||
|
||
.filter-actions-button.not-active { | ||
background-color: transparent !important; | ||
color: var(--text-color-text-primary) !important; | ||
opacity: 0.75; | ||
} | ||
|
||
.filter-actions-button:hover { | ||
background-color: var(--interactions---primary-color-interaction-primary-hover) !important; | ||
} | ||
|
||
.filter-actions-button.active { | ||
background-color: var(--interactions---primary-color-interaction-primary-active); | ||
} | ||
|
||
@media (prefers-color-scheme: dark) { | ||
.filter-actions-button { | ||
border: .5px solid var(--neutrals-color-neutral-3) !important; | ||
} | ||
} |
Oops, something went wrong.