Skip to content

Commit

Permalink
minor improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
Br2850 committed Oct 18, 2024
1 parent b095575 commit 66daf79
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ const PillBadge = ({
) => {
if (typeof text === "string") return text;
if (Array.isArray(text)) {
if (text.length === 0) return "";
if (Array.isArray(text[0])) return text[0][0];
return text[0];
}
Expand All @@ -30,6 +31,7 @@ const PillBadge = ({
) => {
if (typeof text === "string") return color;
if (Array.isArray(text)) {
if (text.length === 0) return "default";
if (Array.isArray(text[0])) return text[0][1];
return color || "default";
}
Expand Down Expand Up @@ -87,7 +89,9 @@ const PillBadge = ({
) : undefined
}
label={
Array.isArray(text) && text.length > 0 && Array.isArray(text[0]) ? (
Array.isArray(text) &&
text.length > 0 &&
Array.isArray(text[0]) ? (
<Select
value={chipSelection}
variant={"standard"}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,6 @@ export default function SliderView(props) {
const focus = autoFocus(props);

const {
type,
min: schemaMin,
max: schemaMax,
multipleOf: schemaMultipleOf,
Expand Down Expand Up @@ -131,7 +130,7 @@ export default function SliderView(props) {
}
} else {
const floatValue = parseFloat(value);
if (!isNaN(floatValue)) {
if (!Number.isNaN(floatValue)) {
isMin ? setMinText(value) : setMaxText(value);
}
}
Expand Down
54 changes: 46 additions & 8 deletions fiftyone/operators/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -1472,11 +1472,24 @@ def __init__(self, **kwargs):
class LoadingView(ReadOnlyView):
"""Displays a loading indicator.
Examples::
schema_dots = {
text: "Loading dots only"
}
schema_spinner = {
variant: "spinner",
color: "primary",
size: "medium",
}
loading_dots = types.LoadingView(**schema_dots)
loading_spinner = types.LoadingView(**schema_spinner)
Args:
text ("Loading"): a label for the loading indicator
variant ("spinner"): the variant of the loading indicator
color ("primary"): the color of the loading indicator
size ("medium"): the size of the loading indicator
text (None): a label for the loading indicator
variant (None): the variant of the loading indicator
color (None): the color of the loading indicator
size (None): the size of the loading indicator
"""

def __init__(self, **kwargs):
Expand All @@ -1486,11 +1499,36 @@ def __init__(self, **kwargs):
class PillBadgeView(ReadOnlyView):
"""Displays a pill shaped badge.
Examples::
schema_options_single_color = {
text: ["Reviewed", "Not Reviewed"],
color: "primary",
variant: "outlined",
show_icon: True
}
schema_options_multi_color = {
text: [["Not Started", "primary"], ["Reviewed", "success"], ["In Review", "warning"]],
color: "primary",
variant: "outlined",
show_icon: True
}
schema_single_option= {
text: "Reviewed",
color: "primary",
variant: "outlined",
show_icon: True
}
badge = types.PillBadgeView(**schema_options_single_color)
Args:
text ("Reviewed" | ["Reviewed", "Not Reviewed"] | [["Not Started", "primary"], ["Reviewed", "success"], ["In Review", "warning"]): a label or set of label options with or without a color for the pill badge
color ("primary"): the color of the pill
variant ("outlined"): the variant of the pill
show_icon (False | True): whether to display indicator icon
text: a label or set of label options with or without a color for the pill badge
color (None): the color of the pill
variant (None): the variant of the pill
show_icon (None): whether to display indicator icon
"""

def __init__(self, **kwargs):
Expand Down

0 comments on commit 66daf79

Please sign in to comment.