0.5.3 • Published 8 months ago

@peersky/next-web3-chakra v0.5.3

Weekly downloads
-
License
MIT
Repository
github
Last release
8 months ago

Web3 react components for Chakra on Next

React(18) components for chakra(2) using next(13).

This is a website building bricks package such as navbar, footer, cards, layouts etc.

It is intended to be used for Web3 specific projects - grants you a web3 provider interface, chain selector drop down, and allows to build generic smart contract interface by just pointing address and ABI. How cool is that?

Use case

https://peersky.github.io/daococoa/

How to use

Getting started

Install yarn add @peersky/next-web3-chakra

Create config.ts that has exports SITEMAP:

import { SiteMap, SiteMapItemType } from "@peersky/next-web3-chakra/dist/types";
export const SITEMAP: SiteMap = [
  {
    title: "Blog",
    path: "/blog",
    type: SiteMapItemType.CONTENT,
  }]

create your theme. Here is how you start with default theme:

import { default as defaultTheme } from "@peersky/next-web3-chakra/dist/theme/";

import { extendTheme } from "@chakra-ui/react";

const theme = extendTheme({
  ...defaultTheme,
  //Here can override library theme items
});

export default theme;

Wrap your application:

import { UIProvider, Web3Provider } from "@peersky/next-web3-chakra/dist/providers";
import { SITEMAP } from "./config";
import theme from "./theme";
....
 <ChakraProvider theme={theme}>
      {/* <Fonts /> */}
      <Web3Provider>
        <UIProvider config={{ SITEMAP: SITEMAP }}>{props.children}</UIProvider>
      </Web3Provider>
</ChakraProvider>

Layouts

This package does not use next13 layouts. Instead old fashioned way is preserved. Use as follows to ensure items defined in layouts do not rerender when you switch between pages:

import { getLayout } from "@peersky/next-web3-chakra/dist/layouts/BlogLayout";
const Blog = <div>lorem<div>
Blog.getLayout = getLayout();
export default Blog;

Components

Import from @peersky/next-web3-chakra/dist/components see inside repository for more details

Providers

Import from @peersky/next-web3-chakra/dist/providers

UI Provider gives you general information about state of UI:

export interface UIProviderInterface {
  sidebarVisible: boolean | undefined;
  searchBarActive: boolean | undefined;
  isMobileView: boolean | undefined;
  sidebarCollapsed: boolean | undefined;
  sidebarToggled: boolean | undefined;
  searchTerm: string | undefined;
  setSearchBarActive: Function;
  setSidebarCollapsed: Function;
  setSearchTerm: Function;
  setSidebarToggled: Function;
  setSidebarVisible: Function;
  sessionId: string | undefined;
  webSiteConfig: WebSiteConfig;
}

Web3 Provider gives a convinient access to blockchain related operations:

export interface Web3ProviderInterface {
  web3: Web3; //web3js
  onConnectWalletClick: Function;
  buttonText: String;
  WALLET_STATES: WalletStatesInterface; //onboard/conect/connected/unknown-chain
  account: string; //address
  chainId: number;
  defaultTxConfig: Object;
  // signAccessToken: Function;
  getMethodsABI: typeof GetMethodsAbiType; //Takes contract ABI and returns method with given name
  changeChain: typeof ChangeChain; //Request wallet to switch chain
  targetChain: ChainInterface | undefined; //Desired chain
  getChainFromId: typeof getChainFromId; //Read chain name from chain id
}

Why there is no <you_name_it>

Author works on this package for pure enthusiasm. If you want to contribute or request a feature: please contact on github: https://github.com/peersky/daococoa/issues

Fund

You can fund this project to make it more fun.

0.3.6

9 months ago

0.5.3

8 months ago

0.3.5

9 months ago

0.3.8

9 months ago

0.3.7

9 months ago

0.4.1

8 months ago

0.4.0

8 months ago

0.5.2

8 months ago

0.3.4

10 months ago

0.5.1

8 months ago

0.3.0

11 months ago

0.2.1

11 months ago

0.1.2

11 months ago

0.2.0

11 months ago

0.1.8

11 months ago

0.1.7

11 months ago

0.3.2

11 months ago

0.2.3

11 months ago

0.1.4

11 months ago

0.3.1

11 months ago

0.2.2

11 months ago

0.1.3

11 months ago

0.1.6

11 months ago

0.3.3

11 months ago

0.2.4

11 months ago

0.1.5

11 months ago

0.1.0

1 year ago

0.0.1

1 year ago

0.0.11

2 years ago

0.0.10

2 years ago

0.0.9

2 years ago

0.0.8

2 years ago

0.0.7

2 years ago

0.0.6

2 years ago

0.0.5

2 years ago

0.0.4

2 years ago

0.0.3

2 years ago

0.0.2

2 years ago