-
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.
fix(embeddings): add color by correctness
- Loading branch information
1 parent
438323b
commit 1d2de97
Showing
8 changed files
with
252 additions
and
150 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,43 @@ | ||
import { Icon, Icons, Radio, RadioGroup } from "@arizeai/components"; | ||
import React from "react"; | ||
|
||
export enum CanvasMode { | ||
move = "move", | ||
select = "select", | ||
} | ||
|
||
/** | ||
* TypeGuard for the canvas mode | ||
*/ | ||
function isCanvasMode(m: unknown): m is CanvasMode { | ||
return typeof m === "string" && m in CanvasMode; | ||
} | ||
|
||
type CanvasModeRadioGroupProps = { | ||
mode: CanvasMode; | ||
onChange: (mode: CanvasMode) => void; | ||
}; | ||
|
||
export function CanvasModeRadioGroup(props: CanvasModeRadioGroupProps) { | ||
return ( | ||
<RadioGroup | ||
defaultValue={props.mode} | ||
variant="inline-button" | ||
size="normal" | ||
onChange={(v) => { | ||
if (isCanvasMode(v)) { | ||
props.onChange(v); | ||
} else { | ||
throw new Error(`Unknown canvas mode: ${v}`); | ||
} | ||
}} | ||
> | ||
<Radio label="Move" value={CanvasMode.move}> | ||
<Icon svg={<Icons.MoveFilled />} /> | ||
</Radio> | ||
<Radio label="Select" value={CanvasMode.select}> | ||
<Icon svg={<Icons.LassoOutline />} /> | ||
</Radio> | ||
</RadioGroup> | ||
); | ||
} |
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 from "react"; | ||
import { Picker, Item } from "@arizeai/components"; | ||
import { ColoringStrategy } from "./types"; | ||
|
||
function isColoringStrategy(strategy: unknown): strategy is ColoringStrategy { | ||
return typeof strategy === "string" && strategy in ColoringStrategy; | ||
} | ||
|
||
const ColoringStrategies = Object.values(ColoringStrategy); | ||
|
||
type ColoringStrategyPickerProps = { | ||
strategy: ColoringStrategy; | ||
onChange: (strategy: ColoringStrategy) => void; | ||
}; | ||
export function ColoringStrategyPicker(props: ColoringStrategyPickerProps) { | ||
const { strategy, onChange } = props; | ||
return ( | ||
<Picker | ||
defaultSelectedKey={strategy} | ||
aria-label="Coloring strategy" | ||
addonBefore="Color by" | ||
onSelectionChange={(key) => { | ||
if (isColoringStrategy(key)) { | ||
onChange(key); | ||
} | ||
}} | ||
> | ||
{ColoringStrategies.map((item) => ( | ||
<Item key={item}>{item}</Item> | ||
))} | ||
</Picker> | ||
); | ||
} |
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
Oops, something went wrong.