-
Notifications
You must be signed in to change notification settings - Fork 11
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 #1355 from concord-consortium/188117039-split-out-…
…collections-in-search feat: Display collections in search results [PT-188117039]
- Loading branch information
Showing
5 changed files
with
140 additions
and
14 deletions.
There are no files selected for viewing
32 changes: 32 additions & 0 deletions
32
rails/react-components/src/library/components/collections.scss
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,32 @@ | ||
@import '../../shared/styles/variables/_variables.scss'; | ||
|
||
.finderResultsCollections { | ||
margin-bottom: 30px; | ||
|
||
.finderResultsCollectionsHeader { | ||
margin-bottom: 10px; | ||
|
||
.finderResultsCollectionsCount { | ||
display: flex; | ||
justify-content: space-between; | ||
} | ||
} | ||
|
||
.findResultsCollectionsShowMore { | ||
display: flex; | ||
justify-content: center; | ||
|
||
button { | ||
background: $col-blue; | ||
color: $white; | ||
padding: 6px 20px; | ||
display: inline-block; | ||
border-radius: 4px; | ||
font-weight: bold; | ||
|
||
&:hover, &:active { | ||
background: #ffc321; | ||
} | ||
} | ||
} | ||
} |
58 changes: 58 additions & 0 deletions
58
rails/react-components/src/library/components/collections.tsx
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,58 @@ | ||
import React from "react"; | ||
import StemFinderResult from "./stem-finder-result"; | ||
import pluralize from "../helpers/pluralize"; | ||
|
||
import css from "./collections.scss"; | ||
|
||
interface Props { | ||
collections: any[] | ||
numTotalCollections: number; | ||
} | ||
|
||
interface State { | ||
showAll: boolean; | ||
} | ||
|
||
const initialDisplayCount = 2; | ||
|
||
export default class Collections extends React.Component<Props, State> { | ||
constructor (props: Props) { | ||
super(props); | ||
|
||
this.state = { | ||
showAll: false | ||
}; | ||
} | ||
|
||
handleShowMore = () => { | ||
this.setState({showAll: true}); | ||
}; | ||
|
||
render () { | ||
const { showAll } = this.state; | ||
const { collections, numTotalCollections } = this.props; | ||
const displayCount = showAll ? numTotalCollections : initialDisplayCount; | ||
const showingAll = showAll || displayCount >= numTotalCollections; | ||
const collectionCount = showingAll ? numTotalCollections : displayCount + " of " + numTotalCollections; | ||
const displayCollections = collections.slice(0, displayCount); | ||
|
||
return ( | ||
<div className={css.finderResultsCollections}> | ||
<div className={css.finderResultsCollectionsHeader}> | ||
<h2>Collections</h2> | ||
<div className={css.finderResultsCollectionsCount}> | ||
<div> | ||
Showing <strong>{ collectionCount + " " + pluralize(collectionCount, "Collection", "Collections") }</strong> matching your search | ||
</div> | ||
</div> | ||
</div> | ||
<div className={css.finderResultsContainer}> | ||
{ displayCollections.map((collection: any, index: any) => { | ||
return <StemFinderResult key={`${collection.external_url}-${index}`} resource={collection} index={index} opacity={1} />; | ||
}) } | ||
</div> | ||
{!showingAll && <div className={css.findResultsCollectionsShowMore}><button onClick={this.handleShowMore}>Show More</button></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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -230,7 +230,7 @@ | |
} | ||
} | ||
.previewLink { | ||
width: 130px; | ||
width: 140px; | ||
|
||
.previewLinkButton { | ||
background: #fff; | ||
|
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