The MightyIframeIntegration
package allows you to integrate an iframe-based sidebar into your web application. This sidebar can be triggered by any element on your page and supports both desktop and mobile views.
To use the MightyIframeIntegration
package, include the following script in your HTML file:
If you are using React, you can install the package via npm:
npm install mightyiframeintegration
Once installed, you can use React components like MightyWidget and MightyPage. Note: All widgets must be wrapped in MightyWrapper for proper initialization.
import React from 'react';
import ReactDOM from 'react-dom';
import App from './App.tsx';
import './index.css';
import { MightyWrapper } from 'mightyiframeintegration';
ReactDOM.render(
<React.StrictMode>
<MightyWrapper>
<App />
</MightyWrapper>
</React.StrictMode>,
document.getElementById('root')
);
MightyWrapper ensures proper initialization of all widgets in your application.
MightyWidget is a React component that allows embedding a sidebar widget, which opens when a button or another element is clicked.
Example usage:
import React from 'react';
import { MightyWidget } from 'mightyiframeintegration';
const App = () => {
return (
<div>
<MightyWidget partnerId="Magic_Ball" targetUrl="https://app.mighty.study/courses/123/456/789" theme="light">
<button>Click to Learn</button>
</MightyWidget>
</div>
);
};
export default App;
Parameters:
- partnerId (required): The partner ID for displaying content.
- targetUrl (optional): The URL of the course to display.
- percent (optional): The width percentage for displaying the sidebar.
- theme (optional): The theme for displaying the widget (dark or light).
MightyPage is a React component that allows embedding a page with an iframe to display content from the Mighty platform based on parameters.
Example usage:
import React from 'react';
import { MightyPage } from 'mightyiframeintegration';
const App = () => {
return (
<div style={{ width: '100%', height: '100vh' }}>
<MightyPage partnerId="Magic_Ball" targetUrl="https://app.mighty.study/courses/123/456/789" theme="dark" />
</div>
);
};
export default App;
Parameters:
- partnerId (required): The partner ID for displaying content.
- targetUrl (optional): The URL of the course to display.
- theme (optional): The theme for displaying the widget (dark or light).
If you are not using React and want to use web components directly in HTML, you can load the package via CDN using unpkg in head tag:
<head>
<script src="https://unpkg.com/mightyiframeintegration@latest/dist/mightyIframeIntegration.js"></script>
</head>
This will load the web components mighty-widget and mighty-page, which you can use in your HTML code.
You must call the authorizePackage function to initialize the package:
<script>
document.addEventListener('DOMContentLoaded', function() {
mightyIframeIntegration.authorizePackage('dark'); // Initialize the package with a theme
});
</script>
is a web component similar to the React version. It allows adding a sidebar widget, which opens when elements inside it are clicked.
Example usage:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<script src="https://unpkg.com/mightyiframeintegration@latest/dist/mightyIframeIntegration.js"></script>
<script>
document.addEventListener('DOMContentLoaded', function() {
mightyIframeIntegration.authorizePackage('dark');
});
</script>
</head>
<body>
<mighty-widget partnerid="Magic_Ball" targeturl="https://app.mighty.study/courses/123/456/789" theme="light">
<button>Click to Learn</button>
</mighty-widget>
</body>
</html>
- partnerid (required): The partner ID for displaying content.
- targeturl (optional): The URL of the course to display.
- percent (optional): The width percentage for displaying the sidebar.
- theme (optional): The theme for displaying the widget (dark or light).
is a web component that allows displaying content via an iframe.
Example usage:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<script src="https://unpkg.com/mightyiframeintegration@latest/dist/mightyIframeIntegration.js"></script>
<script>
document.addEventListener('DOMContentLoaded', function() {
mightyIframeIntegration.authorizePackage('dark');
});
</script>
</head>
<body>
<mighty-page partnerid="Magic_Ball" targeturl="https://app.mighty.study/courses/123/456/789" theme="dark" style="width: 100%; height: 100vh;">
</mighty-page>
</body>
</html>
- partnerid (required): The partner ID for displaying content.
- targeturl (optional): The URL of the course to display.
- theme (optional): The theme for displaying the widget (dark or light).
- MightyWidget: Used for creating clickable widgets that open a sidebar with content.
- MightyPage: Used for displaying a page with content in an iframe.