RWKV-Runner/frontend/src/components/Labeled.tsx

29 lines
719 B
TypeScript
Raw Normal View History

2023-05-05 23:23:34 +08:00
import {FC, ReactElement} from 'react';
import {Label, Tooltip} from '@fluentui/react-components';
2023-05-17 23:27:52 +08:00
export const Labeled: FC<{
label: string; desc?: string, content: ReactElement, flex?: boolean, spaceBetween?: boolean
}> = ({
label,
desc,
content,
flex,
spaceBetween
}) => {
2023-05-05 23:23:34 +08:00
return (
2023-05-17 23:27:52 +08:00
<div className={
(flex ? 'flex' : 'grid grid-cols-2') + ' ' +
(spaceBetween ? 'justify-between' : '') + ' ' +
'items-center'
}>
2023-05-05 23:23:34 +08:00
{desc ?
<Tooltip content={desc} showDelay={0} hideDelay={0} relationship="description">
2023-05-06 20:17:39 +08:00
<Label>{label}</Label>
2023-05-05 23:23:34 +08:00
</Tooltip> :
2023-05-06 20:17:39 +08:00
<Label>{label}</Label>
2023-05-05 23:23:34 +08:00
}
{content}
</div>
);
};