npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

woofi-swap-widget

v0.2.45

Published

Downloads

268

Readme

Woofi Swap Widget

Quick Start

Installation

npm add woofi-swap-widget

or

yarn add woofi-swap-widget

Usage

Initialize the Library with default wallet library(web3-onboard)

Use the minimum required config. There are more options available as detailed in the initialization section

//  main.js or index.js or other import file which will be called once
 import { init } from 'woofi-swap-widget'
 init()

Render the Library

// while target element is mounted, call the 'render' function
// component file
<template>
    <div id="swap" />
</template>
<script>
import { render } from 'woofi-swap-widget'
import 'woofi-swap-widget/dist/style.css' // import css
// on mounted lifecycle
onMounted(() => {
    render('#swap')
})
// or 
useEffect(() => {
    render('#swap') // render(el: string)
}, [])
</script>

Init Configuration

import { init } from 'woofi-swap-widget'
const options = {/** some options*/}
init(options)

Options

| name | type | required | default | values | description | |------------------|----------------------------|----------|---------------------------------------|--------------|------------------------------------------------------------------------------------------------------| | useUserWallet | Boolean | no | false | true/false | use user custom wallet, if it is true, will call the connectWallet and disconnectWallet function | | userAddress | String | no | '' | '0x11...111' | connected wallet address | | chainId | Hex String | no | '' | '0x123' | connected chain id | | provider | HttpProvider | no | | | connected http provider | | title | String | no | Swap | 'Swap' | widget's title | | allowChains | Array | no | [ethereum,avax, bsc, fantom,polygon,] | | allow chains to swap | | className | String | no | '' | | | | widgetExtraFeeRate | String | no | 0 | | | | widgetExtraFeeAddr | String | no | '' | | | | connectWallet | () => void | Promise; | no | | | custom connect wallet function | | disconnectWallet | () => void | Promise; | no | | | custom disconnect wallet function | | onSuccessNotify | function | no | | | Successful Notification function | | onErrorNotify | function | no | | | Error Notification function |

API

init: init(option)

render: render(el: string)

updateAddressAndProvider: (address: Address, provider: Provider, isForce?: boolean) => Promise;

updateConnectWallet: (connectWalletHandler) => void

updateDisconnectWallet: (disconnectWalletHandler) => void

Using the Library with custom wallet

First set the option useUserWallet into true, if custom connectWallet or custom disconnectWallet handler is ready, users can also set into options, like the below example:

import { init,render, updateConnectWallet, updateDisconnectWallet updateAddressAndProvider, } from 'woofi-swap-widget'
init({
    useUserWallet: true,
    connectWallet: () => {}
    disconnectWalet: () => {}
})

onMounted(() => {
    render('#swap')
})

while address and provider is ready()

watch(address, () => {
    if (address) {
     const provider = getProvider() // HttpProvider
     updateAddressAndProvider(address, provider)
    }
})

while functionconnectWallet and functiondisconnectWallet is ready

updateConnectWallet(connectWalletHandler)

updateDisconnectWallet(disconnectWalletHandler)

Style

There are provider some css variable for customize styles

Font
 --font-family: "DIN", "Helvetica Neue", Helvetica, system-ui, Arial,sans-serif;
Text
  --swap-text-primary-color: #73bef4;
  --swap-text-main-color: #ffffff;
  --swap-text-second-color: rgba(255, 255, 255, 0.8);
  --swap-text-three-color: #a8a8a8;
Btn
  --swap-btn-bg-color: linear-gradient(270deg, #59b0fe 0%, #26fefe 100%);
  --swap-btn-text-color: #282e3a;
Background
 --swap-bg-main-color: #1b2028;
  --swap-bg-second-color: #15181d;
  --swap-bg-three-color: #212630;
  --swap-bg-four-color: #282e3a;
Width
  --swap-wrapper-width: 470px;

Demo

More detail can see the demo