Initial commit
This commit is contained in:
12
pages/new-tab/index.html
Normal file
12
pages/new-tab/index.html
Normal file
@@ -0,0 +1,12 @@
|
||||
<!doctype html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<title>New Tab</title>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div id="app-container"></div>
|
||||
<script type="module" src="./src/index.tsx"></script>
|
||||
</body>
|
||||
</html>
|
||||
40
pages/new-tab/package.json
Normal file
40
pages/new-tab/package.json
Normal file
@@ -0,0 +1,40 @@
|
||||
{
|
||||
"name": "@extension/new-tab",
|
||||
"version": "0.5.0",
|
||||
"description": "chrome extension - new tab",
|
||||
"type": "module",
|
||||
"private": true,
|
||||
"sideEffects": true,
|
||||
"files": [
|
||||
"dist/**"
|
||||
],
|
||||
"scripts": {
|
||||
"clean:node_modules": "pnpx rimraf node_modules",
|
||||
"clean:turbo": "rimraf .turbo",
|
||||
"clean": "pnpm clean:turbo && pnpm clean:node_modules",
|
||||
"build": "vite build",
|
||||
"dev": "vite build --mode development",
|
||||
"lint": "eslint .",
|
||||
"lint:fix": "pnpm lint --fix",
|
||||
"format": "prettier . --write --ignore-path ../../.prettierignore",
|
||||
"type-check": "tsc --noEmit"
|
||||
},
|
||||
"dependencies": {
|
||||
"@extension/i18n": "workspace:*",
|
||||
"@extension/shared": "workspace:*",
|
||||
"@extension/storage": "workspace:*",
|
||||
"@extension/ui": "workspace:*"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@extension/tailwindcss-config": "workspace:*",
|
||||
"@extension/tsconfig": "workspace:*",
|
||||
"@extension/vite-config": "workspace:*",
|
||||
"sass": "^1.89.0"
|
||||
},
|
||||
"postcss": {
|
||||
"plugins": {
|
||||
"tailwindcss": {},
|
||||
"autoprefixer": {}
|
||||
}
|
||||
}
|
||||
}
|
||||
124
pages/new-tab/public/logo_horizontal.svg
Normal file
124
pages/new-tab/public/logo_horizontal.svg
Normal file
File diff suppressed because one or more lines are too long
|
After Width: | Height: | Size: 58 KiB |
117
pages/new-tab/public/logo_horizontal_dark.svg
Normal file
117
pages/new-tab/public/logo_horizontal_dark.svg
Normal file
File diff suppressed because one or more lines are too long
|
After Width: | Height: | Size: 60 KiB |
22
pages/new-tab/src/NewTab.css
Normal file
22
pages/new-tab/src/NewTab.css
Normal file
@@ -0,0 +1,22 @@
|
||||
.App {
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.App-logo {
|
||||
height: 40vmin;
|
||||
}
|
||||
|
||||
.App-header {
|
||||
min-height: 100vh;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
font-size: calc(10px + 2vmin);
|
||||
}
|
||||
|
||||
code {
|
||||
background: rgba(148, 163, 184, 0.5);
|
||||
border-radius: 0.25rem;
|
||||
padding: 0.2rem 0.5rem;
|
||||
}
|
||||
10
pages/new-tab/src/NewTab.scss
Normal file
10
pages/new-tab/src/NewTab.scss
Normal file
@@ -0,0 +1,10 @@
|
||||
$myColor: red;
|
||||
|
||||
h1,
|
||||
h2,
|
||||
h3,
|
||||
h4,
|
||||
h5,
|
||||
h6 {
|
||||
color: $myColor;
|
||||
}
|
||||
31
pages/new-tab/src/NewTab.tsx
Normal file
31
pages/new-tab/src/NewTab.tsx
Normal file
@@ -0,0 +1,31 @@
|
||||
import '@src/NewTab.css';
|
||||
import '@src/NewTab.scss';
|
||||
import { t } from '@extension/i18n';
|
||||
import { PROJECT_URL_OBJECT, useStorage, withErrorBoundary, withSuspense } from '@extension/shared';
|
||||
import { exampleThemeStorage } from '@extension/storage';
|
||||
import { cn, ErrorDisplay, LoadingSpinner, ToggleButton } from '@extension/ui';
|
||||
|
||||
const NewTab = () => {
|
||||
const { isLight } = useStorage(exampleThemeStorage);
|
||||
const logo = isLight ? 'new-tab/logo_horizontal.svg' : 'new-tab/logo_horizontal_dark.svg';
|
||||
|
||||
const goGithubSite = () => chrome.tabs.create(PROJECT_URL_OBJECT);
|
||||
|
||||
console.log(t('hello', 'World'));
|
||||
return (
|
||||
<div className={cn('App', isLight ? 'bg-slate-50' : 'bg-gray-800')}>
|
||||
<header className={cn('App-header', isLight ? 'text-gray-900' : 'text-gray-100')}>
|
||||
<button onClick={goGithubSite}>
|
||||
<img src={chrome.runtime.getURL(logo)} className="App-logo" alt="logo" />
|
||||
</button>
|
||||
<p>
|
||||
Edit <code>pages/new-tab/src/NewTab.tsx</code>
|
||||
</p>
|
||||
<h6>The color of this paragraph is defined using SASS.</h6>
|
||||
<ToggleButton onClick={exampleThemeStorage.toggle}>{t('toggleTheme')}</ToggleButton>
|
||||
</header>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export default withErrorBoundary(withSuspense(NewTab, <LoadingSpinner />), ErrorDisplay);
|
||||
1
pages/new-tab/src/index.css
Normal file
1
pages/new-tab/src/index.css
Normal file
@@ -0,0 +1 @@
|
||||
@import '@extension/ui/global.css';
|
||||
15
pages/new-tab/src/index.tsx
Normal file
15
pages/new-tab/src/index.tsx
Normal file
@@ -0,0 +1,15 @@
|
||||
import '@src/index.css';
|
||||
import NewTab from '@src/NewTab';
|
||||
import { createRoot } from 'react-dom/client';
|
||||
|
||||
const init = () => {
|
||||
const appContainer = document.querySelector('#app-container');
|
||||
if (!appContainer) {
|
||||
throw new Error('Can not find #app-container');
|
||||
}
|
||||
const root = createRoot(appContainer);
|
||||
|
||||
root.render(<NewTab />);
|
||||
};
|
||||
|
||||
init();
|
||||
5
pages/new-tab/tailwind.config.ts
Normal file
5
pages/new-tab/tailwind.config.ts
Normal file
@@ -0,0 +1,5 @@
|
||||
import { withUI } from '@extension/ui';
|
||||
|
||||
export default withUI({
|
||||
content: ['index.html', 'src/**/*.tsx'],
|
||||
});
|
||||
11
pages/new-tab/tsconfig.json
Normal file
11
pages/new-tab/tsconfig.json
Normal file
@@ -0,0 +1,11 @@
|
||||
{
|
||||
"extends": "@extension/tsconfig/base",
|
||||
"compilerOptions": {
|
||||
"baseUrl": ".",
|
||||
"paths": {
|
||||
"@src/*": ["src/*"]
|
||||
},
|
||||
"types": ["chrome", "node"]
|
||||
},
|
||||
"include": ["src", "vite.config.mts", "tailwind.config.ts"]
|
||||
}
|
||||
17
pages/new-tab/vite.config.mts
Normal file
17
pages/new-tab/vite.config.mts
Normal file
@@ -0,0 +1,17 @@
|
||||
import { resolve } from 'node:path';
|
||||
import { withPageConfig } from '@extension/vite-config';
|
||||
|
||||
const rootDir = resolve(import.meta.dirname);
|
||||
const srcDir = resolve(rootDir, 'src');
|
||||
|
||||
export default withPageConfig({
|
||||
resolve: {
|
||||
alias: {
|
||||
'@src': srcDir,
|
||||
},
|
||||
},
|
||||
publicDir: resolve(rootDir, 'public'),
|
||||
build: {
|
||||
outDir: resolve(rootDir, '..', '..', 'dist', 'new-tab'),
|
||||
},
|
||||
});
|
||||
Reference in New Issue
Block a user