import React from "react"; import styled, { css } from "styled-components"; import { NoUserSelect } from "../../utils"; import { Base, TTheme } from "../../themes"; import { ButtonProps, ButtonThemeProps } from "./Button.types"; import { ButtonSize } from "./Button.enums"; const activeCss = css` background-color: ${(props) => props.primary ? props.theme.button.backgroundColor.primaryActive : props.theme.button.backgroundColor.baseActive}; color: ${(props) => props.primary ? props.theme.button.color.primaryActive : props.theme.button.color.baseActive}; ${(props) => !props.primary ? css` border: ${props.theme.button.border.baseActive}; box-sizing: ${props.theme.button.boxSizing}; ` : css` border: ${props.theme.button.border.primaryActive}; box-sizing: ${props.theme.button.boxSizing}; `} .btnIcon { svg { path { fill: ${(props) => props.primary ? props.theme.button.color.primaryActive : props.theme.button.color.baseActive}; } } } `; const hoverCss = css` background-color: ${(props) => props.primary ? props.theme.button.backgroundColor.primaryHover : props.theme.button.backgroundColor.baseHover}; color: ${(props) => props.primary ? props.theme.button.color.primaryHover : props.theme.button.color.baseHover}; ${(props) => !props.primary ? css` border: ${props.theme.button.border.baseHover}; box-sizing: ${props.theme.button.boxSizing}; ` : css` border: ${props.theme.button.border.primaryHover}; box-sizing: ${props.theme.button.boxSizing}; `} .btnIcon { svg { path { fill: ${(props) => props.primary ? props.theme.button.color.primaryHover : props.theme.button.color.baseHover}; } } } `; const disableCss = css` background-color: ${(props) => props.primary ? props.theme.button.backgroundColor.primaryDisabled : props.theme.button.backgroundColor.baseDisabled}; color: ${(props) => props.primary ? props.theme.button.color.primaryDisabled : props.theme.button.color.baseDisabled}; ${(props) => !props.primary ? css` border: ${props.theme.button.border.baseDisabled}; box-sizing: ${props.theme.button.boxSizing}; ` : css` border: ${props.theme.button.border.primaryDisabled}; box-sizing: ${props.theme.button.boxSizing}; `} .btnIcon { svg { path { fill: ${(props) => props.primary ? props.theme.button.color.primaryDisabled : props.theme.button.color.baseDisabled}; } } } `; const heightStyle = (props: { size?: ButtonSize; theme: TTheme }) => props.theme.button.height[props.size || ButtonSize.normal]; const fontSizeStyle = (props: { size?: ButtonSize; theme: TTheme }) => props.theme.button.fontSize[props.size || ButtonSize.normal]; const ButtonWrapper = React.forwardRef< HTMLButtonElement, ButtonProps & { interfaceDirection?: boolean | string; } >( ( { primary, scale, size, isHovered, isClicked, isDisabled, disableHover, isLoading, label, minWidth, ...props }, ref, ) => { return