mirror of
https://github.com/BerriAI/litellm.git
synced 2026-09-07 08:26:10 +00:00
fix(ui): theme the created-key box so it follows dark mode (#37985)
The virtual key shown after creating a key sits in a div with a
hardcoded #f8f8f8 inline background, so in dark mode the box keeps
the light background while the key text inherits the light foreground
color, leaving the key nearly unreadable. Swap the inline styles for
the bg-muted and text-foreground tokens, which resolve per theme.
(cherry picked from commit 5f56be3294)
This commit is contained in:
parent
947dbbf029
commit
5c3fa165c8
2 changed files with 11 additions and 9 deletions
|
|
@ -19,6 +19,15 @@ describe("CreatedKeyDisplay", () => {
|
|||
expect(screen.getByText("sk-test-123")).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it("should theme the key box with tokens instead of a hardcoded light background", () => {
|
||||
render(<CreatedKeyDisplay apiKey="sk-test-123" />);
|
||||
|
||||
const keyBox = screen.getByText("sk-test-123").parentElement as HTMLElement;
|
||||
|
||||
expect(keyBox).not.toHaveAttribute("style");
|
||||
expect(keyBox).toHaveClass("bg-muted");
|
||||
});
|
||||
|
||||
it("should display the security warning", () => {
|
||||
render(<CreatedKeyDisplay apiKey="sk-test-123" />);
|
||||
expect(screen.getByText(/you will not be able to view it again/i)).toBeInTheDocument();
|
||||
|
|
|
|||
|
|
@ -29,15 +29,8 @@ const CreatedKeyDisplay: React.FC<CreatedKeyDisplayProps> = ({ apiKey }) => {
|
|||
</p>
|
||||
|
||||
<p className="text-sm text-muted-foreground mt-3 mb-1">Virtual Key:</p>
|
||||
<div
|
||||
style={{
|
||||
background: "#f8f8f8",
|
||||
padding: "10px",
|
||||
borderRadius: "5px",
|
||||
marginBottom: "10px",
|
||||
}}
|
||||
>
|
||||
<pre style={{ wordWrap: "break-word", whiteSpace: "normal", margin: 0 }}>{apiKey}</pre>
|
||||
<div className="bg-muted rounded-md p-2.5 mb-2.5">
|
||||
<pre className="m-0 whitespace-normal break-words text-foreground">{apiKey}</pre>
|
||||
</div>
|
||||
|
||||
<CopyToClipboard text={apiKey} onCopy={handleCopy}>
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue