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
56 changes: 55 additions & 1 deletion src/global.css
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ textarea {
align-items: center;
gap: 8px;
margin-top: 16px;
width: 100%;
}

/* Add this new style */
Expand All @@ -93,15 +94,52 @@ textarea {
padding: 0 8px;
}

.settings-panel {
margin-top: 20px;
text-align: left;
width: 100%;
}

.settings-label {
display: block;
margin-bottom: 8px;
font-size: 14px;
font-weight: 600;
color: #666;
}

/* Update url-input width to be 100% since container will control max width */
.url-input {
.url-input,
.bang-input {
padding: 8px 12px;
border: 1px solid #ddd;
border-radius: 4px;
width: 100%;
background: #f5f5f5;
}

.bang-input {
max-width: calc(100% - 44px);
}
Comment on lines +112 to +123

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

.bang-input max-width reduction looks misapplied.

.bang-input sits alone in .settings-panel (no adjacent button), unlike .url-input which shares .url-container with .copy-button. The calc(100% - 44px) offset appears intended to reserve space for that button, but it's applied to .bang-input instead, needlessly shrinking the settings input below full width.

🎨 Suggested fix
 .url-input,
 .bang-input {
   padding: 8px 12px;
   border: 1px solid `#ddd`;
   border-radius: 4px;
   width: 100%;
   background: `#f5f5f5`;
 }

-.bang-input {
-  max-width: calc(100% - 44px);
-}
+.url-input {
+  max-width: calc(100% - 44px);
+}
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
.url-input,
.bang-input {
padding: 8px 12px;
border: 1px solid #ddd;
border-radius: 4px;
width: 100%;
background: #f5f5f5;
}
.bang-input {
max-width: calc(100% - 44px);
}
.url-input,
.bang-input {
padding: 8px 12px;
border: 1px solid `#ddd`;
border-radius: 4px;
width: 100%;
background: `#f5f5f5`;
}
.url-input {
max-width: calc(100% - 44px);
}
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/global.css` around lines 112 - 123, The `.bang-input` width rule in
`global.css` is applying a button-offset that only makes sense for `.url-input`,
so remove the `max-width: calc(100% - 44px)` override from `.bang-input` and
keep that sizing only for the input that lives beside `.copy-button` in the
`.url-container`. Use the `.bang-input` and `.url-input` selectors to locate the
shared styles, and ensure the settings input can expand to full width in
`.settings-panel`.


.bang-input.invalid {
border-color: #cc3a3a;
outline: 1px solid rgba(204, 58, 58, 0.18);
}

.bang-help {
margin-top: 8px;
font-size: 14px;
color: #777;
}

.bang-error {
min-height: 1.25em;
margin-top: 6px;
font-size: 14px;
color: #cc3a3a;
}

.copy-button {
padding: 8px;
color: #666;
Expand All @@ -110,6 +148,7 @@ textarea {
display: flex;
align-items: center;
justify-content: center;
flex: 0 0 auto;
}

.copy-button:hover {
Expand Down Expand Up @@ -182,6 +221,21 @@ textarea {
color: #fff;
}

.bang-input {
border-color: #3d3d3d;
background-color: #191919;
color: #fff;
}

.settings-label,
.bang-help {
color: #9a9a9a;
}

.bang-error {
color: #ff7a7a;
}

.copy-button img {
filter: invert(1);
}
Expand Down
53 changes: 51 additions & 2 deletions src/main.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import { bangs } from "./bang";
import "./global.css";

const LS_DEFAULT_BANG = "default-bang";
const DEFAULT_BANG_FALLBACK = "g";

function noSearchDefaultPageRender() {
const app = document.querySelector<HTMLDivElement>("#app")!;
app.innerHTML = `
Expand All @@ -19,6 +22,20 @@ function noSearchDefaultPageRender() {
<img src="/clipboard.svg" alt="Copy" />
</button>
</div>
<div class="settings-panel">
<label class="settings-label" for="default-bang-input">Default bang</label>
<input
id="default-bang-input"
class="bang-input"
type="text"
autocomplete="off"
spellcheck="false"
inputmode="latin"
placeholder="g"
/>
<p class="bang-help">Used when a query does not include a bang. Defaults to google</p>
<p class="bang-error" aria-live="polite"></p>
</div>
</div>
<footer class="footer">
<a href="https://t3.chat" target="_blank">t3.chat</a>
Expand All @@ -33,6 +50,9 @@ function noSearchDefaultPageRender() {
const copyButton = app.querySelector<HTMLButtonElement>(".copy-button")!;
const copyIcon = copyButton.querySelector("img")!;
const urlInput = app.querySelector<HTMLInputElement>(".url-input")!;
const defaultBangInput = app.querySelector<HTMLInputElement>("#default-bang-input")!;
const bangError = app.querySelector<HTMLParagraphElement>(".bang-error")!;
let validationTimer: number | undefined;

copyButton.addEventListener("click", async () => {
await navigator.clipboard.writeText(urlInput.value);
Expand All @@ -42,10 +62,39 @@ function noSearchDefaultPageRender() {
copyIcon.src = "/clipboard.svg";
}, 2000);
});

const validateDefaultBang = () => {
const candidate = defaultBangInput.value.trim().toLowerCase();

if (!candidate) {
bangError.textContent = "Default bang cannot be empty.";
defaultBangInput.classList.add("invalid");
return;
}

const match = bangs.find((bang) => bang.t === candidate);
if (!match) {
bangError.textContent = `No bang found for !${candidate}.`;
defaultBangInput.classList.add("invalid");
return;
}

bangError.textContent = "";
defaultBangInput.classList.remove("invalid");
localStorage.setItem(LS_DEFAULT_BANG, candidate);
};

defaultBangInput.value = localStorage.getItem(LS_DEFAULT_BANG) ?? DEFAULT_BANG_FALLBACK;
defaultBangInput.addEventListener("input", () => {
window.clearTimeout(validationTimer);
validationTimer = window.setTimeout(validateDefaultBang, 350);
});

validateDefaultBang();
}

const LS_DEFAULT_BANG = localStorage.getItem("default-bang") ?? "g";
const defaultBang = bangs.find((b) => b.t === LS_DEFAULT_BANG);
const storedDefaultBang = localStorage.getItem(LS_DEFAULT_BANG) ?? DEFAULT_BANG_FALLBACK;
const defaultBang = bangs.find((b) => b.t === storedDefaultBang) ?? bangs.find((b) => b.t === DEFAULT_BANG_FALLBACK);

function getBangredirectUrl() {
const url = new URL(window.location.href);
Expand Down