Skip to content

armgit / dub

Public Imported from GitHub
0

The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.

small improvements

Steven Teyd6bc1500de59
diff --git a/apps/web/lib/upstash/vector.ts b/apps/web/lib/upstash/vector.ts
index 8b90a36fc0..66e386a726 100644
--- a/apps/web/lib/upstash/vector.ts
+++ b/apps/web/lib/upstash/vector.ts
@@ -1,14 +1,14 @@
import { Index } from "@upstash/vector";
export const vectorIndex = new Index({
- url: process.env.UPSTASH_VECTOR_REST_URL!,
- token: process.env.UPSTASH_VECTOR_REST_TOKEN!,
+ url: process.env.UPSTASH_VECTOR_REST_URL ?? "",
+ token: process.env.UPSTASH_VECTOR_REST_TOKEN ?? "",
});
export const emojiVectorIndex = new Index<{
emoji: string;
label: string;
}>({
- url: process.env.UPSTASH_VECTOR_EMOJI_REST_URL!,
- token: process.env.UPSTASH_VECTOR_EMOJI_REST_TOKEN!,
+ url: process.env.UPSTASH_VECTOR_EMOJI_REST_URL ?? "",
+ token: process.env.UPSTASH_VECTOR_EMOJI_REST_TOKEN ?? "",
});
diff --git a/apps/web/scripts/dev/upsert-emoji-embeddings.ts b/apps/web/scripts/dev/upsert-emoji-embeddings.ts
index 552b33f2a7..e81a21129a 100644
--- a/apps/web/scripts/dev/upsert-emoji-embeddings.ts
+++ b/apps/web/scripts/dev/upsert-emoji-embeddings.ts
@@ -1,5 +1,5 @@
-import { toEmojiMatches } from "@/lib/ai/search-emojis";
import "dotenv-flow/config";
+import { toEmojiMatches } from "../../lib/ai/search-emojis";
import { emojiVectorIndex } from "../../lib/upstash/vector";
const EMOJIBASE_DATA_URL =
diff --git a/apps/web/ui/shared/emoji-picker.tsx b/apps/web/ui/shared/emoji-picker.tsx
index 70e4090b54..d0411c312d 100644
--- a/apps/web/ui/shared/emoji-picker.tsx
+++ b/apps/web/ui/shared/emoji-picker.tsx
@@ -1,6 +1,7 @@
import type { EmojiMatch } from "@/lib/ai/search-emojis";
import { Button, Popover } from "@dub/ui";
import { FaceSmile } from "@dub/ui/icons";
+import { cn } from "@dub/utils";
import { EmojiPicker as EmojiPickerBase } from "frimousse";
import {
PropsWithChildren,
@@ -17,6 +18,18 @@ import {
const EMOJI_COLUMNS = 9;
+const LOADING_MESSAGES = [
+ "Discombobulating...",
+ "Percolating...",
+ "Conjuring...",
+ "Reticulating...",
+ "Vibing...",
+ "Finagling...",
+ "Noodling...",
+ "Simmering...",
+ "Baking...",
+];
+
function EmojiMatchGrid({
matches,
onSelect,
@@ -52,9 +65,9 @@ function EmojiMatchGrid({
);
}
-function EmojiSkeleton() {
+function EmojiSkeleton({ className }: { className?: string }) {
return (
- <div className="w-full pt-1.5" aria-hidden>
+ <div className={cn("w-full pt-1.5", className)} aria-hidden>
{Array.from({ length: 8 }, (_, row) => (
<div key={row} className="flex w-full px-1.5">
{Array.from({ length: EMOJI_COLUMNS }, (_, column) => (
@@ -80,9 +93,17 @@ function EmojiSearchFallback({
}) {
const query = normalizeEmojiQuery(search);
const semantic = useSemanticEmojiSearch(query, query.length >= 2);
+ const [loadingMessage] = useState(
+ () => LOADING_MESSAGES[Math.floor(Math.random() * LOADING_MESSAGES.length)],
+ );
if (semantic.status === "loading") {
- return <EmojiSkeleton />;
+ return (
+ <>
+ <EmojiSearchHeader>{loadingMessage}</EmojiSearchHeader>
+ <EmojiSkeleton className="pt-0" />
+ </>
+ );
}
if (semantic.status !== "ready") {
@@ -93,7 +114,20 @@ function EmojiSearchFallback({
);
}
- return <EmojiMatchGrid matches={semantic.matches} onSelect={onSelect} />;
+ return (
+ <>
+ <EmojiSearchHeader>Did you mean...</EmojiSearchHeader>
+ <EmojiMatchGrid matches={semantic.matches} onSelect={onSelect} />
+ </>
+ );
+}
+
+function EmojiSearchHeader({ children }: PropsWithChildren) {
+ return (
+ <div className="text-content-subtle w-full bg-white px-3 pb-1.5 pt-3 text-xs font-medium">
+ {children}
+ </div>
+ );
}
type EmojiPickerProps = PropsWithChildren<{
@@ -165,7 +199,7 @@ export function EmojiPicker({
setOpenPopover={setOpenPopover}
side="top"
align="start"
- sideOffset={anchorRect ? 6 : 38}
+ sideOffset={anchorRect ? 6 : 8}
anchor={anchorEl}
onEscapeKeyDown={() => {
keyboardDismissRef.current = true;