Skip to content

Commit cc38776

Browse files
committed
xMerge branch 'zouhir-auth' into feat-streaks
2 parents e6eb469 + 9d2932d commit cc38776

28 files changed

Lines changed: 426 additions & 144 deletions

public/auth.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
window.addEventListener('message', (event) => {
2+
if (event.data.type === 'TOKEN_RECEIVED') {
3+
// Forward to content script
4+
window.postMessage(event.data, '*')
5+
}
6+
})

public/background.js

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,4 @@
1-
/*chrome.browserAction.onClicked.addListener(function (tab) {
2-
chrome.tabs.create({ url: "chrome://newtab" });
3-
}
4-
);*/
5-
61
const uninstallUrl = `https://hackertab.dev/uninstall.html`
72
if (chrome.runtime.setUninstallURL) {
83
chrome.runtime.setUninstallURL(uninstallUrl)
9-
}
4+
}

public/base.manifest.json

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,19 @@
11
{
2+
"manifest_version": 3,
23
"name": "Hackertab.dev - developer news",
34
"description": "All developer news in one tab",
45
"version": "1.20.1",
56
"chrome_url_overrides": {
67
"newtab": "index.html"
78
},
9+
"host_permissions": ["https://*.hackertab.dev/*"],
10+
"content_scripts": [
11+
{
12+
"matches": ["http://127.0.0.1:5173/*", "http://localhost:5173/*", "https://hackertab.dev/*"],
13+
"run_at": "document_start",
14+
"js": ["content.js"]
15+
}
16+
],
817
"icons": {
918
"16": "/logos/logo16.png",
1019
"32": "/logos/logo32.png",

public/chrome.manifest.json

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
{
2-
"manifest_version": 3,
32
"background": {
43
"service_worker": "background.js"
5-
},
6-
"host_permissions": ["https://*.hackertab.dev/*"]
4+
}
75
}

public/content.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
const script = document.createElement('script')
2+
script.src = chrome.runtime.getURL('auth.js')
3+
document.documentElement.appendChild(script)
4+
5+
// Listen for messages from the injected script
6+
window.addEventListener('message', (event) => {
7+
if (event.source !== window || !event.data || event.data.type !== 'TOKEN_RECEIVED') {
8+
return
9+
}
10+
11+
chrome.runtime.sendMessage({ ...event.data })
12+
})

public/firefox.manifest.json

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,5 @@
11
{
2-
"manifest_version": 2,
3-
"background": {
4-
"scripts": [
5-
"background.js"
6-
]
7-
},
8-
"permissions": [
9-
"https://*.hackertab.dev/*"
10-
],
11-
"content_security_policy": "script-src 'self' object-src 'self'",
12-
"applications": {
13-
"gecko": {
14-
"id": "{f8793186-e9da-4332-aa1e-dc3d9f7bb04c}"
15-
}
16-
}
17-
}
2+
"background": {
3+
"scripts": ["background.js"]
4+
}
5+
}

src/assets/App.css

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1361,6 +1361,19 @@ Producthunt item
13611361
color: var(--primary-text-color);
13621362
border-radius: 10px;
13631363
}
1364+
1365+
.dangerToast {
1366+
background-color: #ff4d4f;
1367+
color: white;
1368+
padding: 10px 20px;
1369+
border-radius: 10px;
1370+
}
1371+
.successToast {
1372+
background-color: #52c41a;
1373+
color: white;
1374+
padding: 10px 20px;
1375+
border-radius: 10px;
1376+
}
13641377
.capitalize {
13651378
text-transform: capitalize;
13661379
}
@@ -1381,7 +1394,7 @@ Modal
13811394
box-shadow: 0 0 20px #00000052;
13821395
z-index: 3;
13831396
max-height: 80vh;
1384-
overflow-y: scroll;
1397+
overflow-y: auto;
13851398
}
13861399

13871400
.Overlay {

src/components/Elements/Button/Button.css

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,12 @@
3232
padding: 1rem 2rem;
3333
font-size: 1.25rem;
3434
}
35+
36+
&.loading {
37+
pointer-events: none;
38+
cursor: not-allowed;
39+
opacity: 0.8;
40+
}
3541
}
3642

3743
.circle-button {

src/components/Elements/Button/Button.tsx

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import clsx from 'clsx'
22
import React from 'react'
3+
import { Spinner } from '../Spinner'
34
import './Button.css'
4-
55
const sizes = {
66
small: 'small',
77
medium: 'medium',
@@ -14,6 +14,7 @@ type ButtonProps = {
1414
size?: keyof typeof sizes
1515
startIcon?: React.ReactNode
1616
endIcon?: React.ReactNode
17+
isLoading?: boolean
1718
}
1819
export const Button = ({
1920
size = 'medium',
@@ -22,10 +23,14 @@ export const Button = ({
2223
startIcon,
2324
endIcon,
2425
children,
26+
isLoading = false,
2527
}: ButtonProps) => {
2628
return (
27-
<button className={clsx('button', sizes[size], className)} onClick={onClick}>
28-
{startIcon}
29+
<button
30+
className={clsx('button', isLoading && 'loading', sizes[size], className)}
31+
onClick={onClick}
32+
disabled={isLoading}>
33+
{isLoading ? <Spinner size="small" /> : startIcon}
2934
{children}
3035
{endIcon}
3136
</button>
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
.spinner {
2+
position: relative;
3+
border-radius: 50%;
4+
border: 2px solid transparent;
5+
border-top-color: currentColor;
6+
border-right-color: currentColor;
7+
border-bottom-color: currentColor;
8+
animation: spin 1.5s linear infinite;
9+
&.small {
10+
width: 20px;
11+
height: 20px;
12+
}
13+
14+
&.medium {
15+
width: 40px;
16+
height: 40px;
17+
}
18+
19+
&.large {
20+
width: 50px;
21+
height: 50px;
22+
}
23+
}
24+
25+
@keyframes spin {
26+
0% {
27+
transform: rotate(0deg);
28+
}
29+
100% {
30+
transform: rotate(360deg);
31+
}
32+
}

0 commit comments

Comments
 (0)