session-desktop/ts/components/session/settings/SessionSettingListItem.tsx

75 lines
2.3 KiB
TypeScript
Raw Normal View History

import React from 'react';
2020-01-14 07:42:04 +01:00
import classNames from 'classnames';
2020-01-09 01:38:48 +01:00
import { SessionToggle } from '../SessionToggle';
import { SessionButton, SessionButtonColor } from '../SessionButton';
2021-08-06 03:09:14 +02:00
import { SessionConfirmDialogProps } from '../../dialog/SessionConfirm';
2020-01-14 07:42:04 +01:00
type ButtonSettingsProps = {
title?: string;
2020-01-09 02:15:12 +01:00
description?: string;
buttonColor: SessionButtonColor;
buttonText: string;
onClick: () => void;
};
const SettingsTitleAndDescription = (props: { title?: string; description?: string }) => {
return (
<div className="session-settings-item__info">
<div className="session-settings-item__title">{props.title}</div>
2020-01-15 02:26:14 +01:00
{props.description && (
<div className="session-settings-item__description">{props.description}</div>
)}
</div>
);
};
2020-01-16 02:08:31 +01:00
const SessionSettingsContent = (props: { children: React.ReactNode }) => {
return <div className="session-settings-item__content">{props.children}</div>;
};
2020-01-09 01:38:48 +01:00
export const SessionSettingsItemWrapper = (props: {
inline: boolean;
title?: string;
description?: string;
children: React.ReactNode;
}) => {
return (
<div className={classNames('session-settings-item', props.inline && 'inline')}>
<SettingsTitleAndDescription title={props.title} description={props.description} />
<SessionSettingsContent>{props.children}</SessionSettingsContent>
</div>
);
};
export const SessionToggleWithDescription = (props: {
title?: string;
description?: string;
active: boolean;
onClickToggle: () => void;
confirmationDialogParams?: SessionConfirmDialogProps;
}) => {
const { title, description, active, onClickToggle, confirmationDialogParams } = props;
return (
<SessionSettingsItemWrapper title={title} description={description} inline={true}>
<SessionToggle
active={active}
onClick={onClickToggle}
confirmationDialogParams={confirmationDialogParams}
/>
</SessionSettingsItemWrapper>
);
};
export const SessionSettingButtonItem = (props: ButtonSettingsProps) => {
const { title, description, buttonColor, buttonText, onClick } = props;
2020-01-16 02:08:31 +01:00
return (
<SessionSettingsItemWrapper title={title} description={description} inline={true}>
<SessionButton text={buttonText} buttonColor={buttonColor} onClick={onClick} />
</SessionSettingsItemWrapper>
);
};