4 changed files with 48 additions and 22 deletions
@ -1,35 +1,43 @@ |
|||||
import type React from 'react'; |
import type React from 'react'; |
||||
|
|
||||
|
import { Tooltip } from '@components/generic/Tooltip'; |
||||
|
|
||||
type DefaulButtonProps = JSX.IntrinsicElements['button']; |
type DefaulButtonProps = JSX.IntrinsicElements['button']; |
||||
|
|
||||
export interface IconButtonProps extends DefaulButtonProps { |
export interface IconButtonProps extends DefaulButtonProps { |
||||
icon: React.ReactNode; |
icon: React.ReactNode; |
||||
|
tooltip?: string; |
||||
active?: boolean; |
active?: boolean; |
||||
} |
} |
||||
|
|
||||
export const IconButton = ({ |
export const IconButton = ({ |
||||
icon, |
icon, |
||||
active, |
active, |
||||
|
tooltip, |
||||
disabled, |
disabled, |
||||
...props |
...props |
||||
}: IconButtonProps): JSX.Element => { |
}: IconButtonProps): JSX.Element => { |
||||
return ( |
return ( |
||||
<div className="my-auto text-gray-500 dark:text-gray-400"> |
<Tooltip disabled={!tooltip} content={tooltip}> |
||||
<button |
<div className="my-auto text-gray-500 dark:text-gray-400"> |
||||
type="button" |
<button |
||||
disabled={disabled} |
type="button" |
||||
className={`rounded-md p-2 transition duration-200 ease-in-out active:scale-95 ${ |
disabled={disabled} |
||||
active |
className={`rounded-md p-2 transition duration-200 ease-in-out active:scale-95 ${ |
||||
? 'bg-gray-200 dark:bg-gray-600' |
active |
||||
: 'hover:bg-gray-200 dark:hover:bg-gray-600' |
? 'bg-gray-200 dark:bg-gray-600' |
||||
} ${ |
: 'hover:bg-gray-200 dark:hover:bg-gray-600' |
||||
disabled ? 'cursor-not-allowed text-gray-400 dark:text-gray-700' : '' |
} ${ |
||||
}`}
|
disabled |
||||
{...props} |
? 'cursor-not-allowed text-gray-400 dark:text-gray-700' |
||||
> |
: '' |
||||
{icon} |
}`}
|
||||
<span className="sr-only">Refresh</span> |
{...props} |
||||
</button> |
> |
||||
</div> |
{icon} |
||||
|
<span className="sr-only">Refresh</span> |
||||
|
</button> |
||||
|
</div> |
||||
|
</Tooltip> |
||||
); |
); |
||||
}; |
}; |
||||
|
|||||
Loading…
Reference in new issue