Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed <p> <ul> nesting error #1961

Merged
merged 1 commit into from
Jul 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 33 additions & 6 deletions src/renderer/components/NodeDocumentation/ConditionExplanation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -110,20 +110,38 @@ const renderPrimitive = (condition: PossiblePrimitive, options: RenderOptions):
return assertNever(condition);
}
};
const renderCondition = (condition: Condition, options: RenderOptions): JSX.Element => {
const renderCondition = (
condition: Condition,
prefix: JSX.Element | undefined,
options: RenderOptions
): JSX.Element => {
// Since we want to construct a natural language sentence, we can't just recursively render
// the condition. Instead, we need to do some analysis of the condition to determine how to
// render it. We also can't support all possible conditions, but that's okay. Most conditions
// are simple.

if (isPossiblePrimitive(condition)) {
return <>{renderPrimitive(condition, options)}.</>;
return (
<Text
fontSize="md"
userSelect="text"
>
{prefix}
{renderPrimitive(condition, options)}.
</Text>
);
}

return (
<>
{condition.kind === 'and' ? 'All of' : 'At least one of'} the following conditions must
be met:
<Text
fontSize="md"
userSelect="text"
>
{prefix}
{condition.kind === 'and' ? 'All of' : 'At least one of'} the following conditions
must be met:
</Text>
<UnorderedList
alignItems="left"
ml={0}
Expand All @@ -138,7 +156,7 @@ const renderCondition = (condition: Condition, options: RenderOptions): JSX.Elem
key={i}
userSelect="text"
>
{renderCondition(inner, options)}
{renderCondition(inner, undefined, options)}
</ListItem>
);
})}
Expand All @@ -153,5 +171,14 @@ interface CEProps {
}
// eslint-disable-next-line react/prop-types
export const ConditionExplanation = memo(({ condition, schema }: CEProps) => {
return renderCondition(simplifyCondition(condition), { schema });
return renderCondition(
simplifyCondition(condition),
<Text
as="i"
pr={1}
>
Condition:
</Text>,
{ schema }
);
});
19 changes: 4 additions & 15 deletions src/renderer/components/NodeDocumentation/NodeDocs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -166,21 +166,10 @@ const InputOutputItem = memo(({ type, item, condition, schema }: InputOutputItem
)}

{condition && !isTautology(condition) && (
<Text
fontSize="md"
userSelect="text"
>
<Text
as="i"
pr={1}
>
Condition:
</Text>
<ConditionExplanation
condition={condition}
schema={schema}
/>
</Text>
<ConditionExplanation
condition={condition}
schema={schema}
/>
)}

{isTextInput && (
Expand Down