UNPKG

@while-and-for/tremor-react

Version:

The React library to build dashboards faster.

3 lines (2 loc) 1.2 kB
'use client'; import{__rest as e}from"tslib";import t from"react";import{DeltaTypes as r,Sizes as s}from"../../../lib/constants.js";import{spacing as i}from"../../../lib/spacing.js";import{makeClassName as a,mapInputsToDeltaType as o}from"../../../lib/utils.js";import{tremorTwMerge as l}from"../../../lib/tremorTwMerge.js";import{colors as n,iconSizes as m,deltaIcons as c,badgeProportionsWithText as f,badgeProportionsIconOnly as p}from"./styles.js";const d=a("BadgeDelta"),g=t.forwardRef(((a,g)=>{const{deltaType:h=r.Increase,isIncreasePositive:u=!0,size:x=s.SM,children:b,className:j}=a,w=e(a,["deltaType","isIncreasePositive","size","children","className"]),N=c[h],y=o(h,u),v=b?f:p;return t.createElement("span",Object.assign({ref:g,className:l(d("root"),"w-max flex-shrink-0 inline-flex justify-center items-center cursor-default rounded-tremor-full",n[y].bgColor,n[y].textColor,v[x].paddingX,v[x].paddingY,v[x].fontSize,j)},w),t.createElement(N,{className:l(d("icon"),"shrink-0",b?l(i.twoXs.negativeMarginLeft,i.xs.marginRight):m[x].height,m[x].width)}),b?t.createElement("p",{className:l(d("text"),"text-sm whitespace-nowrap")},b):null)}));g.displayName="BadgeDelta";export{g as default};