2020-10-30 20:34:04 +00:00
|
|
|
// Copyright 2019-2020 Signal Messenger, LLC
|
|
|
|
// SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
|
2022-06-13 21:39:35 +00:00
|
|
|
import React from 'react';
|
|
|
|
import classnames from 'classnames';
|
|
|
|
|
2019-12-17 20:25:57 +00:00
|
|
|
import * as styles from './Button.scss';
|
|
|
|
|
2022-06-13 21:39:35 +00:00
|
|
|
export type Props = React.ButtonHTMLAttributes<HTMLButtonElement> & {
|
2019-12-17 20:25:57 +00:00
|
|
|
pill?: boolean;
|
|
|
|
primary?: boolean;
|
|
|
|
};
|
|
|
|
|
|
|
|
const getClassName = ({ primary, pill }: Props) => {
|
|
|
|
if (pill && primary) {
|
|
|
|
return styles.pillPrimary;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (pill) {
|
|
|
|
return styles.pill;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (primary) {
|
|
|
|
return styles.primary;
|
|
|
|
}
|
|
|
|
|
|
|
|
return styles.base;
|
|
|
|
};
|
|
|
|
|
2022-11-18 00:45:19 +00:00
|
|
|
export function Button({
|
2020-09-14 21:56:35 +00:00
|
|
|
className,
|
|
|
|
children,
|
|
|
|
...otherProps
|
2022-11-18 00:45:19 +00:00
|
|
|
}: React.PropsWithChildren<Props>): JSX.Element {
|
2019-12-17 20:25:57 +00:00
|
|
|
return (
|
|
|
|
<button
|
2020-09-14 21:56:35 +00:00
|
|
|
type="button"
|
|
|
|
className={classnames(getClassName(otherProps), className)}
|
2019-12-17 20:25:57 +00:00
|
|
|
{...otherProps}
|
|
|
|
>
|
|
|
|
{children}
|
|
|
|
</button>
|
|
|
|
);
|
2022-11-18 00:45:19 +00:00
|
|
|
}
|