({
size = "sm",
color = "primary",
children,
className,
noTextPadding,
iconLeading: IconLeading,
iconTrailing: IconTrailing,
isDisabled: disabled,
isLoading: loading,
showTextWhileLoading,
...props
})
| 173 | (props: LinkProps): ReactElement<LinkProps>; |
| 174 | (props: ButtonProps): ReactElement<ButtonProps>; |
| 175 | } = ({ |
| 176 | size = "sm", |
| 177 | color = "primary", |
| 178 | children, |
| 179 | className, |
| 180 | noTextPadding, |
| 181 | iconLeading: IconLeading, |
| 182 | iconTrailing: IconTrailing, |
| 183 | isDisabled: disabled, |
| 184 | isLoading: loading, |
| 185 | showTextWhileLoading, |
| 186 | ...props |
| 187 | }) => { |
| 188 | const href = "href" in props ? props.href : undefined; |
| 189 | |
| 190 | const isIcon = (IconLeading || IconTrailing) && !children; |
| 191 | const isLinkType = ["link-gray", "link-color", "link-destructive"].includes(color); |
| 192 | |
| 193 | noTextPadding = isLinkType || noTextPadding; |
| 194 | |
| 195 | const commonChildren = ( |
| 196 | <> |
| 197 | {/* Leading icon */} |
| 198 | {isValidElement(IconLeading) && IconLeading} |
| 199 | {isReactComponent(IconLeading) && <IconLeading data-icon="leading" className={styles.common.icon} />} |
| 200 | |
| 201 | {loading && ( |
| 202 | <svg |
| 203 | fill="none" |
| 204 | data-icon="loading" |
| 205 | viewBox="0 0 20 20" |
| 206 | className={cx(styles.common.icon, !showTextWhileLoading && "absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2")} |
| 207 | > |
| 208 | {/* Background circle */} |
| 209 | <circle className="stroke-current opacity-30" cx="10" cy="10" r="8" fill="none" strokeWidth="2" /> |
| 210 | {/* Spinning circle */} |
| 211 | <circle |
| 212 | className="origin-center animate-spin stroke-current" |
| 213 | cx="10" |
| 214 | cy="10" |
| 215 | r="8" |
| 216 | fill="none" |
| 217 | strokeWidth="2" |
| 218 | strokeDasharray="12.5 50" |
| 219 | strokeLinecap="round" |
| 220 | /> |
| 221 | </svg> |
| 222 | )} |
| 223 | |
| 224 | {children && ( |
| 225 | <span data-text className={cx("transition-inherit-all", !noTextPadding && "px-0.5")}> |
| 226 | {children} |
| 227 | </span> |
| 228 | )} |
| 229 | |
| 230 | {/* Trailing icon */} |
| 231 | {isValidElement(IconTrailing) && IconTrailing} |
| 232 | {isReactComponent(IconTrailing) && <IconTrailing data-icon="trailing" className={styles.common.icon} />} |
nothing calls this directly
no test coverage detected