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

ordbit-connect

v1.1.2

Published

A suit web components for web3 applications

Downloads

253

Readme

Ordbit Connect

Ordbit-Connect is a suite of web components designed to facilitate the development of Web3 applications. These components can seamlessly integrate into leading frontend technologies such as React, Angular, Vue.js, as well as plain HTML. With Ordbit-Connect, developers can easily incorporate wallet connectivity and other functionalities into their applications, regardless of the chosen frontend framework.

Installation

Npm

You can install the package using npm

npm i ordbit-connect

Yarn

You can install the package using yarn

yarn add ordbit-connect

CDN

If you prefer to use a CDN, you can include [ordbit-connect] directly into your HTML file:

<!-- Replace 'x.x.x' with the desired version number,preferrably latest stable version -->
<script type="module" src="https://unpkg.com/[email protected]/umd/ordbit-wallet-connect.js"></script>

Components

The package consists of the following components

1. ordbit-connect-button

Description:

The ordbit-connect-button component serves as an entry point for users to connect their wallets. Upon clicking, it opens the ordbit-connect-modal, allowing users to connect their desired wallet.

Usage:

<ordbit-connect-button class="connect-btn"></ordbit-connect-button>

CSS Variables

Developers can use the following CSS variables to customize the styling of the ordbit-connect-button component:

  • --btn-bg-color: Background color of the button. (Default: orange)
  • --btn-border: Border of the button. (Default: none)
  • --btn-border-radius: Border radius of the button. (Default: 1rem)
  • --btn-box-shadow: Box shadow of the button. (Default: 0 0 5px #000)
  • --btn-width: Width of the button. (Default: 10rem)
  • --btn-height: Height of the button. (Default: 3rem)
  • --btn-modal-backdrop-bg: Background color of the modal backdrop. (Default: none)
  • --btn-modal-backdrop-border: Border of the modal backdrop. (Default: none)
  • --btn-modal-backdrop-color: Color of the modal backdrop. (Default: none)

2. ordbit-connect-modal

Description:

The ordbit-connect-modal component is a modal that lists supported wallets, allowing users to connect their desired wallet extension.

Functionality

Upon clicking on a supported wallet, the respective wallet extension is opened, enabling users to connect their wallet.

Supported Wallets

  • Unisat
  • Xverse
  • Leather
  • Okx

Events

Developers can listen for the following events to perform further operations. These events can be listened to from anywhere in the DOM, including from ordbit-connect-button:

  • WALLET_CONNECT_MODAL_CLOSED: Triggered when the modal is closed manually by the user. No data is passed to the callback. NOTE: this event is not propogated outside of modal.
  • WALLET_CONNECT_FAILED: Triggered when the user's attempt to connect a particular wallet fails or is aborted. Error information is passed to the callback.
  • WALLET_CONNECT_SUCCESS: Triggered when the user successfully connects the wallet. Wallet information is passed to the callback. The structure of wallet info is as follows:
{
  ordinalAddress: string;
  paymentAddress: string;
  provider: "NONE" | "UNISAT" | "XVERSE" | "OKX" | "LEATHER";
}

CSS Variables

Developers can use the following CSS variables to customize the styling of the ordbit-connect-modal component:

  • --connect-wallet-modal-border: Border of the modal. (Default: none)
  • --connect-wallet-modal-bg: Background image of the modal. (Default: none)
  • --connect-wallet-modal-bg-color: Background color of the modal. (Default: none)
  • --connect-wallet-modal-bg-color: Background color of the modal with alpha transparency. (Default: rgba(10, 10, 10, 0.8))
  • --connect-wallet-modal-heading-font-size: Font size of the modal heading. (Default: 1.5rem)
  • --connect-wallet-modal-font-family: Font family of the modal text. (Default: Calibri)
  • --connect-wallet-modal-heading-font-color: Font color of the modal heading. (Default: #fff)
  • --connect-wallet-modal-font-color: Font color of the modal text. (Default: #fff)

Example

element.addEventListener("WALLET_CONNECT_MODAL_CLOSED", () => {
  console.error("Wallet modal closed");
});

element.addEventListener("WALLET_CONNECT_FAILED", (error) => {
  console.error("Wallet connection failed:", error);
});

element.addEventListener("WALLET_CONNECT_SUCCESS", (walletInfo) => {
  console.log("Wallet connected successfully:", walletInfo);
  /*
    Output format:
    {
        ordinalAddress: '...',
        paymentAddress: '...',
        provider: 'UNISAT' // Example
    }
    */
});

Example Code

You can take the below code as reference to get started.

<!DOCTYPE html>

<html>
  <head>
    <meta charset="utf-8" />
    <title>Ordbit Connect</title>
    <script
      type="module"
      src="https://unpkg.com/[email protected]/umd/ordbit-wallet-connect.js"
    ></script>
  </head>
  <body>
    <ordbit-connect-button id="wallet-connect"
      >Connect Wallet</ordbit-connect-button
    >

    <script>
      function attachListeners() {
        const element = document.getElementById("wallet-connect");

        element.addEventListener("WALLET_CONNECT_SUCCESS", (event) => {
          const data = event.detail;
          console.log("success = ", data);
          event.stopPropagation();
        });

        element.addEventListener("WALLET_CONNECT_FAILED", (event) => {
          const data = event.detail;
          console.log("failed = ", data);
          event.stopPropagation();
        });

        element.addEventListener("WALLET_CONNECT_MODAL_CLOSED", (event) => {
          const data = event.detail;
          console.log("closed = ", data);
          event.stopPropagation();
        });
      }

      window.onload = function () {
        attachListeners();
      };
    </script>
  </body>
</html>