mirror of
https://github.com/kogakure/website-astro-stefanimhoff.de.git
synced 2026-02-03 20:15:27 +00:00
feat: create Verse component
This commit is contained in:
34
src/components/Verse.tsx
Normal file
34
src/components/Verse.tsx
Normal 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>
|
||||
);
|
||||
};
|
||||
@@ -11,3 +11,4 @@ export * from './Text';
|
||||
export * from './TextLink';
|
||||
export * from './Title';
|
||||
export * from './UnorderedList';
|
||||
export * from './Verse';
|
||||
|
||||
@@ -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,
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user