-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6 from rezasohrabi/develop
Develop
- Loading branch information
Showing
12 changed files
with
94 additions
and
17 deletions.
There are no files selected for viewing
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,9 @@ | ||
import React from 'react'; | ||
import { createRoot } from 'react-dom/client'; | ||
import styles from '@assets/styles/index.css?inline'; | ||
import createShadowRoot from '@utils/createShadowRoot'; | ||
|
||
import Content from './Content'; | ||
import styles from './index.css?inline'; | ||
|
||
const container = document.createElement('div'); | ||
const shadow = container.attachShadow({ mode: 'open' }); | ||
const globalStyleSheet = new CSSStyleSheet(); | ||
globalStyleSheet.replaceSync(styles); | ||
|
||
shadow.adoptedStyleSheets = [globalStyleSheet]; | ||
document.body.appendChild(container); | ||
|
||
const root = createRoot(shadow); | ||
const root = createShadowRoot(styles); | ||
|
||
root.render(<Content />); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,20 @@ | ||
import React, { JSX } from 'react'; | ||
|
||
export default function Options(): JSX.Element { | ||
return <div className='container'>Options</div>; | ||
return ( | ||
<div id='my-ext' className='container' data-theme='light'> | ||
<button type='button' className='btn btn-outline'> | ||
Default | ||
</button> | ||
<button type='button' className='btn btn-outline btn-primary'> | ||
Primary | ||
</button> | ||
<button type='button' className='btn btn-outline btn-secondary'> | ||
Secondary | ||
</button> | ||
<button type='button' className='btn btn-outline btn-accent'> | ||
Accent | ||
</button> | ||
</div> | ||
); | ||
} |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,9 @@ | ||
import React from 'react'; | ||
import { createRoot } from 'react-dom/client'; | ||
import styles from '@assets/styles/index.css?inline'; | ||
import createShadowRoot from '@utils/createShadowRoot'; | ||
|
||
import Options from './Options'; | ||
|
||
import './index.css'; | ||
|
||
const root = createRoot(document.getElementById('my-ext-options-page')!); | ||
const root = createShadowRoot(styles); | ||
|
||
root.render(<Options />); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import React, { JSX } from 'react'; | ||
|
||
export default function Popup(): JSX.Element { | ||
return ( | ||
<div id='my-ext' className='container' data-theme='light'> | ||
<button type='button' className='btn btn-outline'> | ||
Default | ||
</button> | ||
<button type='button' className='btn btn-outline btn-primary'> | ||
Primary | ||
</button> | ||
<button type='button' className='btn btn-outline btn-secondary'> | ||
Secondary | ||
</button> | ||
<button type='button' className='btn btn-outline btn-accent'> | ||
Accent | ||
</button> | ||
</div> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<!doctype html> | ||
<html> | ||
<head> | ||
<meta charset="UTF-8" /> | ||
<title>my ext popup page</title> | ||
</head> | ||
|
||
<body> | ||
<div id="my-ext-popup-page"></div> | ||
<script type="module" src="./index.tsx"></script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import React from 'react'; | ||
import styles from '@assets/styles/index.css?inline'; | ||
import createShadowRoot from '@utils/createShadowRoot'; | ||
|
||
import Popup from './Popup'; | ||
|
||
const root = createShadowRoot(styles); | ||
|
||
root.render(<Popup />); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import { createRoot } from 'react-dom/client'; | ||
|
||
/** | ||
* Creates a shadow root with the specified styles and returns a React root in it. | ||
* @param {string} styles - CSS styles to be applied to the shadow root. | ||
* @returns {ReactRoot} - React root rendered inside the shadow root. | ||
*/ | ||
export default function createShadowRoot(styles: string) { | ||
// Create a container element to hold the shadow root | ||
const container = document.createElement('div'); | ||
|
||
// Attach a shadow root to the container element | ||
const shadow = container.attachShadow({ mode: 'open' }); | ||
|
||
// Create a new CSS style sheet and apply the specified styles | ||
const globalStyleSheet = new CSSStyleSheet(); | ||
globalStyleSheet.replaceSync(styles); | ||
|
||
// Apply the style sheet to the shadow root | ||
shadow.adoptedStyleSheets = [globalStyleSheet]; | ||
|
||
// Append the container element to the document body | ||
document.body.appendChild(container); | ||
|
||
// Return a React root created inside the shadow root | ||
return createRoot(shadow); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters