1.2.2 • Published 6 months ago

bitcoin-price-component v1.2.2

Weekly downloads
-
License
ISC
Repository
github
Last release
6 months ago

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.

1.2.2

6 months ago

1.2.1

7 months ago

1.2.0

7 months ago

1.1.1

7 months ago

1.1.0

7 months ago

1.0.24

7 months ago

1.0.23

7 months ago

1.0.22

7 months ago

1.0.21

7 months ago

1.0.20

7 months ago

1.0.19

7 months ago

1.0.18

7 months ago

1.0.17

7 months ago

1.0.16

7 months ago

1.0.15

7 months ago

1.0.14

7 months ago

1.0.13

7 months ago

1.0.10

7 months ago

1.0.9

7 months ago

1.0.8

7 months ago

1.0.7

7 months ago

1.0.6

7 months ago

1.0.5

7 months ago

1.0.4

7 months ago

1.0.3

7 months ago

1.0.2

7 months ago

1.0.1

7 months ago

1.0.0

7 months ago