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

65 lines
2 KiB
TypeScript
Raw Normal View History

import React from 'react';
import { Group } from '/@/shared/components/group/group';
import { Icon } from '/@/shared/components/icon/icon';
import { Stack } from '/@/shared/components/stack/stack';
import { Text } from '/@/shared/components/text/text';
import { Tooltip } from '/@/shared/components/tooltip/tooltip';
2022-12-19 15:59:14 -08:00
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 = ({ control, description, note, title }: SettingsOptionProps) => {
2023-07-01 19:10:05 -07:00
return (
<>
<Group
justify="space-between"
style={{ alignItems: 'center' }}
wrap="nowrap"
2022-12-19 15:59:14 -08:00
>
2023-07-01 19:10:05 -07:00
<Stack
gap="xs"
style={{
2023-07-01 19:10:05 -07:00
alignSelf: 'flex-start',
display: 'flex',
maxWidth: '50%',
}}
>
<Group>
<Text
isNoSelect
2023-07-01 19:10:05 -07:00
size="md"
>
{title}
</Text>
{note && (
<Tooltip
label={note}
openDelay={0}
>
<Icon icon="info" />
2023-07-01 19:10:05 -07:00
</Tooltip>
)}
</Group>
{React.isValidElement(description) ? (
description
) : (
<Text
isMuted
isNoSelect
2023-07-01 19:10:05 -07:00
size="sm"
>
{description}
</Text>
)}
</Stack>
<Group justify="flex-end">{control}</Group>
2023-07-01 19:10:05 -07:00
</Group>
</>
);
2022-12-19 15:59:14 -08:00
};