JSPM

twitter-component

1.0.2
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 8
  • Score
    100M100P100Q39061F
  • License MIT

A native DOM component wrapper for embedded tweets

Package Exports

  • twitter-component

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (twitter-component) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

twitter-component stability

npm version build status downloads js-standard-style

A native DOM component wrapper for embedded tweets.

Usage

// Vanilla JS example
var TwitterComponent = require('twitter-component')

var tweet1 = new TwitterComponent()
var tweet2 = new TwitterComponent()

document.body.appendChild(tweet1.render('https://twitter.com/uhhyeahbret/status/897603426518876161'))
document.body.appendChild(tweet2.render('https://twitter.com/yoshuawuyts/status/895338700531535878'))

Installation

$ npm install twitter-component

API

TwitterComponent = require('twitter-component)

Import TwitterComponent component class.

tweet = new TwitterComponent([opts])

Create a new instance of the twitter component. opts is an options objec that can have the following options:

{
  placeholder: true // Enables placeholder text while loading tweet cards
}

tweet.render(tweetURL)

Returns a div that, when mounted into the page, will be the target of twttr.widgets.createTweet. Mounting the DOM node returned by .render will also load platform.twitter.com/widgets.js into the page, and any other side-effects and visitor tracking implications that script brings along with it.

Twitter employees: Please release a module version of platform.twitter.com/widgets.js because this took 5 hours of freetime™ of just trying to get caught up with your ever changing API and widget ecosystem.

Native DOM component model powered by nanocomponent and nanomorph.

License

MIT