Added Blockquote Component
This commit is contained in:
27
src/components/Content/Blockquote/Blockquote.module.css
Normal file
27
src/components/Content/Blockquote/Blockquote.module.css
Normal file
@@ -0,0 +1,27 @@
|
||||
.container {
|
||||
margin-block: var(--el-p-vspace-top) var(--el-p-vspace-bottom);
|
||||
padding: var(--spacing-snug) 0 var(--spacing-snug) var(--spacing-comfortable);
|
||||
border-left: var(--size-4) solid var(--color-text-tertiary);
|
||||
}
|
||||
|
||||
.quote {
|
||||
font-family: var(--el-blockquote-font-family), serif;
|
||||
font-size: var(--el-blockquote-font-size);
|
||||
font-weight: var(--el-blockquote-font-weight);
|
||||
font-style: var(--el-blockquote-font-style);
|
||||
line-height: var(--el-blockquote-line-height);
|
||||
color: var(--el-blockquote-color);
|
||||
}
|
||||
|
||||
.attribution,
|
||||
.source {
|
||||
font-family: var(--font-mono);
|
||||
}
|
||||
|
||||
.link {
|
||||
@mixin anim-txt-typewriter;
|
||||
|
||||
&:hover {
|
||||
color: var(--color-primary);
|
||||
}
|
||||
}
|
||||
70
src/components/Content/Blockquote/index.tsx
Normal file
70
src/components/Content/Blockquote/index.tsx
Normal file
@@ -0,0 +1,70 @@
|
||||
import { marked } from 'marked';
|
||||
|
||||
import styles from './Blockquote.module.css';
|
||||
|
||||
interface BlockquoteProps {
|
||||
quote: string;
|
||||
attribution?: string;
|
||||
source?: string;
|
||||
url?: string;
|
||||
}
|
||||
|
||||
export default function Blockquote({
|
||||
quote,
|
||||
attribution,
|
||||
source,
|
||||
url,
|
||||
}: BlockquoteProps) {
|
||||
const hasAttribution = !!attribution;
|
||||
const hasSource = !!source;
|
||||
const hasUrl = !!url;
|
||||
const showFooter = hasSource || hasAttribution;
|
||||
const attributionLinked = hasAttribution && hasUrl && !hasSource;
|
||||
const sourceLinked = hasSource && hasUrl;
|
||||
return (
|
||||
<blockquote className={styles.blockquote}>
|
||||
<div
|
||||
className={styles.quote}
|
||||
dangerouslySetInnerHTML={{ __html: marked.parse(quote) }}
|
||||
/>
|
||||
{showFooter && (
|
||||
<footer className={styles.footer}>
|
||||
{hasAttribution && (
|
||||
<cite className={styles.attribution}>
|
||||
{attributionLinked ? (
|
||||
<a
|
||||
href={url}
|
||||
className={styles.link}
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
>
|
||||
{attribution}
|
||||
</a>
|
||||
) : (
|
||||
attribution
|
||||
)}
|
||||
</cite>
|
||||
)}
|
||||
{hasSource && (
|
||||
<cite className={styles.source}>
|
||||
{' '}
|
||||
–
|
||||
{sourceLinked ? (
|
||||
<a
|
||||
href={url}
|
||||
className={styles.link}
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
>
|
||||
{source}
|
||||
</a>
|
||||
) : (
|
||||
source
|
||||
)}
|
||||
</cite>
|
||||
)}
|
||||
</footer>
|
||||
)}
|
||||
</blockquote>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user