Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
132 changes: 111 additions & 21 deletions popup/popup.css
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@

:root {
--text-color: #202124;
--bg-color: #ffffff;
Expand All @@ -8,9 +9,9 @@
--button-hover: #1557b0;
--button-active: #174ea6;
--success-bg: #e6f4ea;
--success-color: #0b8043;
--success-color: #008000;
--error-bg: #fce8e6;
--error-color: #d93025;
--error-color: #911108;
--label-color: #5f6368;
}

Expand All @@ -25,9 +26,9 @@
--button-hover: #1557b0;
--button-active: #174ea6;
--success-bg: #1e3a2f;
--success-color: #81c995;
--success-color: #008000;
--error-bg: #3c1a1a;
--error-color: #f28b82;
--error-color: #911108;
--label-color: #9aa0a6;
}
}
Expand All @@ -48,8 +49,14 @@ body {

h1 {
margin: 0;
color: var(--button-bg);
font-size: 24px;
font-family: 'Orbitron', sans-serif;
font-size: 22px;
color: #38bdf8;
letter-spacing: 2px;
text-transform: uppercase;
border-bottom: 2px solid #0ea5e9;
padding-bottom: 8px;
margin-bottom: 16px;
text-align: center;
}

Expand Down Expand Up @@ -89,44 +96,97 @@ h2 {
}

button {
padding: 8px 16px;
background: var(--button-bg);
color: white;
border: none;
font-family: 'Orbitron', sans-serif;
font-size: 14px;
text-transform: uppercase;
letter-spacing: 1px;
color: #0ff;
background-color: transparent;
border: 2px solid #0ff;
padding: 10px 18px;
border-radius: 4px;
cursor: pointer;
font-size: 14px;
transition: background-color 0.2s;
box-shadow: 0 0 5px #0ff;
transition: all 0.3s ease;
}

button:hover {
background: var(--button-hover);
background-color: rgba(0, 255, 255, 0.08);
box-shadow: 0 0 10px #0ff, 0 0 20px #0ff;
color: #ffffff;
}

button:active {
background: var(--button-active);
transform: scale(0.97);
box-shadow: 0 0 4px #0ff, 0 0 8px #0ff;
}

#saveApiKey {
background: var(--success-color);
/* background: var(--success-color); */
margin: 0px 4px;

}

#saveApiKey:hover {
background: var(--success-color);
opacity: 0.9;
/* background: var(--success-color); */
/* opacity: 0.9; */
}

#loading {
display: none;
text-align: center;
margin-top: 20px;
}

.spinner {
width: 32px;
height: 32px;
border: 4px solid rgba(0, 255, 255, 0.2);
border-top: 4px solid #00ffff;
border-radius: 50%;
animation: spin 0.8s linear infinite;
margin: 0 auto 10px auto;
box-shadow: 0 0 8px #00ffffaa;
background: rgba(0, 0, 0, 0.4);
}

#loadingText {
color: #00ffff;
font-family: 'Orbitron', sans-serif;
font-size: 14px;
opacity: 0.8;
}

@keyframes spin {
to {
transform: rotate(360deg);
}
}


#changeApiKey {
background: var(--button-bg);
/* background: var(--button-bg); */
margin: 4px;
}

#changeApiKey:hover {
/* background: var(--button-bg); */
opacity: 0.9;
}

#removeApiKey {
background: var(--error-color);
/* background: var(--error-color); */
margin: 4px 3px;
border-color: #f43f5e;
color: #f43f5e;
box-shadow: 0 0 6px #f43f5e;
}

#removeApiKey:hover {
background: var(--error-color);
opacity: 0.9;
/* background: var(--error-color); */
background-color: rgba(244, 63, 94, 0.08);
color: white;
box-shadow: 0 0 10px #f43f5e, 0 0 18px #f43f5e;
}

.setting-group {
Expand Down Expand Up @@ -172,6 +232,19 @@ select {
color: var(--error-color);
}

#apiKeyStatus{
margin: 3px 2px;
font-family: 'Orbitron', sans-serif;
font-size: 15px;
color: #00ffee;
text-shadow:
0 0 1px #00ffee,
0 0 3px #00ffee,
0 0 5px #8800ff;
text-transform: uppercase;
letter-spacing: 1.5px;
}

ol {
margin: 0;
padding-left: 20px;
Expand Down Expand Up @@ -222,4 +295,21 @@ li:last-child {
transform: translate(-50%, 0);
opacity: 1;
}
}

.note2 a{
color: #00ffff;
font-family: 'Orbitron', sans-serif;
font-size: 14px;
opacity: 0.8;
}

