Git Product home page Git Product logo

ronin-modal's Introduction

Ronin Modal

Ronin Modal is a framework agnostic UI library that simplifies the integration of the Ronin Wallet connection with websites.

Ronin Modal supports W3Vm and Wagmi v2.

Installation

npm install @roninbuilders/modal

Implementation

  1. Import the chain you want to use, you can select Ronin mainnet or Saigon testnet.

  2. Get a free project ID from WalletConnect Cloud. This is used for mobile connection.

  3. Call the createRoninModal function on top of your application.

import { ronin, saigon, createRoninModal } from "@roninbuilders/modal"

createRoninModal({
	chain: saigon,
	projectId: "WALLETCONNECT_PROJECT_ID",
})

Now you can call the web component button anywhere in your application. This web component doesn't require importing and its CSS style can be overwritten.

<ronin-button/>

if you are NOT using React.js, you can use the W3Vm Core functions to get the user address and the provider.

React

Install W3Vm React to use hooks that are connected to the Ronin Modal.

npm install @w3vm/react

Use react hooks to get the wallet provider and address. These values are reactive and depend on the Ronin Modal state.

import './App.css'
import { ronin, saigon, createRoninModal } from "@roninbuilders/modal"
import { getW3Address, getW3Provider } from '@w3vm/react'

createRoninModal({
	chain: saigon,
	projectId: "WALLETCONNECT_PROJECT_ID",
})

export default function App() {
	const address = getW3Address()
	const provider = getW3Provider()

	console.log(address, provider)

  return <ronin-button/>
}

You can wrap the provider with any ethereum library such as Ethers, Viem or Web3js.

Server Side Rendering

If you are using a Meta-frameworks like Next.js with SSR, you can use the SSR flag to avoid hydration mismatch errors.

  1. Add the SSR param when calling createRoninModal
  2. This function will now return an object, we can call it w3props (or any name).
  3. Import the W3 component from W3Vm React and place it on top of your application.
import { saigon, createRoninModal } from "@roninbuilders/modal"
import { W3 } from '@w3vm/react'

const w3props = createRoninModal({
	chain: saigon,
	projectId: "WALLETCONNECT_PROJECT_ID",
	SSR: true,
})

export default function App({ Component, pageProps }: AppProps) {
  return (
    <>
      <W3 {...w3props} /> { /* Required when SSR: true */ }
      <Component {...pageProps} />
    </>
  )
}

Run the monorepo

pnpm install
pnpm run build

open two terminals

  • in the first one type:
cd packages/modal-w3vm
pnpm run watch

or

cd packages/modal-wagmi-v2
pnpm run watch
  • in the second terminal run
pnpm run dev:w3vm

or

pnpm run dev:wagmi

Now you can open localhost and see the changes in the package reflected on these examples.

ronin-modal's People

Contributors

glitch-txs avatar izayl avatar

Stargazers

Alex avatar Gleb Skibitsky avatar  avatar

Watchers

 avatar  avatar

ronin-modal's Issues

Add Theming

Add theming an customization options for the button and the modal

Unify UI into a package

As of today, wagmi and w3vm modals are separeted, we can unify the UI of the modal into a single package an wrap it into another with the logic of each connector library

Add animations

  • Animate flow from different views
  • Animate mobile when modal opens/closes
  • Animate icons when connection is rejected
  • Any other ideas for animation...

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.