feat: create Verse component

This commit is contained in:
Stefan Imhoff
2023-04-13 14:57:54 +02:00
parent e0e37c8343
commit 52504a070f
3 changed files with 37 additions and 0 deletions

34
src/components/Verse.tsx Normal file
View File

@@ -0,0 +1,34 @@
import cx from 'classnames';
import type { ComponentChild, FunctionalComponent } from 'preact';
interface Props {
class?: string;
children: ComponentChild;
variant?: 'center' | 'left';
}
export const Verse: FunctionalComponent<Props> = ({
class: className,
children,
variant = 'center',
...props
}) => {
const classes = cx(
'flex italic [&_p]:mbe-0',
{
'm-10': variant === 'center',
'mbs-10 mbe-10 mis-0 mie-0': variant === 'left',
},
className
);
const preClasses = cx('font-sans mis-0 mie-0 whitespace-pre', {
'mbs-auto mbe-auto': variant === 'center',
});
return (
<blockquote class={classes} {...props}>
<pre class={preClasses}>{children}</pre>
</blockquote>
);
};

View File

@@ -11,3 +11,4 @@ export * from './Text';
export * from './TextLink';
export * from './Title';
export * from './UnorderedList';
export * from './Verse';

View File

@@ -10,6 +10,7 @@ import {
TextLink,
Title,
UnorderedList,
Verse,
} from './components';
export const mapping = {
@@ -26,4 +27,5 @@ export const mapping = {
ol: OrderedList,
p: Text,
ul: UnorderedList,
Verse,
};