material-you-react/src/primitive-components/button-components/button/button.tsx

54 lines
1.4 KiB
TypeScript
Raw Normal View History

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';
import { ButtonLayout } from '../button-layout/button-layout';
import { IconWrapper } from '../../icon/icon-wrapper';
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
{
icon = undefined,
2024-02-02 13:39:02 +03:00
className = '',
disabled = false,
variant = 'filled',
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}
>
<IconWrapper icon={icon} iconPlace={iconPlace}>
<Typography
className={'label-large'}
role={'label'}
size={'large'}
>
{props.children}
</Typography>
</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']),
};