1.0.6 • Published 9 months ago

grapesjs-component-twitch v1.0.6

Weekly downloads
54
License
MIT
Repository
github
Last release
9 months ago

Grapesjs Component Twitch

Twitch embed component based on docs here.

Requires server for more accurate preview in the grapesjs editor

DEMO

HTML

<link href="https://unpkg.com/grapesjs/dist/css/grapes.min.css" rel="stylesheet">
<script src="https://unpkg.com/grapesjs"></script>
<script src="https://unpkg.com/grapesjs-component-twitch"></script>

<div id="gjs"></div>

JS

const editor = grapesjs.init({
  container: '#gjs',
  height: '100%',
  fromElement: true,
  plugins: ['grapesjs-component-twitch'],
});

CSS

body, html {
  margin: 0;
  height: 100%;
}

Summary

  • Plugin name: grapesjs-component-twitch
  • Components
    • twitch
  • Blocks
    • Twitch

Options

OptionDescriptionDefault
scriptTwitch embed scripthttps://embed.twitch.tv/embed/v1.js
blockOptions for twitch block{}
labelTwitch block labelTwitch
categoryTwitch block categoryBasic
channelPlaceholderChannel trait placeholderusername here
videoPlaceholderVideo trait placeholdervideo here
collectionPlaceholderCollection trait placeholdercollection here
propsCustomize component propsi => i

Download

  • CDN
    • https://unpkg.com/grapesjs-component-twitch
  • NPM
    • npm i grapesjs-component-twitch
  • GIT
    • git clone https://github.com/Ju99ernaut/grapesjs-component-twitch.git

Usage

Directly in the browser

<link href="https://unpkg.com/grapesjs/dist/css/grapes.min.css" rel="stylesheet"/>
<script src="https://unpkg.com/grapesjs"></script>
<script src="path/to/grapesjs-component-twitch.min.js"></script>

<div id="gjs"></div>

<script type="text/javascript">
  var editor = grapesjs.init({
      container: '#gjs',
      // ...
      plugins: ['grapesjs-component-twitch'],
      pluginsOpts: {
        'grapesjs-component-twitch': { /* options */ }
      }
      // ...
  });
</script>

Modern javascript

import grapesjs from 'grapesjs';
import plugin from 'grapesjs-component-twitch';
import 'grapesjs/dist/css/grapes.min.css';

const editor = grapesjs.init({
  container : '#gjs',
  // ...
  plugins: [plugin],
  pluginsOpts: {
    [plugin]: { /* options */ }
  }
  // or
  plugins: [
    editor => plugin(editor, { /* options */ }),
  ],
});

Development

Clone the repository

$ git clone https://github.com/Ju99ernaut/grapesjs-component-twitch.git
$ cd grapesjs-component-twitch

Install dependencies

$ npm i

Start the dev server

$ npm start

Build the source

$ npm run build

License

MIT