Skip to content

Commit

Permalink
(fix): handle primitives better in playground union dropdown (#1171)
Browse files Browse the repository at this point in the history
  • Loading branch information
armandobelardo authored Jul 19, 2024
1 parent b82c476 commit 9781242
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,18 +40,33 @@ export const PlaygroundUniscriminatedUnionForm = memo<PlaygroundUniscriminatedUn

const options = useMemo(
() =>
undiscriminatedUnion.variants.map(
(variant, idx): FernDropdown.Option => ({
undiscriminatedUnion.variants.map((variant, idx): FernDropdown.Option => {
let labelFallback: string;
switch (variant.shape.type) {
// We should also likely handle literals here to make it not just say
// "literal" but the actual value of the literal, but not positive the best UX
case "primitive":
labelFallback = variant.shape.value.type;
break;
case "optional":
labelFallback = variant.shape.shape.type;
break;
default:
labelFallback = variant.shape.type;
break;
}
const capitalizedFallbacklabel = labelFallback.charAt(0).toUpperCase() + labelFallback.slice(1);
return {
type: "value",
label: variant.displayName ?? variant.shape.type,
label: variant.displayName ?? capitalizedFallbacklabel,
value: idx.toString(),
// todo: handle availability
tooltip:
variant.description != null ? (
<Markdown className="text-xs" mdx={variant.description} />
) : undefined,
}),
),
};
}),
[undiscriminatedUnion.variants],
);

Expand Down
6 changes: 6 additions & 0 deletions packages/ui/docs-bundle/.env.template
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# uncomment the next line when targeting the production cloud environment
# NEXT_PUBLIC_DOCS_DOMAIN=proficientai.docs.buildwithfern.com

# uncomment the next line when targeting the dev cloud environment
# NEXT_PUBLIC_DOCS_DOMAIN=polytomic.docs.dev.buildwithfern.com
WORKOS_API_KEY=""

0 comments on commit 9781242

Please sign in to comment.