mirror of
https://github.com/kogakure/website-astro-stefanimhoff.de.git
synced 2026-02-03 20:15:27 +00:00
feat: add Blockquote component
This commit is contained in:
50
src/components/Blockquote.tsx
Normal file
50
src/components/Blockquote.tsx
Normal file
@@ -0,0 +1,50 @@
|
|||||||
|
import cx from 'classnames';
|
||||||
|
|
||||||
|
import type { ComponentChild, FunctionalComponent, JSX } from 'preact';
|
||||||
|
|
||||||
|
import { TextLink } from '.';
|
||||||
|
|
||||||
|
interface Props extends JSX.HTMLAttributes<HTMLQuoteElement> {
|
||||||
|
author?: string;
|
||||||
|
children: ComponentChild;
|
||||||
|
class?: string;
|
||||||
|
lang?: string;
|
||||||
|
source?: string;
|
||||||
|
sourceUrl?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export const Blockquote: FunctionalComponent<Props> = ({
|
||||||
|
author,
|
||||||
|
children,
|
||||||
|
class: className,
|
||||||
|
lang = 'en',
|
||||||
|
source,
|
||||||
|
sourceUrl,
|
||||||
|
...props
|
||||||
|
}) => {
|
||||||
|
const classes = cx(
|
||||||
|
'relative overflow-hidden mbe-12 mbs-12 mie-8 mis-8 pie-8 pis-8 md:mie-10 md:mis-10',
|
||||||
|
className
|
||||||
|
);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<blockquote lang={lang} class={classes} {...props}>
|
||||||
|
{children}
|
||||||
|
{(author || source) && (
|
||||||
|
<footer class="text-2 font-normal opacity-60 mbs-6">
|
||||||
|
{(author || source) && '—'}
|
||||||
|
{author && <b class="font-normal">{author}</b>}
|
||||||
|
{author && source && ', '}
|
||||||
|
{source &&
|
||||||
|
(sourceUrl ? (
|
||||||
|
<cite>
|
||||||
|
<TextLink href={sourceUrl}>{source}</TextLink>
|
||||||
|
</cite>
|
||||||
|
) : (
|
||||||
|
<cite>{source}</cite>
|
||||||
|
))}
|
||||||
|
</footer>
|
||||||
|
)}
|
||||||
|
</blockquote>
|
||||||
|
);
|
||||||
|
};
|
||||||
@@ -1,6 +1,7 @@
|
|||||||
export * from './AffiliateLink';
|
export * from './AffiliateLink';
|
||||||
export * from './AmazonBook';
|
export * from './AmazonBook';
|
||||||
export * from './Banner';
|
export * from './Banner';
|
||||||
|
export * from './Blockquote';
|
||||||
export * from './Book';
|
export * from './Book';
|
||||||
export * from './ColorStack';
|
export * from './ColorStack';
|
||||||
export * from './ColorSwatch';
|
export * from './ColorSwatch';
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ import {
|
|||||||
AffiliateLink,
|
AffiliateLink,
|
||||||
AmazonBook,
|
AmazonBook,
|
||||||
Banner,
|
Banner,
|
||||||
|
Blockquote,
|
||||||
Book,
|
Book,
|
||||||
ColorStack,
|
ColorStack,
|
||||||
ColorSwatch,
|
ColorSwatch,
|
||||||
@@ -37,6 +38,8 @@ export const mapping = {
|
|||||||
AffiliateLink,
|
AffiliateLink,
|
||||||
AmazonBook,
|
AmazonBook,
|
||||||
Banner,
|
Banner,
|
||||||
|
blockquote: Blockquote,
|
||||||
|
Blockquote,
|
||||||
Book,
|
Book,
|
||||||
ColorStack,
|
ColorStack,
|
||||||
ColorSwatch,
|
ColorSwatch,
|
||||||
|
|||||||
@@ -81,6 +81,35 @@
|
|||||||
quotes: '「' '」' '『' '』';
|
quotes: '「' '」' '『' '』';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Blockquote */
|
||||||
|
blockquote {
|
||||||
|
& p,
|
||||||
|
& ul,
|
||||||
|
& ol {
|
||||||
|
@apply text-3 font-extralight italic opacity-60 !mbe-8 mbs-0;
|
||||||
|
}
|
||||||
|
|
||||||
|
& p:last-child {
|
||||||
|
@apply !mbe-0;
|
||||||
|
}
|
||||||
|
|
||||||
|
& > footer {
|
||||||
|
@apply !-mbs-5;
|
||||||
|
}
|
||||||
|
|
||||||
|
&:nth-last-child(2) {
|
||||||
|
@apply mbe-5;
|
||||||
|
}
|
||||||
|
|
||||||
|
& strong {
|
||||||
|
@apply font-bold italic;
|
||||||
|
}
|
||||||
|
|
||||||
|
& sup {
|
||||||
|
@apply font-normal;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/** Inline Quotes */
|
/** Inline Quotes */
|
||||||
q {
|
q {
|
||||||
@apply italic;
|
@apply italic;
|
||||||
|
|||||||
Reference in New Issue
Block a user