ADDED: Icon wrapper for more elegant way to placement icon in buttons

TODO: Add styles for selected segmented button
DONE: Base styles for segmented buttons
This commit is contained in:
2024-02-09 23:16:00 +04:00
committed by doryan
parent 4778ce7e37
commit dbb19057ac
15 changed files with 148 additions and 45 deletions

View File

@@ -1,10 +1,10 @@
'use client';
import { forwardRef } from 'react';
import { Icon } from '../../components';
import { ButtonProps } from './button.types';
import { bool, oneOf, string } from 'prop-types';
import { ButtonLayout } from '../button-layout/button-layout';
import { IconWrapper } from '../../icon/icon-wrapper';
/**
* Button component
@@ -14,10 +14,11 @@ import { ButtonLayout } from '../button-layout/button-layout';
export const Button = forwardRef<HTMLButtonElement, ButtonProps>(
(
{
icon,
icon = undefined,
className = '',
disabled = false,
variant = 'filled',
iconPlace = 'left',
centralRipple = false,
...props
},
@@ -30,8 +31,9 @@ export const Button = forwardRef<HTMLButtonElement, ButtonProps>(
disabled={disabled}
ref={ref}
>
{icon ? <Icon iconSize={20}>{icon}</Icon> : <></>}
<span className={'label-large'}>{props.children}</span>
<IconWrapper icon={icon} iconPlace={iconPlace}>
<span className={'label-large'}>{props.children}</span>
</IconWrapper>
</ButtonLayout>
),
);