Skip to content

Commit ee24252

Browse files
authored
Merge pull request #211 from zouhir96/auth
Add Google and Github authentication.
2 parents ae9df23 + bb81416 commit ee24252

48 files changed

Lines changed: 1805 additions & 240 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
"axios-cache-adapter": "^2.7.3",
1414
"country-emoji": "^1.5.4",
1515
"dompurify": "^2.2.7",
16+
"firebase": "^11.2.0",
1617
"htmlparser2": "^8.0.1",
1718
"jsonpath": "^1.1.1",
1819
"normalize.css": "^8.0.1",

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: 139 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -122,44 +122,25 @@ a {
122122
}
123123

124124
.extras {
125-
display: none;
126-
flex-direction: row;
127-
align-content: center;
128125
order: 2;
129126
}
130127

131-
.extraBtn {
132-
background-color: var(--button-background-color);
133-
color: var(--button-text-color);
134-
margin-left: 8px;
135-
height: 40px;
136-
width: 40px;
137-
line-height: 44px;
138-
font-size: 18px;
139-
text-align: center;
140-
border: 0;
141-
border-radius: 20px;
142-
cursor: pointer;
143-
position: relative;
128+
.buttonsFlex {
144129
display: inline-flex;
145-
align-items: center;
146-
justify-content: center;
147-
}
148-
149-
.extraBtn:first-child {
150-
margin-left: 0;
130+
flex-direction: row;
131+
align-content: center;
132+
column-gap: 8px;
133+
row-gap: 8px;
151134
}
152135

153-
.extraTextBtn {
154-
padding: 0 16px;
155-
width: auto;
156-
min-width: 40px;
136+
.dndButton {
157137
font-weight: bold;
158138
}
159139

160-
.darkModeBtn {
161-
background-color: var(--dark-mode-background-color);
162-
color: var(--dark-mode-text-color);
140+
.profileImage {
141+
height: 40px;
142+
width: 40px;
143+
border-radius: 20px;
163144
}
164145

165146
.badgeCount {
@@ -1198,10 +1179,6 @@ Producthunt item
11981179
position: relative;
11991180
}
12001181

1201-
.extras {
1202-
display: block;
1203-
}
1204-
12051182
.scrollButton {
12061183
align-items: center;
12071184
display: flex;
@@ -1349,6 +1326,135 @@ Producthunt item
13491326
color: var(--primary-text-color);
13501327
border-radius: 10px;
13511328
}
1329+
1330+
.dangerToast {
1331+
background-color: #ff4d4f;
1332+
color: white;
1333+
padding: 10px 20px;
1334+
border-radius: 10px;
1335+
}
1336+
.successToast {
1337+
background-color: #52c41a;
1338+
color: white;
1339+
padding: 10px 20px;
1340+
border-radius: 10px;
1341+
}
13521342
.capitalize {
13531343
text-transform: capitalize;
13541344
}
1345+
1346+
/**
1347+
Modal
1348+
**/
1349+
1350+
.Modal {
1351+
position: absolute;
1352+
left: 50%;
1353+
top: 50%;
1354+
transform: translate(-50%, -50%);
1355+
width: 650px;
1356+
background-color: var(--card-background-color);
1357+
padding: 24px;
1358+
border-radius: 10px;
1359+
box-shadow: 0 0 20px #00000052;
1360+
z-index: 3;
1361+
max-height: 80vh;
1362+
overflow-y: auto;
1363+
}
1364+
1365+
.Overlay {
1366+
position: fixed;
1367+
top: 0;
1368+
left: 0;
1369+
right: 0;
1370+
bottom: 0;
1371+
background-color: var(--overlay-background-color);
1372+
backdrop-filter: blur(2px);
1373+
}
1374+
1375+
.modalHeader {
1376+
display: flex;
1377+
flex-direction: row;
1378+
align-items: center;
1379+
justify-content: space-between;
1380+
margin-bottom: 16px;
1381+
position: relative;
1382+
}
1383+
1384+
.modalTitle {
1385+
margin: 0;
1386+
padding: 0;
1387+
color: var(--primary-text-color);
1388+
font-size: 1.3em;
1389+
display: inline-flex;
1390+
width: 100%;
1391+
column-gap: 8px;
1392+
align-items: center;
1393+
}
1394+
.modalCloseBtn {
1395+
align-items: center;
1396+
position: absolute;
1397+
background-color: transparent;
1398+
border-radius: 50%;
1399+
top: 0;
1400+
right: 0;
1401+
border: none;
1402+
color: var(--primary-text-color);
1403+
cursor: pointer;
1404+
display: flex;
1405+
justify-content: center;
1406+
margin: 0;
1407+
padding: 0;
1408+
text-align: center;
1409+
}
1410+
.modalCloseBtn:hover {
1411+
opacity: 0.7;
1412+
}
1413+
.settingContent .form {
1414+
display: flex;
1415+
flex-direction: row;
1416+
align-items: center;
1417+
gap: 12px;
1418+
}
1419+
1420+
.settingContent input[type='text'] {
1421+
flex: 1;
1422+
background-color: var(--settings-input-background-color);
1423+
border: 1px solid var(--settings-input-border-color);
1424+
border-radius: 50px;
1425+
padding: 6px 18px;
1426+
color: var(--settings-input-text-color);
1427+
font-size: 14px;
1428+
}
1429+
1430+
.settingContent input[type='text']::placeholder {
1431+
/* Chrome, Firefox, Opera, Safari 10.1+ */
1432+
color: var(--settings-input-placeholder-color);
1433+
opacity: 1;
1434+
font-size: 14px;
1435+
}
1436+
1437+
.settingContent input[type='text']:focus {
1438+
border-color: var(--settings-input-border-focus-color);
1439+
}
1440+
@media (max-width: 768px) {
1441+
.Modal {
1442+
left: 0;
1443+
top: 0;
1444+
margin: 0;
1445+
height: 100vh;
1446+
max-height: 100vh;
1447+
transform: translate(0, 0);
1448+
border-radius: 0;
1449+
position: relative;
1450+
box-shadow: none;
1451+
width: auto;
1452+
}
1453+
.settingContent {
1454+
margin-top: 6px;
1455+
}
1456+
.settingRow {
1457+
flex-direction: column;
1458+
align-items: flex-start;
1459+
}
1460+
}

src/assets/variables.css

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,9 @@ html.dark {
3131

3232
/** Buttons **/
3333
--button-background-color: #1c2026;
34+
--button-hover-background-color: #181c21;
3435
--button-text-color: #fff;
36+
--button-hover-text-color: #d0d0d0;
3537

3638
/**Card **/
3739
--card-background-color: #0d1116;
@@ -117,6 +119,8 @@ html.light {
117119

118120
--button-background-color: #d2deeb;
119121
--button-text-color: #3c5065;
122+
--button-hover-background-color: #b9cadc;
123+
--button-hover-text-color: #3c5065;
120124

121125
/**Card **/
122126
--card-background-color: #ffffff;

0 commit comments

Comments
 (0)