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

51 lines
1.7 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 (
<>
2025-07-12 11:17:54 -07:00
<Group justify="space-between" style={{ alignItems: 'center' }} wrap="nowrap">
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>
2025-07-12 11:17:54 -07:00
<Text isNoSelect size="md">
2023-07-01 19:10:05 -07:00
{title}
</Text>
{note && (
2025-07-12 11:17:54 -07:00
<Tooltip label={note} openDelay={0}>
<Icon icon="info" />
2023-07-01 19:10:05 -07:00
</Tooltip>
)}
</Group>
{React.isValidElement(description) ? (
description
) : (
2025-07-12 11:17:54 -07:00
<Text isMuted isNoSelect size="sm">
2023-07-01 19:10:05 -07:00
{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
};