Skip to content

Commit

Permalink
fix: buttons props #190
Browse files Browse the repository at this point in the history
  • Loading branch information
habdevs committed Sep 7, 2023
1 parent bb36120 commit 317a91b
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 7 deletions.
20 changes: 15 additions & 5 deletions components/shared/ui/CustomButton/CustomButton.tsx
Original file line number Diff line number Diff line change
@@ -1,20 +1,30 @@
import { CustomButtonProps } from './CustomButtonProps';
import { ICustomButtonProps } from './CustomButtonProps';
import styles from './CustomButton.module.scss';
import cn from 'classnames';
import Link from 'next/link';
import { FC } from 'react';

export const CustomButton = (props: CustomButtonProps) => {
const { disabled, size, color, radius, text, image, imagePosition, link, imageSize } = props;
export const CustomButton: FC<ICustomButtonProps> = ({
size,
color,
radius,
text,
image,
imagePosition,
link,
imageSize,
...rest
}) => {

const buttonClasses = cn(
styles.button,
styles[`size-${size}`],
styles[`color-${color}`],
styles[`radius-${radius}`],
rest.disabled ? styles.disabled : null,
{
[styles['text-center']]: imagePosition === 'left' || imagePosition === 'right',
},
props.disabled ? styles.disabled : null,
);

const imageStyles = {
Expand All @@ -39,7 +49,7 @@ export const CustomButton = (props: CustomButtonProps) => {
}

return (
<button className={buttonClasses} {...props}>
<button className={buttonClasses} {...rest}>
{imagePosition === 'left' && (
<img src={image} alt='Button Image' className={styles.image} style={imageStyles} />
)}
Expand Down
3 changes: 1 addition & 2 deletions components/shared/ui/CustomButton/CustomButtonProps.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export interface CustomButtonProps {
export interface ICustomButtonProps {
onClick?: () => void;
size?: 'xs' | 'sm' | 'md' | 'lg' | 'xl';
color?: 'transparent' | 'dark' | 'gradient';
Expand All @@ -9,5 +9,4 @@ export interface CustomButtonProps {
imagePosition?: 'left' | 'right';
link?: string;
imageSize?: string;
disabled?: boolean
}

0 comments on commit 317a91b

Please sign in to comment.