1.4.0 • Published 7 years ago
@tokenjs/widget v1.4.0
TokenJS Widget
Demo
Installation
npm install @tokenjs/widgetoryarn add @tokenjs/widgetor grab from CDN:Initialize widget:
import TokenJS from 'tokenjs' const tokenJs = new TokenJS({ apiKey: '<YOUR-API-KEY>', campaignId: '<YOUR-CAMPAIGN-id>', })Open the widget on some user action:
tokenJs.open()
API
Constructor options
new TokenJS({
// (required) API key
apiKey: '',
// (required) Campaign ID
campaignId: '',
// (optional) Checkout URL
checkoutUrl: '',
// (optional) Text to display in widget’s header
title: '',
// (optional) Theme
theme: {
// you can override any of the following defaults:
background: '#fff',
muted: '#f5f5f5',
text: '#4a4a4a',
textLight: '#7a7a7a',
link: '#3273dc',
primary: '#00d1b2',
primaryInverted: '#fff',
secondary: '#209cee',
secondaryInverted: '#fff',
success: '#23d160',
successInverted: '#fff',
warning: '#ff8838',
warningInverted: '#fff',
danger: '#ff3860',
dangerInverted: '#fff',
ethereum: '#454b72',
ethereumInverted: '#fff',
bitcoin: '#eb973d',
bitcoinInverted: '#fff',
bitcoinCash: '#e48f39',
bitcoinCashInverted: '#fff',
litecoin: '#bebebe',
litecoinInverted: '#fff',
},
})Instance methods
open()– opens the widgetembed(container)– renders the widget inside thecontainerclose()– closes the widgetupdate({ title, theme })– updates initialization options on an existing widgetdestroy()– destroys instance of the widget
Development
yarninstalls dependenciesyarn startstarts dev server