refactoring, using different pattern for page injection and reusing same pattern for both popup and content scripts
This commit is contained in:
16
src/views/components/CourseCatalogMain.tsx
Normal file
16
src/views/components/CourseCatalogMain.tsx
Normal file
@@ -0,0 +1,16 @@
|
||||
import React, { useEffect, useMemo } from 'react';
|
||||
import { bMessenger } from 'src/shared/messages';
|
||||
import { SiteSupport } from '../lib/getSiteSupport';
|
||||
import { Button } from './common/Button/Button';
|
||||
|
||||
interface Props {
|
||||
support: SiteSupport[];
|
||||
}
|
||||
|
||||
export default function CourseCatalogMain(props: Props) {
|
||||
const openGoogle = () => {
|
||||
bMessenger.openNewTab({ url: 'https://google.com' });
|
||||
};
|
||||
|
||||
return <Button onClick={openGoogle}>{props.support.join(',')}</Button>;
|
||||
}
|
||||
5
src/views/components/PopupMain.tsx
Normal file
5
src/views/components/PopupMain.tsx
Normal file
@@ -0,0 +1,5 @@
|
||||
import React from 'react';
|
||||
|
||||
export default function PopupMain() {
|
||||
return <div>popup</div>;
|
||||
}
|
||||
19
src/views/components/common/Button/Button.module.scss
Normal file
19
src/views/components/common/Button/Button.module.scss
Normal file
@@ -0,0 +1,19 @@
|
||||
@import 'src/views/styles/base.module.scss';
|
||||
|
||||
.button {
|
||||
background-color: #000;
|
||||
color: #fff;
|
||||
padding: 10px;
|
||||
border-radius: 5px;
|
||||
border: none;
|
||||
cursor: pointer;
|
||||
font-size: 16px;
|
||||
font-weight: 600;
|
||||
transition: all 0.3s ease;
|
||||
font-family: 'Inter';
|
||||
|
||||
&:hover {
|
||||
background-color: #fff;
|
||||
color: #000;
|
||||
}
|
||||
}
|
||||
14
src/views/components/common/Button/Button.tsx
Normal file
14
src/views/components/common/Button/Button.tsx
Normal file
@@ -0,0 +1,14 @@
|
||||
import React from 'react';
|
||||
import styles from './Button.module.scss';
|
||||
|
||||
interface Props {
|
||||
onClick?: () => void;
|
||||
}
|
||||
|
||||
export function Button(props: React.PropsWithChildren<Props>): JSX.Element {
|
||||
return (
|
||||
<button className={styles.button} onClick={props.onClick}>
|
||||
{props.children}
|
||||
</button>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user