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

@trustswap/web-widgets

v1.3.1

Published

Widget collection, built by Team Finance

Downloads

546

Readme

Team Finance widget collection

This is a collection of widgets related to Team Finance ecosystem.

Powered by

Getting Started

You will need:

  • NodeJS latest LTS version. Actually it also works with Node 18, but latest LTS is recommended. On Linux / Mac, we recommend using nodenv

Deploy with Docker

WIP, but the simplest command should be:

docker build -f Dockerfile -t tf-widgets .
docker run -it --rm -d -p 8080:80 --name=tf-widgets-impl tf-widgets

How to test locally

  1. Clone the project:
git clone https://github.com/trustswap/teamfinance-widgets.git
cd teamfinance-widgets
  1. Install dependencies:
npm i
  1. Add the pool info:

Create an .env file in the root of this project with following information. This is just a sample, you should bring your own pool id, chain id,... if you want to test with your own token. You can change the app.tsx file as a playground with the widget settings and props:

VITE_STAKING_POOL_ADDRESS="0x0f2A5800f9Da5Fc765D28d64b554036b58fA8156"
# Leo token
VITE_STAKING_POOL_ID=0
VITE_STAKING_CHAIN_ID=97
  1. Run the dev server
npm run build:library
npm run dev

Your dev server should be live in http://localhost:5173/ .

Usage

Using npm

Here’s how you can integrate the widget into your project:

Install the package:

npm i @trustswap/web-widgets

or

yarn add @trustswap/web-widgets

then use it:

import { StakingWidget } from "@trustswap/web-widgets";

const chainId = 97;
const poolAddress = "YOUR_CONTRACT_ADDRESS";
const poolId = 1;

export default function App() {
  return (
    <StakingWidget
      chainId={chainId}
      poolId={poolId}
      stakingPoolAddress={poolAddress}
      themeConfig={{
        primaryColor: "#bf6636",
        container: "#F6F6FA",
      }}
    />
  );
}

Alternatively, you can import the StakingWidget module only, so your bundle size will be smaller:

import StakingWidget from "@trustswap/web-widgets/staking";

Note that bundle size is quite large because of bundled styling (from Mantine) and the RainbowKit library. A trimmed version is planned.

Using embeddable JS script

Please refer to test.html for the usage. This project use Web Component so it can be used in any websites, not just React.

You need to add 2 HTML tags for it to work though. First is the script, it looks like:

<script
  src="https://widget.team.finance/dist/assets/js/staking-widget.js"
  type="module"
></script>

the second is the Web Component placeholder, which is like:

<staking-widget applicationId="test-1" />

Testing

This project uses Vitest and Playwright.

Inside that directory, you can run several commands:

Runs the end-to-end tests.

npx playwright test

Starts the interactive UI mode.

npx playwright test --ui

Runs the tests only on Desktop Chrome.

npx playwright test --project=chromium

Runs the tests in a specific file.

npx playwright test example

Runs the tests in debug mode.

npx playwright test --debug

Auto generate tests with Codegen.

npx playwright codegen

We suggest that you begin by typing:

npx playwright test

Contributing

  1. Checkout a branch from main branch and create a PR from there.
  2. Change the code.
  3. Run the lint, using npm run lint. Lefthook does this automatically for you but it's a good practice to do it usually.
  4. Create a PR with short but easy to understand description.
  5. If you want to make a release, bump the version in package.json. It will be auto-published if its version is different with current NPM version.