@bothub-chat/ui
Version:
Bothub UI Components
2 lines (1 loc) • 947 B
JavaScript
import{jsx as o}from"react/jsx-runtime";import{useState as t,useEffect as i}from"react";import{useSpring as e}from"@react-spring/web";import{CopyIcon as r}from"../../../../icons/copy/index.js";import{CheckSmallIcon as c}from"../../../../icons/check-small/index.js";import{ActionButton as m}from"../action-button/index.js";import{MessageActionsButtonIconStyled as n}from"./styled.js";import"../../../../theme/index.js";import{useTheme as s}from"../../../../theme/hook.js";const l=({onCopy:l,tooltipLabel:p})=>{const a=s(),[f,u]=t(!1),[d,h]=t(),j=e({opacity:f?0:1,config:{duration:250}}),y=e({opacity:f?1:0,config:{duration:250}});return i((()=>()=>{d&&clearTimeout(d)}),[]),o(m,{onClick:()=>{d&&clearTimeout(d),u(!0),null==l||l({}),h(setTimeout((()=>u(!1)),1e3))},tooltipLabel:p,children:o(n,f?{style:y,children:o(c,Object.assign({},"custom"===a.scheme&&{fill:a.colors.custom.icon}))}:{style:j,children:o(r,{size:20})})})};export{l as CopyButton};