feat: add components for list item, unordered, and ordered lists

This commit is contained in:
Stefan Imhoff
2023-04-05 15:33:12 +02:00
parent 58336ccd73
commit d8bb473ffe
5 changed files with 85 additions and 1 deletions

View File

@@ -0,0 +1,18 @@
import cx from 'classnames';
import type { ComponentChild, FunctionalComponent } from 'preact';
interface Props {
class?: string;
children: ComponentChild;
}
export const ListItem: FunctionalComponent<Props> = ({ class: className, children, ...props }) => {
const classes = cx('mbe-2', className);
return (
<li class={classes} {...props}>
{children}
</li>
);
};

View File

@@ -0,0 +1,25 @@
import cx from 'classnames';
import type { ComponentChild, FunctionalComponent } from 'preact';
interface Props {
class?: string;
children: ComponentChild;
}
export const OrderedList: FunctionalComponent<Props> = ({
class: className,
children,
...props
}) => {
const classes = cx(
'list-decimal text-3 mbe-12 pis-[1.5rem] md:pis-0 [li>&]:mbe-0 [li>&]:pis-[1.5rem]',
className
);
return (
<ol class={classes} {...props}>
{children}
</ol>
);
};

View File

@@ -0,0 +1,25 @@
import cx from 'classnames';
import type { ComponentChild, FunctionalComponent } from 'preact';
interface Props {
class?: string;
children: ComponentChild;
}
export const UnorderedList: FunctionalComponent<Props> = ({
class: className,
children,
...props
}) => {
const classes = cx(
'list-square text-3 mbe-12 pis-[1.5rem] md:pis-0 [li>&]:mbe-0 [li>&]:pis-[1.5rem]',
className
);
return (
<ul class={classes} {...props}>
{children}
</ul>
);
};

View File

@@ -1,8 +1,11 @@
export * from './Headline';
export * from './LegalDate';
export * from './Link';
export * from './ListItem';
export * from './OrderedList';
export * from './Subheadline';
export * from './Subsubheadline';
export * from './Text';
export * from './TextLink';
export * from './Title';
export * from './UnorderedList';

View File

@@ -1,4 +1,14 @@
import { Headline, Subheadline, Subsubheadline, Text, TextLink, Title } from './components';
import {
Headline,
ListItem,
OrderedList,
Subheadline,
Subsubheadline,
Text,
TextLink,
Title,
UnorderedList,
} from './components';
export const mapping = {
a: TextLink,
@@ -8,5 +18,8 @@ export const mapping = {
h4: Subsubheadline,
h5: Subsubheadline,
h6: Subsubheadline,
li: ListItem,
ol: OrderedList,
p: Text,
ul: UnorderedList,
};