Skip to content

Commit

Permalink
add lang / tone feature
Browse files Browse the repository at this point in the history
  • Loading branch information
f committed Feb 19, 2025
1 parent 778737f commit b95c92f
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 25 deletions.
41 changes: 17 additions & 24 deletions _layouts/default.html
Original file line number Diff line number Diff line change
Expand Up @@ -530,7 +530,7 @@
position: sticky;
top: 0;
background-color: var(--bg-color-light);
padding: 8px 35px;
padding: 6px 38px;
border-bottom: 1px solid #e1e4e8;
z-index: 10;
margin: -20px -20px 20px -20px;
Expand All @@ -546,7 +546,7 @@
.main-content-header .header-content {
display: flex;
align-items: center;
justify-content: space-between;
justify-content: end;
max-width: 1200px;
margin: 0 auto;
gap: 16px;
Expand All @@ -571,6 +571,7 @@
color: var(--text-color-light);
opacity: 0.9;
flex-wrap: wrap;
margin-right: 0 !important;
}

.dark-mode .main-content-header .platform-selectors {
Expand Down Expand Up @@ -615,7 +616,7 @@

@media (max-width: 768px) {
.main-content-header {
padding: 12px;
padding: 12px 40px;
margin: -16px -16px 16px -16px;
}

Expand Down Expand Up @@ -658,7 +659,7 @@
}

.main-content-header .custom-select {
padding: 2px 24px 2px 4px;
padding: 2px 20px 2px 4px;
font-size: inherit;
border: none;
border-radius: 4px;
Expand Down Expand Up @@ -1735,7 +1736,6 @@
}

.main-content-header .custom-select {
flex: 1;
min-width: 0;
}

Expand All @@ -1746,7 +1746,7 @@

@media (max-width: 768px) {
.main-content-header {
padding: 12px;
padding: 12px 40px;
margin: -16px -16px 16px -16px;
}

Expand Down Expand Up @@ -1868,22 +1868,21 @@ <h1 class="site-title">prompts.chat</h1>
<div class="header-content">
<div class="platform-selectors">
Reply in <select id="languageSelect" class="custom-select">
<option value="en">English</option>
<option value="es">Spanish</option>
<option value="fr">French</option>
<option value="de">German</option>
<option value="it">Italian</option>
<option value="pt">Portuguese</option>
<option value="ru">Russian</option>
<option value="zh">Chinese</option>
<option value="ja">Japanese</option>
<option value="ko">Korean</option>
<option value="tr">Turkish</option>
<option value="English">English</option>
<option value="Spanish">Spanish</option>
<option value="French">French</option>
<option value="German">German</option>
<option value="Italian">Italian</option>
<option value="Portuguese">Portuguese</option>
<option value="Russian">Russian</option>
<option value="Chinese">Chinese</option>
<option value="Japanese">Japanese</option>
<option value="Korean">Korean</option>
<option value="Turkish">Turkish</option>
<option value="custom">Custom...</option>
</select>
<input type="text" id="customLanguage" class="custom-input" placeholder="language..." style="display: none;">
using <select id="toneSelect" class="custom-select">
<option value="developer">developer</option>
<option value="professional">professional</option>
<option value="casual">casual</option>
<option value="friendly">friendly</option>
Expand Down Expand Up @@ -1991,12 +1990,6 @@ <h3>e-Books by @f</h3>
const isDevMode = e.target.value === 'developers';
document.body.classList.toggle('dev-mode', isDevMode);

// Update URL params
const params = new URLSearchParams(window.location.search);
params.set('audience', e.target.value);
const newUrl = `${window.location.pathname}?${params.toString()}`;
window.history.pushState({}, '', newUrl);

// Trigger prompt filtering
filterPrompts();
});
Expand Down
25 changes: 24 additions & 1 deletion script.js
Original file line number Diff line number Diff line change
Expand Up @@ -860,6 +860,29 @@ document.querySelectorAll(".platform-tag").forEach((button) => {
chatButtons.forEach((btn) => {
btn.style.display = shouldHideChat ? "none" : "flex";
});

// Auto-select technical tone and developers audience for GitHub Copilot
if (selectedPlatform === "github-copilot") {
const toneSelect = document.getElementById('toneSelect');
const audienceSelect = document.getElementById('audienceSelect');

// Set tone to technical
toneSelect.value = 'technical';
localStorage.setItem('selected-tone', 'technical');

// Set audience to developers
audienceSelect.value = 'developers';
localStorage.setItem('audience', 'developers');

// Update dev mode class on body
document.body.classList.add('dev-mode');

// Update chat button icons
updateChatButtonIcons(true);

// Trigger prompt filtering for dev mode
filterPrompts();
}
});
});

Expand Down Expand Up @@ -946,7 +969,7 @@ function buildPrompt(encodedPrompt) {
const audience = audienceSelect.value;

// Append preferences as a new line
promptText += `\n\nReply in ${language} using ${tone} tone for ${audience}`;
promptText += ` Reply in ${language} using ${tone} tone for ${audience}.`;

return promptText;
}
Expand Down

0 comments on commit b95c92f

Please sign in to comment.