-
Notifications
You must be signed in to change notification settings - Fork 285
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(playground): allow up to 4 instances, distinguish alphabetically (…
…#4951) * WIP * feat(playground): allow up to 4 playground instances, distinguish alphabetically
- Loading branch information
1 parent
b65ddeb
commit c108625
Showing
9 changed files
with
125 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import React, { useMemo } from "react"; | ||
import { schemeSet2 } from "d3-scale-chromatic"; | ||
import { transparentize } from "polished"; | ||
import { css } from "@emotion/react"; | ||
|
||
function indexToChar(index: number) { | ||
// Wrap around using modulo if index exceeds 'C' | ||
const charCode = 65 + index; // 'A' has ASCII code 65, 'B' is 66, 'C' is 67 | ||
return String.fromCharCode(charCode); | ||
} | ||
|
||
export function AlphabeticIndexIcon({ index }: { index: number }) { | ||
const char = useMemo(() => indexToChar(index), [index]); | ||
const color = useMemo(() => schemeSet2[index % 8], [index]); | ||
const backgroundColor = useMemo(() => transparentize(0.8, color), [color]); | ||
return ( | ||
<div | ||
css={css` | ||
color: ${color}; | ||
background-color: ${backgroundColor}; | ||
width: 24px; | ||
height: 24px; | ||
display: flex; | ||
flex-direction: column; | ||
justify-content: center; | ||
align-items: center; | ||
border-radius: var(--ac-global-rounding-small); | ||
`} | ||
> | ||
{char} | ||
</div> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import React from "react"; | ||
|
||
import { Flex } from "@arizeai/components"; | ||
|
||
import { AlphabeticIndexIcon } from "@phoenix/components/AlphabeticIndexIcon"; | ||
|
||
/** | ||
* Display the alphabetic index and title in a single line | ||
*/ | ||
export function TitleWithAlphabeticIndex({ | ||
index, | ||
title, | ||
}: { | ||
index: number; | ||
title: string; | ||
}) { | ||
return ( | ||
<Flex direction="row" gap="size-100" alignItems="center"> | ||
<AlphabeticIndexIcon index={index} /> | ||
<span>{title}</span> | ||
</Flex> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters