CodingContractPopup now correctly displays innerHTML, desc should be changed to return jsx though.

This commit is contained in:
Olivier Gagnon
2021-05-05 19:06:08 -04:00
parent f7c1d64033
commit cedac23dfa
2 changed files with 15 additions and 15 deletions

View File

@ -107,10 +107,10 @@ export const codingContractTypesMetadata: ICodingContractTypeMetadata[] = [
{
desc: (n: number): string => {
return ["It is possible write four as a sum in exactly four different ways:\n\n",
" 3 + 1\n",
" 2 + 2\n",
" 2 + 1 + 1\n",
" 1 + 1 + 1 + 1\n\n",
"    3 + 1\n",
"    2 + 2\n",
"    2 + 1 + 1\n",
"    1 + 1 + 1 + 1\n\n",
`How many different ways can the number ${n} be written as a sum of at least`,
"two positive integers?"].join(" ");
},
@ -142,17 +142,17 @@ export const codingContractTypesMetadata: ICodingContractTypeMetadata[] = [
}
d += ["\nHere is an example of what spiral order should be:",
"\nExample:",
" [\n",
" [1, 2, 3],\n",
" [4, 5, 6],\n",
" [7, 8, 9]\n",
" ] should result in [1, 2, 3, 6, 9, 8 ,7, 4, 5]\n\n",
"    [\n",
"        [1, 2, 3],\n",
"        [4, 5, 6],\n",
"        [7, 8, 9]\n",
"    ] should result in [1, 2, 3, 6, 9, 8 ,7, 4, 5]\n\n",
"Note that the matrix will not always be square:\n",
" [\n",
" [1, 2, 3, 4]\n",
" [5, 6, 7, 8]\n",
" [9, 10, 11, 12]\n",
" ] should result in [1, 2, 3, 4, 8, 12, 11, 10, 9, 5, 6, 7"].join(" ");
"    [\n",
"        [1, 2, 3, 4]\n",
"        [5, 6, 7, 8]\n",
"        [9, 10, 11, 12]\n",
"    ] should result in [1, 2, 3, 4, 8, 12, 11, 10, 9, 5, 6, 7"].join(" ");
return d;
},

View File

@ -42,7 +42,7 @@ export class CodingContractPopup extends React.Component<IProps, IState>{
const contractType: CodingContractType = CodingContractTypes[this.props.c.type];
let description = [];
for (const [i, value] of contractType.desc(this.props.c.data).split('\n').entries())
description.push(<span key={i}>{value}<br/></span>);
description.push(<span key={i} dangerouslySetInnerHTML={{__html: value+'<br />'}}></span>);
return (
<div>
<CopyableText value={this.props.c.type} tag={ClickableTag.Tag_h1} />