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

bitcoin-price-component

v1.2.2

Published

Bitcoin Price Component for React/Typescript taking data from Coindesk API, very configurable and easy to use to display USD, GBP or EUR rates.

Downloads

41

Readme

Bitcoin Price Component for React

Bitcoin Price Component Scrrenshot

npm npm GitHub code size in bytes GitHub issues

This is a simple (but customisable) React component to display the current Bitcoin price in USD, GBP or EUR using the Coindesk API.

No styles or fancy javascript animations!

Installation

npm install bitcoin-price-component

Usage

Import the component into your React app:

import BitcoinPrice from 'bitcoin-price-component';

You can include some basic css for styling (optional)

import 'bitcoin-price-component/dist/BitcoinPrice.css';

Then use it in your component:

note: all the properties are optional, the ones specified below are the default values
function App() {
  return (
    <div>
      <BitcoinPrice
          containerTag="div" // options "div" | "span"
          label="Current Bitcoin Prices:"
          btnText="Refresh"
          labelLevel="h3" // options "h1" | "h2" | "h3" | "h4" | "h5" | "h6";
          incLabel={true}
          txtHtml="p" //options "p" | "span" | "div";
          incBtn={true}
          incUSD={true}
          incGBP={true}
          incEUR={true}
          incDisclaimer={true}
          incUpdateTime={true}
        />
    </div>
  );
}

Updated prices (increased, decreased or unchanged)

When updating/refreshing, an item attribute class of 'increased', 'decreased' or 'unchanged' is placed on the item for 2 seconds, this is so it can be styled, e.g. apply css green for .unchanged, red for .increased, yellow for .decreased

For example:

.increased {
  color: red;
  transition: color 0.5s ease-out; }
.increased::after {
  content: " ↑"; }

.decreased {
  color: yellow;
  transition: color 0.5s ease-out; }
.decreased::after {
  content: " ↓"; }

.unchanged {
  color: green;
  transition: color 0.5s ease-out; }
.unchanged::after {
  content: " ↔"; }

The button will also have disabled attribute for 3 seconds to avoid multiple clicking

Example button css

button.bpc-refresh {
  background-color: #ccc;
  border: 1px solid #ccc;
  border-radius: 4px;
  color: #000;
  cursor: pointer;
  font-size: 12px;
  padding: 5px 10px; }
  button.bpc-refresh:hover {
    background-color: #aaa;
    border: 1px solid #aaa; }

.bpc-refresh:disabled {
  background-color: grey;
  cursor: not-allowed; }

Live Demo

You can see this component in action at LayerFi.

I have also created a Wordpress plugin based on this npm package, you can find it here... Wordpress bitcoin plugin

About the Author

Abel Rogers - A seasoned web developer. You can find more about him and his projects:

License

This project is licensed under the ISC License.