GithubHelp home page GithubHelp logo

jeffersonsimaogoncalves / vuejs-embedded-widget Goto Github PK

View Code? Open in Web Editor NEW

This project forked from labrodev/vuejs-embedded-widget

0.0 0.0 0.0 37 KB

In certain scenarios, integrating a Single Page Application as an embedded widget into external websites becomes necessary. This project addresses the challenges associated with creating a versatile Vue.js 3 widget that seamlessly integrates into any website without imposing specific conditions.

License: MIT License

JavaScript 28.76% CSS 4.25% HTML 4.90% Vue 62.09%

vuejs-embedded-widget's Introduction

Vue.js 3 Embedded Widget

Overview

In certain scenarios, integrating a Single Page Application as an embedded widget into external websites becomes necessary. This project addresses the challenges associated with creating a versatile Vue.js 3 widget that seamlessly integrates into any website without imposing specific conditions.

Features

  • Versatility: The widget is designed to be easily integrated into any website, maintaining visual aesthetics and workflow while remaining self-contained.

  • Isolation: The embedded widget ensures it remains isolated to prevent interference with the styling of the parent site or disruption of external site functions.

Technologies Used

Example Use Case

This project serves as a comprehensive example of transforming a Vue.js 3 Single Page Application into a fully functional embedded widget. The practical example demonstrates creating a countdown widget for tracking the time remaining until a specific date or event, such as the start of the New Year or the end of discount campaigns.

It should be use like this in external site:

  • include widget.js script in section of external site
  • include tag in section of external site with required attributes that apply countdown logic.

Like this:

So at the end you need to configure your web server virtual host to reach the widget.js (like http://yourhost.com/widget.js)

Installation

  1. Clone (or fork) this project
git clone [email protected]:labrodev/vuejs-widget-embedded.git
  1. Install packages
npm install
  1. Build widget.js
npx vite build

In /dist folder you may find compiled widget.js and styles.css files.

  1. Configure virtual host

Nginx example:

server {
     listen 80;

     root /var/www/vuejs-embedded-widget/dist;

     server_name yourhost;

     location / {
        try_files $uri $uri/ /index.html?$query_string;
     }
}

Make sure that virtual host works and yourhost/widget.js is reachable.

Usage

Implement embedded widget in your desired external site to check results.

Head Section:

<script src="http://yourhost.com/widget.js" defer></script>

Body Section:

<countdown-widget 
   date="2024-06-14" 
   title="Euro 2024 will start in"
   end="Euro 2024 is started!"
   color="#FF0000">
</countdown-widget>

Additional information

You may find detailed step-by-step guide how to turn Vue.js 3 application to embedded widget in our blog on Substack (don't forget to subscribe!)

Enjoy and thanks for your attention!

vuejs-embedded-widget's People

Contributors

labrodev 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.