UNPKG

@frak-labs/components

Version:

Frak Wallet components, helping any person to interact with the Frak wallet.

40 lines (37 loc) 2.57 kB
import{d as e,i as t,l as n,m as r,n as i,o as a,s as o,t as s,u as c}from"./usePlacement.BgMXY5CX.js";import{t as l}from"./useReward.BtBpuMwt.js";import{t as u}from"./embeddedWallet.BS-9u4Be.js";function d(e){return c(`svg`,{fill:`none`,height:`1em`,viewBox:`0 0 28 28`,width:`1em`,xmlns:`http://www.w3.org/2000/svg`,...e,children:[c(`title`,{children:`Gift icon`}),c(`path`,{d:`m23.1427 13.9999v11.4285h-18.2857v-11.4285m9.1429 11.4285v-17.14282m0 0h-5.1429c-.75776 0-1.48448-.30102-2.0203-.83684s-.83684-1.26255-.83684-2.02031.30102-1.48448.83684-2.0203 1.26254-.83684 2.0203-.83684c4 0 5.1429 5.71429 5.1429 5.71429zm0 0h5.1428c.7578 0 1.4845-.30102 2.0203-.83684s.8369-1.26255.8369-2.02031-.3011-1.48448-.8369-2.0203-1.2625-.83684-2.0203-.83684c-4 0-5.1428 5.71429-5.1428 5.71429zm-11.42861 0h22.85711v5.71432h-22.85711z`,stroke:`#fff`,"stroke-linecap":`round`,"stroke-linejoin":`round`})]})}function f(){`vibrate`in navigator&&navigator.vibrate(10)}function p(e,t){f(),u(e,t)}function m({placement:e,classname:u=``,useReward:f,targetInteraction:m}){let h=s(e),g=a(()=>h?.targetInteraction===void 0?m:h.targetInteraction,[h?.targetInteraction,m]),_=a(()=>f===!0,[f]),{shouldRender:v,isHidden:y,isClientReady:b}=t(),{reward:x}=l(_&&b,g),[S,C]=o(`right`);if(n(()=>{let e=h?.components?.buttonWallet?.position,t=window.FrakSetup?.modalWalletConfig?.metadata?.position;C(e??t??`right`)},[h?.components?.buttonWallet?.position]),!v||y)return null;let w=[`button`,`button__fadeIn`,S===`left`?`button__left`:`button__right`,u].filter(Boolean).join(` `);return c(r,{children:[c(`style`,{children:i(` .button { all: unset; position: fixed; bottom: 20px; z-index: 2000000; display: flex; justify-content: center; align-items: center; background-color: #3e557e; width: 45px; height: 45px; border-radius: 50%; cursor: pointer; text-align: center; font-size: 24px; } .button__left { left: 20px; } .button__right { right: 20px; } .reward { position: absolute; top: -4px; right: 27px; padding: 2px 3px; border-radius: 5px; background: #ff3f3f; font-size: 9px; color: #fff; font-weight: 600; white-space: nowrap; line-height: 9px; } `,h?.components?.buttonWallet?.css)}),c(`button`,{type:`button`,"aria-label":`Open wallet`,part:`button`,disabled:!b,class:w,onClick:()=>{p(g,e)},children:[c(d,{}),x&&c(`span`,{class:`reward`,children:x})]})]})}e(m,`frak-button-wallet`,[`placement`,`classname`,`useReward`,`targetInteraction`],{shadow:!0});export{m as ButtonWallet};