bigbuffet-rw/app/soapbox/components/ui/divider/divider.tsx

30 lines
821 B
TypeScript
Raw Normal View History

2022-06-07 08:24:40 -07:00
import React from 'react';
2022-08-25 10:44:19 -07:00
import Text from '../text/text';
import type { Sizes as TextSizes } from '../text/text';
2022-06-07 08:24:40 -07:00
interface IDivider {
text?: string
2022-08-25 10:44:19 -07:00
textSize?: TextSizes
2022-06-07 08:24:40 -07:00
}
/** Divider */
2022-08-25 10:44:19 -07:00
const Divider = ({ text, textSize = 'md' }: IDivider) => (
2022-06-07 08:24:40 -07:00
<div className='relative' data-testid='divider'>
<div className='absolute inset-0 flex items-center' aria-hidden='true'>
<div className='w-full border-t-2 border-gray-100 dark:border-gray-800 border-solid' />
2022-06-07 08:24:40 -07:00
</div>
{text && (
<div className='relative flex justify-center'>
2022-09-29 06:45:57 -07:00
<span className='px-2 bg-white dark:bg-gray-900 text-gray-700 dark:text-gray-600' data-testid='divider-text'>
2022-08-25 10:44:19 -07:00
<Text size={textSize} tag='span' theme='inherit'>{text}</Text>
</span>
2022-06-07 08:24:40 -07:00
</div>
)}
</div>
);
export default Divider;