Skip to content

Commit

Permalink
Merge pull request #523 from kipr/fix-operator-localization
Browse files Browse the repository at this point in the history
Fix localization for challenge conditions
  • Loading branch information
tcorbly authored Jan 22, 2025
2 parents 9090e6e + 364050b commit b8cf3a8
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 12 deletions.
2 changes: 1 addition & 1 deletion src/components/Challenge/EventViewer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ const Description = styled('div', {
fontSize: '0.8em',
});

interface EventViewerProps extends StyleProps {
export interface EventViewerProps extends StyleProps {
event: Event;
eventState?: boolean;
locale: LocalizedString.Language;
Expand Down
25 changes: 14 additions & 11 deletions src/components/Challenge/PredicateEditor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import Predicate from '../../state/State/Challenge/Predicate';
import PredicateCompletion from '../../state/State/ChallengeCompletion/PredicateCompletion';
import { StyleProps } from '../../util/style';
import HTree, { HTreeNode } from './HTree';
import EventViewer from './EventViewer';
import Operator from './Operator';
import EventViewer, { EventViewerProps } from './EventViewer';
import Operator, { OperatorProps } from './Operator';

export interface PredicateEditorProps extends StyleProps {
predicate: Predicate;
Expand Down Expand Up @@ -48,42 +48,45 @@ const treeify = (exprs: Dict<Expr>, rootId: string, events: Dict<Event>, locale:
case Expr.Type.And:
case Expr.Type.Or:
case Expr.Type.Xor: {
return {
const node: Node<OperatorProps> = {
type: Node.Type.NonTerminal,
parent: {
component: Operator,
// eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/no-unsafe-assignment
props: { type: root.type } as any
props: { type: root.type, locale }
},
children: Dict.generate(root.argIds, id => treeify(exprs, id, events, locale, exprStates)),
childrenOrdering: root.argIds,
state: exprStates ? exprStates[rootId] : undefined
};

return node;
}
case Expr.Type.Once:
case Expr.Type.Not: {
return {
const node: Node<OperatorProps> = {
type: Node.Type.NonTerminal,
parent: {
component: Operator,
// eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/no-unsafe-assignment
props: { type: root.type } as any
props: { type: root.type, locale }
},
children: Dict.generate([root.argId], id => treeify(exprs, id, events, locale, exprStates)),
childrenOrdering: [root.argId],
state: exprStates ? exprStates[rootId] : undefined
};

return node;
}
case Expr.Type.Event: {
return {
const node: Node<EventViewerProps> = {
type: Node.Type.Terminal,
node: {
component: EventViewer,
// eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/no-unsafe-assignment
props: { event: events[root.eventId], locale } as any
props: { event: events[root.eventId], locale }
},
state: exprStates ? exprStates[rootId] : undefined
};

return node;
}
}
};
Expand Down

0 comments on commit b8cf3a8

Please sign in to comment.