2f7b266e6b
* MP-1674: replaced the logo and added dekstop only nav * MP-1677: borrowCapacity implemented into the SubAccount Nav * MP-1677: adjusted the SubAccount navigation * M1677: fixed the button and SearchInput component * MP-1674: fixed the NavLink component * MP-1674: fixed the SubAccount navigation * tidy: cleaning up the trading view * MP-1674: added withdraw and funding functions * MP-1674: worked on the AccountStats * MP-1671: modal work * MP-1647: improvised CreditAccount expander * tidy: fixed the page structure * MP-1758: finished the SearchInput layout * MP-1759: updated the semicircle graphs * MP-1759: SemiCircle to Gauge * fix: implemented animated numbers * tidy: refactor * MP-1759: added Tooltip to the Gauge * fix: replace animate={true} with animate * fix: fixed the Gauge timing * fix: updated the BorrowCapacity styles * fix: renamed SubAccount to Account * fix: Text should not be a button, Button should be * tidy: format * fix: Text no clicky * fix: replaced all the Text appearances with onClick
75 lines
1.9 KiB
TypeScript
75 lines
1.9 KiB
TypeScript
import classNames from 'classnames'
|
|
import React, { LegacyRef, ReactNode } from 'react'
|
|
|
|
interface Props extends React.HTMLProps<HTMLAnchorElement> {
|
|
children?: string | ReactNode
|
|
className?: string
|
|
color?: 'primary' | 'secondary' | 'tertiary' | 'quaternary'
|
|
externalLink?: boolean
|
|
textSize?: 'small' | 'medium' | 'large'
|
|
text?: string | ReactNode
|
|
uppercase?: boolean
|
|
}
|
|
|
|
const colorClasses = {
|
|
primary:
|
|
'text-primary hover:text-primary-highlight active:text-primary-highlight-10 focus:text-primary-highlight',
|
|
secondary:
|
|
'text-secondary hover:text-secondary-highlight active:text-secondary-highlight-10 focus:text-secondary-highlight',
|
|
tertiary:
|
|
'text-secondary-dark/60 hover:text-secondary-dark active:text-secondary-dark-10 focus:text-secondary-dark',
|
|
quaternary: 'hover:text-white active:text-white',
|
|
}
|
|
const textSizeClasses = {
|
|
small: 'text-sm',
|
|
medium: 'text-base',
|
|
large: 'text-lg',
|
|
}
|
|
|
|
const TextLink = React.forwardRef(function TextLink(
|
|
{
|
|
children,
|
|
className = '',
|
|
color = 'primary',
|
|
disabled,
|
|
externalLink,
|
|
href,
|
|
textSize = 'small',
|
|
text,
|
|
uppercase,
|
|
onClick,
|
|
...restProps
|
|
}: Props,
|
|
ref,
|
|
) {
|
|
return (
|
|
<a
|
|
className={classNames(
|
|
uppercase ? `${textSizeClasses[textSize]}-caps` : textSizeClasses[textSize],
|
|
colorClasses[color],
|
|
disabled && 'pointer-events-none opacity-50',
|
|
className,
|
|
)}
|
|
ref={ref as LegacyRef<HTMLAnchorElement>}
|
|
target={externalLink ? '_blank' : '_self'}
|
|
rel='noreferrer'
|
|
onClick={
|
|
onClick && !href
|
|
? (e) => {
|
|
e.preventDefault()
|
|
if (disabled) return
|
|
onClick
|
|
}
|
|
: undefined
|
|
}
|
|
href={!href ? '#' : href}
|
|
{...restProps}
|
|
>
|
|
{text && !children && text}
|
|
{children && children}
|
|
</a>
|
|
)
|
|
})
|
|
|
|
export default TextLink
|