-
Notifications
You must be signed in to change notification settings - Fork 122
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(lit):out of box functions, countor \ newtab timer \ events
- Loading branch information
Showing
67 changed files
with
711 additions
and
527 deletions.
There are no files selected for viewing
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,3 @@ | ||
{ | ||
"recommendations": ["bierner.lit-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,14 @@ | ||
<!doctype html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8" /> | ||
<link rel="icon" href="/icons/logo.ico" /> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> | ||
<title>Chrome Extension + Lit + JS + Vite</title> | ||
<link rel="stylesheet" href="./src/index.css" /> | ||
</head> | ||
<body> | ||
<devtools-root></devtools-root> | ||
<script type="module" src="./src/devtools/index.js"></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,14 @@ | ||
<!doctype html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8" /> | ||
<link rel="icon" href="/icons/logo.ico" /> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> | ||
<title>Chrome Extension + Lit + JS + Vite</title> | ||
<link rel="stylesheet" href="./src/index.css" /> | ||
</head> | ||
<body> | ||
<newtab-root></newtab-root> | ||
<script type="module" src="./src/newtab/index.js"></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
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
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,3 +1,7 @@ | ||
console.info('chrome-ext template-li-js background script') | ||
console.log('background is running') | ||
|
||
export {} | ||
chrome.runtime.onMessage.addListener((request) => { | ||
if (request.type === 'COUNT') { | ||
console.log('background has received a message from popup, and count is ', request?.count) | ||
} | ||
}) |
This file was deleted.
Oops, something went wrong.
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 @@ | ||
console.info('contentScript is running') |
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 +1,56 @@ | ||
export {} | ||
import { LitElement, css, html } from 'lit' | ||
|
||
chrome.devtools.panels.create('LitCrx', '', '../../devtools.html', () => { | ||
console.log('devtools panel create') | ||
}) | ||
|
||
export class DevTools extends LitElement { | ||
link = 'https://github.com/guocaoyi/create-chrome-ext' | ||
|
||
render() { | ||
return html` | ||
<main> | ||
<h3>DevTools Page</h3> | ||
<a href=${this.link} target="_blank"> generated by create-chrome-ext </a> | ||
</main> | ||
` | ||
} | ||
|
||
static styles = css` | ||
@media (prefers-color-scheme: light) { | ||
a:hover { | ||
color: #324fff; | ||
} | ||
} | ||
body { | ||
min-width: 20rem; | ||
} | ||
main { | ||
text-align: center; | ||
padding: 1em; | ||
margin: 0 auto; | ||
} | ||
h3 { | ||
color: #324fff; | ||
text-transform: uppercase; | ||
font-size: 1.5rem; | ||
font-weight: 200; | ||
line-height: 1.2rem; | ||
margin: 2rem auto; | ||
} | ||
a { | ||
font-size: 0.5rem; | ||
margin: 0.5rem; | ||
color: #cccccc; | ||
text-decoration: none; | ||
} | ||
` | ||
} | ||
|
||
export default DevTools | ||
|
||
window.customElements.define('devtools-root', DevTools) |
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,23 +1,28 @@ | ||
:root { | ||
font-family: Inter, Avenir, Helvetica, Arial, sans-serif; | ||
font-size: 16px; | ||
line-height: 24px; | ||
font-weight: 400; | ||
font-family: | ||
system-ui, | ||
-apple-system, | ||
BlinkMacSystemFont, | ||
'Segoe UI', | ||
Roboto, | ||
Oxygen, | ||
Ubuntu, | ||
Cantarell, | ||
'Open Sans', | ||
'Helvetica Neue', | ||
sans-serif; | ||
|
||
color-scheme: light dark; | ||
color: rgba(255, 255, 255, 0.87); | ||
background-color: #242424; | ||
|
||
font-synthesis: none; | ||
text-rendering: optimizeLegibility; | ||
-webkit-font-smoothing: antialiased; | ||
-moz-osx-font-smoothing: grayscale; | ||
-webkit-text-size-adjust: 100%; | ||
} | ||
|
||
@media (prefers-color-scheme: light) { | ||
:root { | ||
color: #213547; | ||
background-color: #ffffff; | ||
background-color: #fafafa; | ||
} | ||
} | ||
|
||
body { | ||
min-width: 20rem; | ||
margin: 0; | ||
} |
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 +1,79 @@ | ||
export {} | ||
import { LitElement, css, html } from 'lit' | ||
|
||
export class NewTab extends LitElement { | ||
static get properties() { | ||
return { | ||
time: { type: Number, default: '-' }, | ||
link: { type: String, default: 'https://github.com/guocaoyi/create-chrome-ext' }, | ||
} | ||
} | ||
|
||
getTime() { | ||
const date = new Date() | ||
const hour = String(date.getHours()).padStart(2, '0') | ||
const minute = String(date.getMinutes()).padStart(2, '0') | ||
return `${hour}:${minute}` | ||
} | ||
|
||
connectedCallback() { | ||
super.connectedCallback() | ||
let intervalId = setInterval(() => { | ||
this.time = this.getTime() | ||
}, 1000) | ||
|
||
this.addEventListener('disconnected', () => { | ||
clearInterval(intervalId) | ||
}) | ||
} | ||
|
||
render() { | ||
return html` | ||
<section> | ||
<span></span> | ||
<h1>${this.time}</h1> | ||
<a .href=${this.link} target="_blank"> generated by create-chrome-ext </a> | ||
</section> | ||
` | ||
} | ||
|
||
static styles = css` | ||
section::before { | ||
content: ''; | ||
position: fixed; | ||
z-index: -1; | ||
width: 100vw; | ||
height: 100vh; | ||
background-image: url('https://source.unsplash.com/random'); | ||
background-size: cover; | ||
filter: blur(10px); | ||
} | ||
section { | ||
width: 100vw; | ||
height: 100vh; | ||
display: flex; | ||
flex-direction: column; | ||
justify-content: space-between; | ||
align-items: center; | ||
} | ||
h1 { | ||
color: #324fff; | ||
text-transform: uppercase; | ||
font-size: 6rem; | ||
margin: 2rem auto; | ||
} | ||
a { | ||
font-size: 0.5rem; | ||
margin: 0.5rem; | ||
color: #cccccc; | ||
text-decoration: none; | ||
} | ||
` | ||
} | ||
|
||
export default NewTab | ||
|
||
window.customElements.define('newtab-root', NewTab) |
Oops, something went wrong.