1
1
import React from "react" ;
2
2
3
-
4
3
// Custom functions
5
4
6
5
import { RepoButton , FilterButton } from "./LbeElements.js" ;
7
6
import Authors from "./Authors.js" ;
8
-
7
+ import ShortenDesc from "../commons/ShortenDesc.js" ;
8
+ import ShortenButtons from "./ShortenButtons.js" ;
9
9
10
10
// Function for single lbe dataset block
11
11
12
- function LbeBlock ( { title, authors, journal, pubyear, linkpub, linkdata, linkcomment, description, lbeState, setLbeState } ) {
13
-
12
+ function LbeBlock ( {
13
+ title,
14
+ authors,
15
+ journal,
16
+ pubyear,
17
+ linkpub,
18
+ linkdata,
19
+ linkcomment,
20
+ description,
21
+ lbeState,
22
+ setLbeState,
23
+ } ) {
14
24
// Extract DOI from link by cutting right of "doi.org"
15
- var doi = linkpub . slice ( linkpub . indexOf ( "doi.org" ) + 8 ) ;
25
+ var doi = linkpub . slice ( linkpub . indexOf ( "doi.org" ) + 8 ) ;
16
26
17
27
// Define set of repos in this dataset
18
- var myRepos = Array . from ( new Set ( linkdata . map ( obj => obj . name ) ) ) . flat ( ) . sort ( ( a , b ) => a . localeCompare ( b , undefined , { sensitivity : 'base' } ) ) ;
28
+ var myRepos = Array . from ( new Set ( linkdata . map ( ( obj ) => obj . name ) ) )
29
+ . flat ( )
30
+ . sort ( ( a , b ) => a . localeCompare ( b , undefined , { sensitivity : "base" } ) ) ;
19
31
20
- return (
32
+ return (
21
33
< div className = "lbe__block" >
22
34
< div className = "lbe__block__header" >
23
- < div className = "lbe__block__header__title" > < h3 > { title } </ h3 > </ div >
24
- < div className = "lbe__block__header__link" > < RepoButton name = "Permalink" url = { "./?doi=" . concat ( doi ) } /> </ div >
35
+ < div className = "lbe__block__header__title" >
36
+ < h3 > { title } </ h3 >
37
+ </ div >
38
+ < div className = "lbe__block__header__link" >
39
+ < RepoButton name = "Permalink" url = { "./?doi=" . concat ( doi ) } />
40
+ </ div >
25
41
</ div >
26
42
27
- < p > < em > < Authors { ...{ authors} } length = { 10 } /> </ em > </ p >
43
+ < p >
44
+ < em >
45
+ < Authors { ...{ authors } } length = { 10 } />
46
+ </ em >
47
+ </ p >
28
48
29
- < p > < em > { journal } </ em > < strong > { pubyear } </ strong > , DOI: < a href = { linkpub } target = "_blank" > { doi } </ a > .</ p >
49
+ < p >
50
+ < em > { journal } </ em > < strong > { pubyear } </ strong > , DOI:{ " " }
51
+ < a href = { linkpub } target = "_blank" >
52
+ { doi }
53
+ </ a >
54
+ .
55
+ </ p >
30
56
31
- < p > { myRepos . map ( ( m , idx ) =>
32
- < FilterButton key = { idx } name = { m } type = "repo" numbered = { false } { ...{ lbeState, setLbeState} } />
33
- ) }
57
+ < p >
58
+ { myRepos . map ( ( m , idx ) => (
59
+ < FilterButton
60
+ key = { idx }
61
+ name = { m }
62
+ type = "repo"
63
+ numbered = { false }
64
+ funnel
65
+ title = { "Filter datasets from " + m }
66
+ { ...{ lbeState, setLbeState } }
67
+ />
68
+ ) ) }
34
69
</ p >
35
70
36
- < details className = "lbe__details" >
37
- < summary > Details</ summary >
38
- < div className = "lbe__details--collapsible" >
39
- < h4 > Description</ h4 >
40
- < p > { description } </ p >
71
+ < hr className = "lbe__block__hr" />
41
72
42
- < h4 > Links to datasets</ h4 >
43
- < p > { linkdata . map ( ( props , idx ) => (
73
+ < details className = "lbe__details" open = { description . length <= 100 } >
74
+ < summary > Description</ summary >
75
+ < p > { description } </ p >
76
+ </ details >
77
+
78
+ < hr className = "lbe__block__hr" />
79
+
80
+ < details className = "lbe__details" open = { linkdata . length <= 3 } >
81
+ < summary > Links to datasets</ summary >
82
+ < p >
83
+ { linkdata . map ( ( props , idx ) => (
44
84
< RepoButton key = { idx } { ...props } />
45
- ) ) } </ p >
46
- < p > < em > { linkcomment } </ em > </ p >
47
- </ div >
85
+ ) ) }
86
+ </ p >
87
+ < p >
88
+ < em > { linkcomment } </ em >
89
+ </ p >
48
90
</ details >
49
91
</ div >
50
- ) ;
92
+ ) ;
51
93
}
52
94
53
-
54
95
// Render LBE entry list
55
96
56
- function LbeBody ( { list, lbeState, setLbeState } ) {
57
- return (
58
- < div className = "lbe__body" >
59
- { list . map ( ( props , idx ) => (
60
- < LbeBlock key = { idx } { ...props } { ...{ lbeState, setLbeState} } />
61
- ) ) }
62
- </ div >
63
- )
97
+ function LbeBody ( { list, lbeState, setLbeState } ) {
98
+ return (
99
+ < div className = "lbe__body" >
100
+ { list . map ( ( props , idx ) => (
101
+ < LbeBlock key = { idx } { ...props } { ...{ lbeState, setLbeState } } />
102
+ ) ) }
103
+ </ div >
104
+ ) ;
64
105
}
65
106
66
- export default LbeBody ;
107
+ export default LbeBody ;
0 commit comments