🆙 Init V3

This commit is contained in:
DuckieTM
2026-01-31 09:10:52 +01:00
commit 7feb10ab15
1733 changed files with 53405 additions and 0 deletions
@@ -0,0 +1,44 @@
import { FC } from 'react';
import { VALUE_KEY_DISLIKE, VALUE_KEY_LIKE } from '../../../../api';
import { Column, Flex, Text } from '../../../../common';
interface WordQuizQuestionViewProps
{
question: string;
canVote: boolean;
vote(value: string): void;
noVotes: number;
yesVotes: number;
}
export const WordQuizQuestionView: FC<WordQuizQuestionViewProps> = props =>
{
const { question = null, canVote = null, vote = null, noVotes = null, yesVotes = null } = props;
return (
<Column className="wordquiz-question p-2" gap={ 2 }>
{ !canVote &&
<div className="flex w-full items-center gap-2">
<div className="flex items-center justify-center cursor-pointer bg-danger rounded p-2">
<Text variant="white">{ noVotes }</Text>
</div>
<Text center textBreak variant="white">{ question }</Text>
<div className="flex items-center justify-center cursor-pointer bg-success rounded p-2">
<Text variant="white">{ yesVotes }</Text>
</div>
</div> }
{ canVote &&
<div className="flex flex-col">
<Text center textBreak variant="white">{ question }</Text>
<div className="flex w-full gap-1 justify-center">
<Flex center pointer className="bg-danger rounded p-1" onClick={ event => vote(VALUE_KEY_DISLIKE) }>
<div className="word-quiz-dislike" />
</Flex>
<Flex center pointer className="bg-success rounded p-1" onClick={ event => vote(VALUE_KEY_LIKE) }>
<div className="word-quiz-like" />
</Flex>
</div>
</div> }
</Column>
);
};
@@ -0,0 +1,24 @@
import { RoomObjectCategory } from '@nitrots/nitro-renderer';
import { FC } from 'react';
import { VALUE_KEY_DISLIKE } from '../../../../api';
import { BaseProps } from '../../../../common';
import { ObjectLocationView } from '../object-location/ObjectLocationView';
interface WordQuizVoteViewProps extends BaseProps<HTMLDivElement>
{
userIndex: number;
vote: string;
}
export const WordQuizVoteView: FC<WordQuizVoteViewProps> = props =>
{
const { userIndex = null, vote = null, ...rest } = props;
return (
<ObjectLocationView category={ RoomObjectCategory.UNIT } objectId={ userIndex } { ...rest }>
<div className={ `flex justify-center items-center cursor-pointer bg-${ (vote === VALUE_KEY_DISLIKE) ? 'danger' : 'success' } rounded p-1` }>
<div className={ `word-quiz-${ (vote === VALUE_KEY_DISLIKE) ? 'dislike' : 'like' }-sm` } />
</div>
</ObjectLocationView>
);
};
@@ -0,0 +1,19 @@
import { FC } from 'react';
import { VALUE_KEY_DISLIKE, VALUE_KEY_LIKE } from '../../../../api';
import { useWordQuizWidget } from '../../../../hooks';
import { WordQuizQuestionView } from './WordQuizQuestionView';
import { WordQuizVoteView } from './WordQuizVoteView';
export const WordQuizWidgetView: FC<{}> = props =>
{
const { question = null, answerSent = false, answerCounts = null, userAnswers = null, vote = null } = useWordQuizWidget();
return (
<>
{ question &&
<WordQuizQuestionView canVote={ !answerSent } noVotes={ answerCounts.get(VALUE_KEY_DISLIKE) || 0 } question={ question.content } vote={ vote } yesVotes={ answerCounts.get(VALUE_KEY_LIKE) || 0 } /> }
{ userAnswers &&
Array.from(userAnswers.entries()).map(([ key, value ], index) => <WordQuizVoteView key={ index } userIndex={ key } vote={ value.value } />) }
</>
);
};