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

@dibsy-components/react-dibsy.js

v1.0.2

Published

Dibsy components for reactjs

Downloads

2

Readme

React Dibsy.js

React Dibsy.js is an embedded wrapper around Dibsy Components, allowing you to add checkout fields directly into your React Checkout.

Prerequisites

Install react-dibsy.js from the npm public registry.

npm i @dibsy-components/react-dibsy.js

Example

import React, { useState } from 'react'
import {
  DibsyClient,
  CardNumber,
  ExpiryDate,
  VerificationCode
} from '@dibsy-components/react-dibsy.js'

import ErrorsWrraper from './components/errors-wrraper'

// Take a look on the index.css to see how you can style the outer elements like .dibsy-component.is-valid

// Optional. If not provided, we will set en_US as a default value
const options = {
  locale: ''
}

// Custom style for components
var componentsOptions = {
  styles: {
    fontSize: '16px',
    color: '#3d3838',
    '&.is-invalid': {
      color: 'red'
    }
  }
  // You can add a custom placeholder
  // PlaceHolder: "custom placeholder" ,
}

const App = () => {
  //Set up the initial state of components..
  //You must respect the naming of each component in the card state
  const [cardState, setCardState] = useState({
    //cardHolder: {},
    cardNumber: {},
    expiryDate: {},
    verificationCode: {}
  })

  const [canSubmit, setCanSubmit] = useState(true)

  // get the state of each component from dibsy client via a callback.
  function getFieldState(data) {
    setCardState({
      ...data
    })
  }

  // submit the card data to get the result
  function submitPayment(e, onSubmit) {
    e.preventDefault()
    setCanSubmit(false)
    //if card data is valid, the result will be a card token... you can submit it to your backend api
    onSubmit().then((result) => {
      var token = result?.token
      var error = result?.error
      if (error) {
        alert(error?.message)
      } else {
        console.log(token)
      }
      setCanSubmit(true)
    })
  }

  return (
    <div className='outer-container'>
      <div className='inner-container'>
        <DibsyClient
          publicKey={'pk_test_pl078KnEzhAQwSSzTn51Bv__internal'}
          options={options}
          onEvent={getFieldState}
        >
          {({ onSubmit }) => (
            <div className='form'>
              <h1>Pay with Credit Card</h1>
              <div className='form-fields'>
                <div className='row'>
                  <div className='form-group form-group--card-number'>
                    <CardNumber
                      eventListener={'change'}
                      options={componentsOptions}
                    />
                    <ErrorsWrraper state={cardState.cardNumber} />
                  </div>
                </div>

                <div className='row'>
                  <div className='form-group form-group--expiry-date'>
                    <ExpiryDate
                      eventListener={'change'}
                      options={componentsOptions}
                    />
                    <ErrorsWrraper state={cardState.expiryDate} />
                  </div>

                  <div className='form-group form-group--verification-code'>
                    <VerificationCode
                      eventListener={'change'}
                      options={componentsOptions}
                    />
                    <ErrorsWrraper state={cardState.verificationCode} />
                  </div>
                </div>
              </div>

              <button
                id='submit-button'
                className='submit-button'
                type='submit'
                onClick={(e) => submitPayment(e, onSubmit)}
                disabled={!canSubmit}
              >
                {canSubmit ? 'submit' : 'sumbitting...'}
              </button>
            </div>
          )}
        </DibsyClient>
      </div>
    </div>
  )
}

export default App

License

MIT ©