anvil/striker-ui/components/Text/InlineMonoText.tsx

31 lines
705 B
TypeScript
Raw Normal View History

import { FC, useMemo } from 'react';
2022-08-17 00:11:59 +00:00
import { BodyTextProps } from './BodyText';
import SmallText from './SmallText';
const InlineMonoText: FC<BodyTextProps> = ({
edge,
sx,
...bodyTextRestProps
}) => {
const paddingLeft = useMemo(() => (edge === 'start' ? 0 : undefined), [edge]);
2022-08-17 00:11:59 +00:00
const paddingRight = useMemo(() => (edge === 'end' ? 0 : undefined), [edge]);
const combinedSx: BodyTextProps['sx'] = useMemo(
() => ({
display: 'inline',
padding: '.1rem .3rem',
paddingLeft,
paddingRight,
...sx,
}),
[paddingLeft, paddingRight, sx],
);
return <SmallText monospaced sx={combinedSx} {...bodyTextRestProps} />;
};
2022-08-17 00:11:59 +00:00
export default InlineMonoText;