Giter VIP home page Giter VIP logo

multibutton-widget's Introduction

Виджет "Мультикнопка"

CircleCI

Структура

На 22-03-2019 структура следующая:

src/components
├── assets
│   ├── images
│   │   ├── bestsp.png
│   │   └── sliza.png
├── constants.js
├── hideWidgets.js
├── logger.js
├── widget.js
├── widget.scss
  • widget.js -- основной код виджета;
  • widget.scss -- верстка;
  • costants.js -- настроечные константы парсеров и виджета, все данные должны быть всегда здесь;
  • hideWidgets.js -- функция поиска на странице кнопок сторонних парсеров и их скрытие;
  • logger.js -- логгер, все сообщения в консоль должны быть только здесь;

Требуемые доработки

Все что требует допастройки прописываем тут:

// Grabli
// const script3 = document.createElement('script');
// Q-Parcer
// const script5 = document.createElement('script');

// // FIXME: Грабли не работает! Возможно нужен авторизованный виджет, data-uuid на это намекает
// script3.type = 'text/javascript';
// script3.src = 'https://grably-parser.ru/js/parser_widget.js';
// // script3.setAttribute('data-uuid', '0016f430-856c-50b8-aba6-54f61c5766b6');
// script3.setAttribute('data-position', 'position-bottom-left');
// script3.setAttribute('data-color', '#fdc049');
// script3.setAttribute(
//   'data-style',
//   'background-color: #fdc049; color: white'
// );
// // data-color="#fdc049" data-style="background-color: #fdc049; color: white"

// // FIXME: Q-Parcer требует регистрации сайта в каталоге
// script5.type = 'text/javascript';
// script5.async = true;
// script5.defer = true;
// script5.src =
//   'https://q-parser.ru/dist/widget.js?c=%232f353e&domain=&p=lc&run=false&tc=%23fff&u=0';

Как настраивать скрипт, когда у него нет src, а код прямо теге text:

// Важно!!!
// window.onload = function() {
// var s = document.createElement('script');
// s.type = 'text/javascript';
// var code = 'alert("hello world!");';
// try {
//   s.appendChild(document.createTextNode(code));
//   document.body.appendChild(s);
// } catch (e) {
//   s.text = code;
//   document.body.appendChild(s);
// }
// }

Дополнительные материалы

Создано на основе репозитория: https://github.com/seriousben/embeddable-react-widget

Embeddable React Widget

CircleCI codecov Greenkeeper badge

Easy creation of an embeddable widget. - https://seriousben.github.io/embeddable-react-widget

Features

  • Full ES6/ES2015 support (with Babel)
  • Package fonts, css, json, javascripts together into one single package (with Webpack)
  • No css styling conflicts between the host page and the widget (with https://github.com/premasagar/cleanslate)
  • Bookmarklet supported for fast testing and demonstration
  • User theming of widget
  • Obfuscating of the widget code
  • Unit Tested with code coverage enabled
  • Continuous Integration ready

Running the widget

Install dependencies

$ npm install

Start the development server

$ npm start
... server running at http://localhost:8080/

Run tests

$ npm test
... test output

Production build

$ npm run build
... create files in /dist

Roadmap

  • Widget as react app - index.html works (webpack, babel, react)
  • React widget (widget builder)
  • Webpack changed to output a library
  • Add tests
  • Add circleci integration
  • Add codecov integration for codecoverage
  • Production Build
  • Minified
  • Add greenkeeper
  • Bookmarklet
  • Reset / Cleanslate / No-conflicts of styles
  • Obfuscation
  • Theming support
  • Storyboard and docs
  • Integrate eslint with webpack

Background

What is an embeddable widget?

  • Usable using a simple <script> tag
  • Configurable with code
  • Themable

Why not in an iframe?

  • Interaction between the frame and the hosting page is tricky and not recommended
  • You can only display content within the iframe
  • iframe and content resizing is impossible
  • iframe sandboxing can result in missing functionalities

Read more

Read more about about widgets, react and scoping of css.

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.