mirror of
https://github.com/abhijithvijayan/web-extension-starter.git
synced 2026-03-20 01:37:46 +01:00
feat: add react components for Popup & Options
This commit is contained in:
parent
0c501a5232
commit
fc7e064726
7
src/Options/Options.tsx
Normal file
7
src/Options/Options.tsx
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
import React from 'react';
|
||||||
|
|
||||||
|
const Options = () => {
|
||||||
|
return <div>Hello World</div>;
|
||||||
|
};
|
||||||
|
|
||||||
|
export default Options;
|
||||||
6
src/Options/index.tsx
Normal file
6
src/Options/index.tsx
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
import React from 'react';
|
||||||
|
import ReactDOM from 'react-dom';
|
||||||
|
|
||||||
|
import Options from './Options';
|
||||||
|
|
||||||
|
ReactDOM.render(<Options />, document.getElementById('options-root'));
|
||||||
7
src/Popup/Popup.tsx
Normal file
7
src/Popup/Popup.tsx
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
import React from 'react';
|
||||||
|
|
||||||
|
const Popup = () => {
|
||||||
|
return <div>Hello world</div>;
|
||||||
|
};
|
||||||
|
|
||||||
|
export default Popup;
|
||||||
6
src/Popup/index.tsx
Normal file
6
src/Popup/index.tsx
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
import React from 'react';
|
||||||
|
import ReactDOM from 'react-dom';
|
||||||
|
|
||||||
|
import Popup from './Popup';
|
||||||
|
|
||||||
|
ReactDOM.render(<Popup />, document.getElementById('popup-root'));
|
||||||
@ -1 +0,0 @@
|
|||||||
console.log('Hello World from options main file!');
|
|
||||||
@ -1,18 +0,0 @@
|
|||||||
import browser from 'webextension-polyfill';
|
|
||||||
|
|
||||||
document.addEventListener('DOMContentLoaded', async () => {
|
|
||||||
const tabs = await browser.tabs.query({
|
|
||||||
active: true,
|
|
||||||
lastFocusedWindow: true,
|
|
||||||
});
|
|
||||||
|
|
||||||
const url = tabs.length && tabs[0].url;
|
|
||||||
|
|
||||||
const response = await browser.runtime.sendMessage({
|
|
||||||
msg: 'hello',
|
|
||||||
url,
|
|
||||||
});
|
|
||||||
|
|
||||||
// eslint-disable-next-line no-console
|
|
||||||
console.log(response);
|
|
||||||
});
|
|
||||||
@ -54,8 +54,8 @@ module.exports = {
|
|||||||
entry: {
|
entry: {
|
||||||
background: path.join(sourcePath, 'Background', 'index.ts'),
|
background: path.join(sourcePath, 'Background', 'index.ts'),
|
||||||
contentScript: path.join(sourcePath, 'ContentScript', 'index.ts'),
|
contentScript: path.join(sourcePath, 'ContentScript', 'index.ts'),
|
||||||
popup: './src/scripts/popup.js',
|
popup: path.join(sourcePath, 'Popup', 'index.tsx'),
|
||||||
options: './src/scripts/options.js',
|
options: path.join(sourcePath, 'Options', 'index.tsx'),
|
||||||
styles: [path.join(sourcePath, 'Popup', 'popup.scss'), path.join(sourcePath, 'Options', 'options.scss')],
|
styles: [path.join(sourcePath, 'Popup', 'popup.scss'), path.join(sourcePath, 'Options', 'options.scss')],
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user