Skip to content

Open-source Grok Bot alternative with a virtual machine that bots can use

fix(bot-settings): keep the Color picker when the avatar is a photo

AdityaUmale8aca3b1ab95b
diff --git a/src/components/BotProfileAvatarCard.test.ts b/src/components/BotProfileAvatarCard.test.ts
index fce5ee9c64..d517aa877e 100644
--- a/src/components/BotProfileAvatarCard.test.ts
+++ b/src/components/BotProfileAvatarCard.test.ts
@@ -106,3 +106,24 @@ describe("BotProfileAvatarCard body picker", () => {
}
});
});
+
+describe("BotProfileAvatarCard color picker", () => {
+ it("keeps the color picker for a custom photo in every flat crop", () => {
+ for (const crop of ["circle", "rounded", "square"] as const) {
+ const markup = renderCard(makeBot({ avatarUrl: "/api/attachments/cat.webp", avatarCrop: crop, color: "blue" }));
+
+ expect(markup).toContain(">Color<");
+ expect(markup).toContain('aria-pressed="true" class="size-10');
+ expect(markup).toContain('aria-label="Use blue mascot color"');
+ expect(markup).not.toContain(">Expression<");
+ }
+ });
+
+ it("shows the color picker for the mascot too", () => {
+ const markup = renderCard(makeBot());
+
+ expect(markup).toContain(">Expression<");
+ expect(markup).toContain(">Color<");
+ expect(markup).toContain('aria-label="Use green mascot color"');
+ });
+});
diff --git a/src/components/BotProfileAvatarCard.tsx b/src/components/BotProfileAvatarCard.tsx
index 337ceb63e9..09cfd23b3c 100644
--- a/src/components/BotProfileAvatarCard.tsx
+++ b/src/components/BotProfileAvatarCard.tsx
@@ -141,29 +141,33 @@ export function BotProfileAvatarCard({
</button>
))}
</div>
+ </>
+ )}
- <div className="mb-2 mt-4 text-[12px] font-medium uppercase tracking-[0.08em] text-ink-secondary">
- {t("botIdentity.color")}
- </div>
- <div className="flex flex-wrap gap-2.5">
- {MAUS_COLOR_NAMES.map((color) => (
- <button
- key={color}
- type="button"
- disabled={busy}
- aria-pressed={bot.color === color}
- onClick={() => onPatch({ color })}
- className={cn(
- "size-10 rounded-full border-2 border-transparent transition-transform hover:scale-110 disabled:opacity-50",
- bot.color === color && "ring-2 ring-accent-border ring-offset-2 ring-offset-card",
- )}
- style={{ background: colorSwatch(color) }}
- title={t(MAUS_COLOR_LABEL[color])}
- aria-label={t("mascot.useColor", { color: colorName(color) })}
- />
- ))}
- </div>
+ <div className="mb-2 mt-4 text-[12px] font-medium uppercase tracking-[0.08em] text-ink-secondary">
+ {t("botIdentity.color")}
+ </div>
+ <div className="flex flex-wrap gap-2.5">
+ {MAUS_COLOR_NAMES.map((color) => (
+ <button
+ key={color}
+ type="button"
+ disabled={busy}
+ aria-pressed={bot.color === color}
+ onClick={() => onPatch({ color })}
+ className={cn(
+ "size-10 rounded-full border-2 border-transparent transition-transform hover:scale-110 disabled:opacity-50",
+ bot.color === color && "ring-2 ring-accent-border ring-offset-2 ring-offset-card",
+ )}
+ style={{ background: colorSwatch(color) }}
+ title={t(MAUS_COLOR_LABEL[color])}
+ aria-label={t("mascot.useColor", { color: colorName(color) })}
+ />
+ ))}
+ </div>
+ {crop === "mascot" && (
+ <>
<div className="mb-2 mt-4 text-[12px] font-medium uppercase tracking-[0.08em] text-ink-secondary">
{t("botIdentity.body")}
</div>