-
Notifications
You must be signed in to change notification settings - Fork 6
add book list component for flexpages #2736
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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,55 @@ | ||
import React from 'react'; | ||
import PromoteBadge from '~/components/promote-badge/promote-badge'; | ||
import type {Item} from '~/models/book-titles'; | ||
import {Book as BookInfo} from '~/pages/subjects/new/specific/context'; | ||
import GetTheBookDropdown from './dropdown-menu'; | ||
import cn from 'classnames'; | ||
import './book-tile.scss'; | ||
|
||
type AdditionalFields = Partial<{ | ||
promoteSnippet: Item['promote_snippet']; | ||
bookState: string; | ||
}> | ||
|
||
export default function BookTile({book}: {book: BookInfo & AdditionalFields}) { | ||
const {coverUrl, title, slug} = book; | ||
const comingSoon = book.bookState === 'coming_soon'; | ||
const snippets = book.promoteSnippet?.filter((s) => s.value.image); | ||
const promoteSnippet = snippets?.find((s) => s.value.image); | ||
const classes = cn({ | ||
'book-tile': true, | ||
'coming-soon': comingSoon, | ||
promote: Boolean(promoteSnippet) | ||
}); | ||
|
||
return ( | ||
<div className={classes}> | ||
<a href={`/details/${slug}`} aria-label={`${title} book`}> | ||
<img | ||
src={coverUrl} | ||
role='presentation' | ||
width='240' | ||
height='240' | ||
/> | ||
{promoteSnippet?.value.image && ( | ||
<PromoteBadge | ||
name={promoteSnippet.value.name} | ||
image={promoteSnippet.value.image} | ||
/> | ||
)} | ||
<div className='text-block'> | ||
{title} | ||
</div> | ||
</a> | ||
{comingSoon ? ( | ||
<div className='navmenu'> | ||
<button type='button' disabled> | ||
Coming soon | ||
</button> | ||
</div> | ||
) : ( | ||
<GetTheBookDropdown bookInfo={book} /> | ||
)} | ||
</div> | ||
); | ||
} |
This file contains hidden or 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 hidden or 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,16 @@ | ||
@import 'pattern-library/core/pattern-library/headers'; | ||
|
||
.flex-page.page div.content-block-book-list { | ||
display: grid; | ||
grid-template-columns: repeat(auto-fill, minmax(16rem, 1fr)); | ||
margin: $normal-margin 0; | ||
width: 100%; | ||
|
||
@include width-up-to($phone-max) { | ||
grid-gap: 1rem; | ||
} | ||
|
||
@include wider-than($phone-max) { | ||
grid-gap: 4rem 2rem; | ||
} | ||
} |
This file contains hidden or 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,44 @@ | ||
import React from 'react'; | ||
import cn from 'classnames'; | ||
import './BookListBlock.scss'; | ||
import BookTile from '~/components/book-tile/book-tile-display'; | ||
|
||
/* | ||
* the book data formatting in the CMS is currently fragemented, | ||
* when it gets centralized we can centralize the types as well | ||
*/ | ||
export type BookInfo = { | ||
id: number; | ||
slug: string; | ||
title: string; | ||
webviewRexLink: string; | ||
webviewLink: string; | ||
highResolutionPdfUrl: string; | ||
lowResolutionPdfUrl: string; | ||
coverUrl: string; | ||
bookState: string; | ||
promoteSnippet: { | ||
value: { | ||
id: number; | ||
description: string; | ||
image: string; | ||
name: string; | ||
}; | ||
}[]; | ||
}; | ||
|
||
export type BookListBlockConfig = { | ||
id: string; | ||
type: 'book_list'; | ||
value: { | ||
books: BookInfo[]; | ||
}; | ||
}; | ||
|
||
export function BookListBlock({data}: {data: BookListBlockConfig}) { | ||
return ( | ||
<div className={cn('content-block-book-list')}> | ||
{data.value.books.map((book) => <BookTile key={book.id} book={book} />)} | ||
</div> | ||
); | ||
} |
This file contains hidden or 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 hidden or 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 hidden or 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,4 @@ | ||
|
||
.page.flex-page { | ||
overflow: visible; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. the overflow:hidden on the page was hiding the dropdown menu if there was no following content |
||
} |
This file contains hidden or 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 hidden or 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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not certain this is the best way to handle this, but without the margin the text descenders are cut off
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This appears to be a
line-height
issue in the pattern library. hero-h1 line-height is5rem
. It should benormal
rather than being specified. This dates back to ancient times when the pattern-library was first spec'd.