#apiKeyInput {
flex-grow: 1;
padding: 8px;
border: 1px solid var(--input-border);
border-radius: 4px;
font-family: monospace;
background: var(--bg-color);
color: var(--text-color);
}
9 changes: 8 additions & 1 deletion popup/popup.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
<head>
<title>Hinglish Translator</title>
<link rel="stylesheet" href="popup.css">
<link href="https://fonts.googleapis.com/css2?family=Orbitron:wght@600&display=swap" rel="stylesheet">
</head>
<body>
<div class="container">
Expand All @@ -20,11 +21,16 @@ <h1>Hinglish Translator</h1>
<div class="api-key-container" id="apiKeyContainer" style="display: none;">
<div class="input-group">
<input type="password" id="apiKey" placeholder="Enter your Groq API key">
<button id="toggleApiKey" class="icon-button">👁️</button>
<button id="toggleApiKey">Show</i></button>
</div>
<button id="saveApiKey" class="button primary">Save API Key</button>
</div>

<div id="loading">
<div id="loadingIndicator" class="spinner"></div>
<div id="loadingText">Validating...</div>
</div>

<div class="settings-section">
<h2>Translation Settings</h2>
<div class="setting-group">
Expand Down Expand Up @@ -63,5 +69,6 @@ <h2>How to Use</h2>
</div>
</div>
<script src="popup.js"></script>

</body>
</html>
18 changes: 13 additions & 5 deletions popup/popup.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ document.addEventListener('DOMContentLoaded', async () => {
const translationStyle = document.getElementById('translationStyle');
const languageLevel = document.getElementById('languageLevel');
const saveSettings = document.getElementById('saveSettings');
const loader = document.getElementById('loading');

// Check if API key exists
const { groqApiKey } = await chrome.storage.local.get('groqApiKey');
Expand All @@ -19,7 +20,7 @@ document.addEventListener('DOMContentLoaded', async () => {
}

// Show API key is configured
apiKeyStatus.textContent = 'API Key Configured';
apiKeyStatus.textContent = 'API Key Configured';
apiKeyStatus.style.color = '#4CAF50';

// Load existing translation settings
Expand All @@ -33,10 +34,11 @@ document.addEventListener('DOMContentLoaded', async () => {
toggleApiKey.addEventListener('click', () => {
if (apiKeyInput.type === 'password') {
apiKeyInput.type = 'text';
toggleApiKey.textContent = '🙈';
toggleApiKey.innerText = 'Hide';

} else {
apiKeyInput.type = 'password';
toggleApiKey.textContent = '👁️';
toggleApiKey.innerText = 'Show';
}
});

Expand All @@ -47,6 +49,9 @@ document.addEventListener('DOMContentLoaded', async () => {
showError('Please enter your API key');
return;
}

loader.style.display = "block";
saveApiKey.disabled = true;

try {
// Save API key first
Expand Down Expand Up @@ -81,12 +86,15 @@ document.addEventListener('DOMContentLoaded', async () => {
showSuccess('API key saved successfully');
apiKeyInput.value = '';
apiKeyContainer.style.display = 'none';
apiKeyStatus.textContent = 'API Key Configured';
apiKeyStatus.style.color = '#4CAF50';
apiKeyStatus.textContent = 'API Key Configured';
apiKeyStatus.style.color = '';
} catch (error) {
console.error('API key validation error:', error);
await chrome.storage.local.remove('groqApiKey');
showError(error.message || 'Failed to validate API key');
} finally {
loader.style.display = "none";
saveApiKey.disabled = false;
}
});

Expand Down
10 changes: 8 additions & 2 deletions popup/welcome.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,14 @@ <h1>Welcome to Hinglish Translator</h1>
<p>Please enter your Groq API key to enable translations:</p>
<input type="password" id="apiKeyInput" placeholder="Enter your Groq API key">
<button id="saveApiKey">Save Key</button>
<p class="note">Your key will be stored locally in Chrome and only used for translation requests.</p>
<p class="note">Don't have a key? <a href="https://groq.com/" target="_blank">Get one from Groq</a></p>

<div id="loading">
<div id="loadingIndicator" class="spinner"></div>
<div id="loadingText">Validating...</div>
</div>

<p class="note1">Your key will be stored locally in Chrome and only used for translation requests.</p>
<p class="note2">Don't have a key? <a href="https://groq.com/" target="_blank">Get one from Groq</a></p>
</div>
</div>
<script src="welcome.js"></script>
Expand Down
7 changes: 7 additions & 0 deletions popup/welcome.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
const loader = document.getElementById('loading');

document.addEventListener('DOMContentLoaded', async () => {
// Check if API key exists
const { groqApiKey } = await chrome.storage.local.get(['groqApiKey']);
Expand All @@ -19,6 +21,8 @@ document.addEventListener('DOMContentLoaded', async () => {
errorMessage.textContent = 'Please enter your API key';
return;
}
loader.style.display = "block";
saveButton.disabled = true;

try {
// Save API key first
Expand Down Expand Up @@ -54,6 +58,9 @@ document.addEventListener('DOMContentLoaded', async () => {
// Remove invalid key
await chrome.storage.local.remove(['groqApiKey']);
errorMessage.textContent = error.message || 'Invalid API key. Please try again.';
} finally {
loader.style.display = 'none';
saveButton.disabled = false;
}
});
});