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

@pacta-app/react-components

v1.5.3

Published

Put some Drizzle on your React components.

Downloads

7

Readme

@drizzle/react-components

A set of useful components for common UI elements.

Components

We provide components that support the React 16.3+ context API and also the legacy context API. The legacy context components will be deprecated in 2.0 with breaking changes to the @drizzle/react-components API. We recommend usage of the new context components where possible.

For 1.x.x this is how you import the different components:

React 16.3+ Context Components

import { newContextComponents } from "@drizzle/react-components";
const { AccountData, ContractData, ContractForm } = newContextComponents;

LoadingContainer is not provided with the new context components currently. Also note that you must pass in drizzle and drizzleState for each of these components.

Legacy Context Components

import {
  AccountData,
  ContractData,
  ContractForm,
  LoadingContainer
} from "@drizzle/react-components";

Refer to the included test apps for usage examples.

LoadingContainer (Legacy only)

This component wraps your entire app (but within the DrizzleProvider) and will show a loading screen until Drizzle, and therefore web3 and your contracts, are initialized.

loadingComp (component) The component displayed while Drizzle initializes.

errorComp (component) The component displayed if Drizzle initialization fails.

AccountData

accountIndex (number, required) Index of account from which to retrieve balance.

units (string) Unit to display either value in. Default is wei. See full list of units here in the web3 documentation.

precision (number) The number of digits after the decimal point to display.

ContractData

contract (string, required) Name of the contract to call.

method (string, required) Method of the contract to call.

methodArgs (array) Arguments for the contract method call. EX: The address for an ERC20 balanceOf() function. The last argument can optionally be an options object with the typical form, gas and gasPrice keys.

hideIndicator (boolean) If true, hides the loading indicator during contract state updates. Useful for things like ERC20 token symbols which do not change.

toUtf8 (boolean) Converts the return value to a UTF-8 string before display.

toAscii (boolean) Converts the return value to an Ascii string before display.

render (function with one argument) Render property, takes the value in the argument and returns render output.

ContractForm

contract (string, required) Name of the contract whose method will be the basis the form.

method (string, required) Method whose inputs will be used to create corresponding form fields.

sendArgs (object) An object specifying options for the transaction to be sent; namely: from, gasPrice, gas and value. Further explanataion of these parameters can be found here in the web3 documentation.

labels (array) Custom labels; will follow ABI input ordering. Useful for friendlier names. For example "_to" becoming "Recipient Address".

render (function) Render prop for rendering custom components. It receives a single object with the fields: inputs, inputTypes, state, handleInputChange, handleSubmit, as arguments and returns render output.

Test Apps

Refer to the test apps to learn more about how to use DRC.

A test app targeting the React 16.3+ context API has been included at ./test-app. And one targeting the legacy context API can be found at test-app-legacy-context.

Installation

  1. cd ./test-app
  2. Install dependencies: npm install
  3. Start your development blockchain: truffle develop
  4. (In Truffle develop console) Compile contracts: compile
  5. (In Truffle develop console) Migrate contracts: migrate
  6. In another terminal window: cd ./app
  7. Install dependencies: npm install
  8. Start dev server: npm start

NOTE: Make sure to migrate --reset your contracts and reset your Metamask account when switching between test apps, otherwise errors may occur.