Giter VIP home page Giter VIP logo

react-carbon's Introduction

react-carbon

A React component for using both custom and standard Carbon ads.

Installation

npm i react-carbon --save

Usage

The component takes these arguments:

name - The ID given to the wrapper placement - The placement ID from Carbon serve - The served ad ID from Carbon script - Loading a static script for custom ads fallback - Fallback JSX if ad cannot be loaded (e.g. due to an adblocker)

Standard ads

import React, { Component } from "react";
import Carbon from "react-carbon";

class App extends Component {
  render() {
    return (
      ...
      <Carbon name="carbon-home" placement="pixelmobco" serve="CK7I42Q7" />;
      ...
    );
  }
}

export default App;

Custom ads

import React, { Component } from "react";
import Carbon from "react-carbon";

class App extends Component {
  render() {
    return (
      ...
      <Carbon
        name="carbon-search"
        serve="CK7I42JE"
        script="/native_banner.js"
      />
      ...
    )
  }
}

export default App;

An example of native_banner.js:

(function(){  
  if(typeof _bsa !== 'undefined' && _bsa) {
      _bsa.init('custom', 'CK7I42JE', 'placement:pixelmobco',
        {
          target: '#carbon-search',
          template: `
            <a href="##link##" class="native-banner" style="background: linear-gradient(-30deg, ##backgroundColor##E5, ##backgroundColor##E5 45%, ##backgroundColor## 45%) #fff;">
              <div class="native-main">
                <img class="native-img" img src="##logo##">
                <div class="native-details" style="color: ##textColor##">
                  <span class="native-company">Sponsored by ##company##</span>
                  <span class="native-desc">##description##</span>
                </div>
                <span class="native-cta" style="color: ##ctaTextColor##; background-color: ##ctaBackgroundColor##;">##callToAction##</span>
              </div>
            </a>
            <a class="native-via" href="##adViaLink##">Ads via BuySellAds</a>
          `,
        }
      );
    }
})();

react-carbon's People

Contributors

nehalist avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.