-
Notifications
You must be signed in to change notification settings - Fork 28
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 #394 from tilfischer/main
feat: lbe details open by default
- Loading branch information
Showing
7 changed files
with
385 additions
and
149 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 |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import React, { useState } from "react"; | ||
|
||
// shorten the description of the experiment up to the next blank, comma or period after 100 characters | ||
|
||
function ShortenDesc({ desc, length }) { | ||
const [collapsed, setCollapsed] = useState(true); | ||
|
||
if (desc.length <= length) { | ||
return <React.Fragment>{desc}</React.Fragment>; | ||
} | ||
|
||
return ( | ||
<React.Fragment> | ||
{collapsed ? ( | ||
<span | ||
title={desc} | ||
onClick={() => setCollapsed(!collapsed)} | ||
style={{ cursor: "pointer" }} | ||
> | ||
{desc.slice(0, length) + | ||
desc.slice(length).split(/[\s,\.]/)[0] + | ||
" ..."} | ||
|
||
<button className="lbe__block__author-trigger"> | ||
expand ▼ | ||
</button> | ||
</span> | ||
) : ( | ||
<span | ||
onClick={() => setCollapsed(!collapsed)} | ||
style={{ cursor: "pointer" }} | ||
> | ||
{desc} | ||
<button className="lbe__block__author-trigger"> | ||
collapse ▲ | ||
</button> | ||
</span> | ||
)} | ||
</React.Fragment> | ||
); | ||
} | ||
|
||
export default ShortenDesc; |
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,33 +1,78 @@ | ||
import React from "react"; | ||
|
||
|
||
// Custom functions | ||
|
||
import { TextSearch, FilterButton } from "./LbeElements.js"; | ||
|
||
|
||
// Assemble buttons for filtering section | ||
|
||
function LbeButtons( {repos, subdiscs, journals, lbeState, setLbeState} ) { | ||
return( | ||
<React.Fragment> | ||
<div className="lbe__searchfilter__section"><h4>Filter by repositories</h4><p>{repos.map((props, idx) => <FilterButton key={idx} name={props} type="repo" numbered={true} {...{lbeState, setLbeState}} />)}</p></div> | ||
<div className="lbe__searchfilter__section"><h4>Filter by subdisciplines</h4><p>{subdiscs.map((props, idx) => <FilterButton key={idx} name={props} type="subd" numbered={true} {...{lbeState, setLbeState}} />)}</p></div> | ||
<div className="lbe__searchfilter__section"><h4>Filter by journals</h4><p>{journals.map((props, idx) => <FilterButton key={idx} name={props} type="journal" numbered={true} {...{lbeState, setLbeState}} />)}</p></div> | ||
</React.Fragment> | ||
) | ||
function LbeButtons({ repos, subdiscs, journals, lbeState, setLbeState }) { | ||
return ( | ||
<React.Fragment> | ||
<div className="lbe__searchfilter__section"> | ||
<h4>Filter by repositories</h4> | ||
<p> | ||
{repos.map((props, idx) => ( | ||
<FilterButton | ||
key={idx} | ||
name={props} | ||
type="repo" | ||
numbered={true} | ||
{...{ lbeState, setLbeState }} | ||
/> | ||
))} | ||
</p> | ||
</div> | ||
<div className="lbe__searchfilter__section"> | ||
<h4>Filter by subdisciplines</h4> | ||
<p> | ||
{subdiscs.map((props, idx) => ( | ||
<FilterButton | ||
key={idx} | ||
name={props} | ||
type="subd" | ||
numbered={true} | ||
{...{ lbeState, setLbeState }} | ||
/> | ||
))} | ||
</p> | ||
</div> | ||
<div className="lbe__searchfilter__section"> | ||
<h4>Filter by journals</h4> | ||
<p> | ||
{journals.map((props, idx) => ( | ||
<FilterButton | ||
key={idx} | ||
name={props} | ||
type="journal" | ||
numbered={true} | ||
{...{ lbeState, setLbeState }} | ||
/> | ||
))} | ||
</p> | ||
</div> | ||
</React.Fragment> | ||
); | ||
} | ||
|
||
function FilterSection( {repos, subdiscs, journals, lbeState, setLbeState, resultOutput} ) { | ||
|
||
return( | ||
<div className="lbe__searchfilter"> | ||
<div className="lbe__searchfilter__container"> | ||
<TextSearch {...{lbeState,setLbeState,resultOutput}} /> | ||
<LbeButtons {...{repos, subdiscs, journals, lbeState, setLbeState}} /> | ||
</div> | ||
</div> | ||
) | ||
function FilterSection({ | ||
repos, | ||
subdiscs, | ||
journals, | ||
lbeState, | ||
setLbeState, | ||
resultOutput, | ||
}) { | ||
return ( | ||
<div className="lbe__searchfilter"> | ||
<div className="lbe__searchfilter__container"> | ||
<TextSearch {...{ lbeState, setLbeState, resultOutput }} /> | ||
<LbeButtons | ||
{...{ repos, subdiscs, journals, lbeState, setLbeState }} | ||
/> | ||
</div> | ||
</div> | ||
); | ||
} | ||
|
||
export default FilterSection; | ||
export default FilterSection; |
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,66 +1,107 @@ | ||
import React from "react"; | ||
|
||
|
||
// Custom functions | ||
|
||
import { RepoButton, FilterButton } from "./LbeElements.js"; | ||
import Authors from "./Authors.js"; | ||
|
||
import ShortenDesc from "../commons/ShortenDesc.js"; | ||
import ShortenButtons from "./ShortenButtons.js"; | ||
|
||
// Function for single lbe dataset block | ||
|
||
function LbeBlock( { title, authors, journal, pubyear, linkpub, linkdata, linkcomment, description, lbeState, setLbeState } ) { | ||
|
||
function LbeBlock({ | ||
title, | ||
authors, | ||
journal, | ||
pubyear, | ||
linkpub, | ||
linkdata, | ||
linkcomment, | ||
description, | ||
lbeState, | ||
setLbeState, | ||
}) { | ||
// Extract DOI from link by cutting right of "doi.org" | ||
var doi = linkpub.slice(linkpub.indexOf("doi.org")+8); | ||
var doi = linkpub.slice(linkpub.indexOf("doi.org") + 8); | ||
|
||
// Define set of repos in this dataset | ||
var myRepos = Array.from(new Set(linkdata.map(obj => obj.name))).flat().sort((a, b) => a.localeCompare(b, undefined, {sensitivity: 'base'})); | ||
var myRepos = Array.from(new Set(linkdata.map((obj) => obj.name))) | ||
.flat() | ||
.sort((a, b) => a.localeCompare(b, undefined, { sensitivity: "base" })); | ||
|
||
return ( | ||
return ( | ||
<div className="lbe__block"> | ||
<div className="lbe__block__header"> | ||
<div className="lbe__block__header__title"><h3>{title}</h3></div> | ||
<div className="lbe__block__header__link"><RepoButton name="Permalink" url={"./?doi=".concat(doi)} /></div> | ||
<div className="lbe__block__header__title"> | ||
<h3>{title}</h3> | ||
</div> | ||
<div className="lbe__block__header__link"> | ||
<RepoButton name="Permalink" url={"./?doi=".concat(doi)} /> | ||
</div> | ||
</div> | ||
|
||
<p><em><Authors {...{authors}} length={10} /></em></p> | ||
<p> | ||
<em> | ||
<Authors {...{ authors }} length={10} /> | ||
</em> | ||
</p> | ||
|
||
<p><em>{journal}</em> <strong>{pubyear}</strong>, DOI: <a href={linkpub} target="_blank">{doi}</a>.</p> | ||
<p> | ||
<em>{journal}</em> <strong>{pubyear}</strong>, DOI:{" "} | ||
<a href={linkpub} target="_blank"> | ||
{doi} | ||
</a> | ||
. | ||
</p> | ||
|
||
<p>{myRepos.map((m,idx) => | ||
<FilterButton key={idx} name={m} type="repo" numbered={false} {...{lbeState, setLbeState}} /> | ||
)} | ||
<p> | ||
{myRepos.map((m, idx) => ( | ||
<FilterButton | ||
key={idx} | ||
name={m} | ||
type="repo" | ||
numbered={false} | ||
funnel | ||
title={"Filter datasets from " + m} | ||
{...{ lbeState, setLbeState }} | ||
/> | ||
))} | ||
</p> | ||
|
||
<details className="lbe__details"> | ||
<summary>Details</summary> | ||
<div className="lbe__details--collapsible"> | ||
<h4>Description</h4> | ||
<p>{description}</p> | ||
<hr className="lbe__block__hr" /> | ||
|
||
<h4>Links to datasets</h4> | ||
<p>{linkdata.map((props, idx) => ( | ||
<details className="lbe__details" open={description.length <= 100}> | ||
<summary>Description</summary> | ||
<p>{description}</p> | ||
</details> | ||
|
||
<hr className="lbe__block__hr" /> | ||
|
||
<details className="lbe__details" open={linkdata.length <= 3}> | ||
<summary>Links to datasets</summary> | ||
<p> | ||
{linkdata.map((props, idx) => ( | ||
<RepoButton key={idx} {...props} /> | ||
))}</p> | ||
<p><em>{linkcomment}</em></p> | ||
</div> | ||
))} | ||
</p> | ||
<p> | ||
<em>{linkcomment}</em> | ||
</p> | ||
</details> | ||
</div> | ||
); | ||
); | ||
} | ||
|
||
|
||
// Render LBE entry list | ||
|
||
function LbeBody( { list, lbeState, setLbeState } ) { | ||
return( | ||
<div className="lbe__body"> | ||
{list.map((props, idx) => ( | ||
<LbeBlock key={idx} {...props} {...{lbeState, setLbeState}} /> | ||
))} | ||
</div> | ||
) | ||
function LbeBody({ list, lbeState, setLbeState }) { | ||
return ( | ||
<div className="lbe__body"> | ||
{list.map((props, idx) => ( | ||
<LbeBlock key={idx} {...props} {...{ lbeState, setLbeState }} /> | ||
))} | ||
</div> | ||
); | ||
} | ||
|
||
export default LbeBody; | ||
export default LbeBody; |
Oops, something went wrong.