Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: break out the blockquote's author into more standalone sub-…
…components
- Loading branch information
Showing
5 changed files
with
70 additions
and
59 deletions.
There are no files selected for viewing
28 changes: 28 additions & 0 deletions
28
packages/components/bolt-blockquote/src/Author/AuthorImage.js
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,28 @@ | ||
import { html } from '@bolt/core/renderers/renderer-lit-html'; | ||
import { ifDefined } from 'lit-html/directives/if-defined'; | ||
import classNames from 'classnames/bind'; | ||
import styles from '../blockquote.scss'; | ||
|
||
const cx = classNames.bind(styles); | ||
|
||
export const AuthorImage = elem => { | ||
const { props, slots } = elem; | ||
if (slots['author-image'] || props.authorImage) { | ||
return html` | ||
<div class="${cx('c-bolt-blockquote__image')}"> | ||
${ | ||
slots['author-image'] | ||
? html` | ||
${elem.slot('author-image')} | ||
` | ||
: html` | ||
<img | ||
src="${props.authorImage}" | ||
alt=${ifDefined(props.authorTitle)} | ||
/> | ||
` | ||
} | ||
</div> | ||
`; | ||
} | ||
}; |
21 changes: 21 additions & 0 deletions
21
packages/components/bolt-blockquote/src/Author/AuthorName.js
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,21 @@ | ||
import { html } from '@bolt/core/renderers/renderer-lit-html'; | ||
|
||
export const AuthorName = elem => { | ||
const { props, slots } = elem; | ||
if (slots['author-name'] || props.authorName) { | ||
return html` | ||
<bolt-text | ||
tag="cite" | ||
font-size="xsmall" | ||
color="theme-headline" | ||
font-weight="bold" | ||
> | ||
${ | ||
elem.slots['author-name'] | ||
? elem.slot('author-name') | ||
: props.authorName | ||
} | ||
</bolt-text> | ||
`; | ||
} | ||
}; |
16 changes: 16 additions & 0 deletions
16
packages/components/bolt-blockquote/src/Author/AuthorTitle.js
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,16 @@ | ||
import { html } from '@bolt/core/renderers/renderer-lit-html'; | ||
|
||
export const AuthorTitle = elem => { | ||
const { props, slots } = elem; | ||
if (slots['author-title'] || props.authorTitle) { | ||
return html` | ||
<bolt-text tag="cite" font-size="xsmall" color="theme-headline"> | ||
${ | ||
elem.slots['author-title'] | ||
? elem.slot('author-title') | ||
: props.authorTitle | ||
} | ||
</bolt-text> | ||
`; | ||
} | ||
}; |
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,3 @@ | ||
export { AuthorImage } from './AuthorImage'; | ||
export { AuthorName } from './AuthorName'; | ||
export { AuthorTitle } from './AuthorTitle'; |
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