2024-02-01 00:58:19 +03:00
|
|
|
'use client';
|
|
|
|
|
|
|
|
import { forwardRef } from 'react';
|
2024-02-01 15:23:59 +03:00
|
|
|
import { ButtonProps } from './button.types';
|
2024-02-02 13:39:02 +03:00
|
|
|
import { bool, oneOf, string } from 'prop-types';
|
2024-02-03 00:34:54 +03:00
|
|
|
import { ButtonLayout } from '../button-layout/button-layout';
|
2024-02-09 22:16:00 +03:00
|
|
|
import { IconWrapper } from '../../icon/icon-wrapper';
|
2024-02-17 20:11:14 +03:00
|
|
|
import { Typography } from '../../typography/typography';
|
2024-02-01 00:58:19 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Button component
|
|
|
|
** description
|
|
|
|
*/
|
|
|
|
|
2024-02-01 15:23:59 +03:00
|
|
|
export const Button = forwardRef<HTMLButtonElement, ButtonProps>(
|
2024-02-01 00:58:19 +03:00
|
|
|
(
|
2024-02-02 13:39:02 +03:00
|
|
|
{
|
2024-02-09 22:16:00 +03:00
|
|
|
icon = undefined,
|
2024-02-02 13:39:02 +03:00
|
|
|
className = '',
|
|
|
|
disabled = false,
|
|
|
|
variant = 'filled',
|
2024-02-09 22:16:00 +03:00
|
|
|
iconPlace = 'left',
|
2024-02-02 13:39:02 +03:00
|
|
|
centralRipple = false,
|
|
|
|
...props
|
|
|
|
},
|
2024-02-01 00:58:19 +03:00
|
|
|
ref,
|
|
|
|
) => (
|
|
|
|
<ButtonLayout
|
|
|
|
{...props}
|
|
|
|
centralRipple={centralRipple}
|
2024-02-02 13:39:02 +03:00
|
|
|
className={`${variant} ${className}`}
|
2024-02-01 00:58:19 +03:00
|
|
|
disabled={disabled}
|
|
|
|
ref={ref}
|
|
|
|
>
|
2024-02-09 22:16:00 +03:00
|
|
|
<IconWrapper icon={icon} iconPlace={iconPlace}>
|
2024-02-17 20:11:14 +03:00
|
|
|
<Typography
|
|
|
|
className={'label-large'}
|
|
|
|
role={'label'}
|
|
|
|
size={'large'}
|
|
|
|
>
|
|
|
|
{props.children}
|
|
|
|
</Typography>
|
2024-02-09 22:16:00 +03:00
|
|
|
</IconWrapper>
|
2024-02-01 00:58:19 +03:00
|
|
|
</ButtonLayout>
|
|
|
|
),
|
|
|
|
);
|
2024-02-02 13:39:02 +03:00
|
|
|
|
|
|
|
Button.propTypes = {
|
|
|
|
icon: string,
|
|
|
|
children: string,
|
|
|
|
centralRipple: bool,
|
|
|
|
variant: oneOf(['filled', 'outlined', 'elevated', 'tonal', 'text']),
|
|
|
|
};
|