feishin/src/renderer/features/settings/components/settings-option.tsx

69 lines
2.1 KiB
TypeScript
Raw Normal View History

2022-12-19 15:59:14 -08:00
import React from 'react';
import { Group, Stack } from '@mantine/core';
import { RiInformationLine } from 'react-icons/ri';
import { Text, Tooltip } from '/@/renderer/components';
interface SettingsOptionProps {
2023-07-01 19:10:05 -07:00
control: React.ReactNode;
description?: React.ReactNode | string;
note?: string;
title: React.ReactNode | string;
2022-12-19 15:59:14 -08:00
}
export const SettingsOptions = ({ title, description, control, note }: SettingsOptionProps) => {
2023-07-01 19:10:05 -07:00
return (
<>
<Group
noWrap
position="apart"
sx={{ alignItems: 'center' }}
2022-12-19 15:59:14 -08:00
>
2023-07-01 19:10:05 -07:00
<Stack
spacing="xs"
sx={{
alignSelf: 'flex-start',
display: 'flex',
maxWidth: '50%',
}}
>
<Group>
<Text
$noSelect
size="md"
>
{title}
</Text>
{note && (
<Tooltip
label={note}
openDelay={0}
>
<Group>
<RiInformationLine size={15} />
</Group>
</Tooltip>
)}
</Group>
{React.isValidElement(description) ? (
description
) : (
<Text
$noSelect
$secondary
size="sm"
>
{description}
</Text>
)}
</Stack>
<Group position="right">{control}</Group>
</Group>
</>
);
2022-12-19 15:59:14 -08:00
};
SettingsOptions.defaultProps = {
2023-07-01 19:10:05 -07:00
description: undefined,
note: undefined,
2022-12-19 15:59:14 -08:00
};