(triviaResult: TriviaResult)
| 158 | } |
| 159 | |
| 160 | function displaySingleQuestion(triviaResult: TriviaResult) { |
| 161 | const frame = figma.createFrame() |
| 162 | frame.fills = [{type: 'SOLID', color: {r: 1, g: 1, b: 1}}] |
| 163 | frame.verticalPadding = 25 |
| 164 | frame.horizontalPadding = 25 |
| 165 | frame.primaryAxisSizingMode = 'AUTO' |
| 166 | frame.counterAxisSizingMode = 'AUTO' |
| 167 | frame.itemSpacing = 10 |
| 168 | frame.cornerRadius = 20 |
| 169 | |
| 170 | const questionText = createText(triviaResult.question, 20) |
| 171 | frame.appendChild(questionText) |
| 172 | |
| 173 | const optionsFrame = figma.createFrame() |
| 174 | optionsFrame.itemSpacing = 10 |
| 175 | optionsFrame.layoutMode = "VERTICAL" |
| 176 | optionsFrame.counterAxisSizingMode = "AUTO" |
| 177 | |
| 178 | const options = reorderOptions(triviaResult.correctAnswer, triviaResult.incorrectAnswers) |
| 179 | for (const option of options) { |
| 180 | const optionText = createText(option, 24) |
| 181 | optionsFrame.appendChild(optionText) |
| 182 | } |
| 183 | frame.appendChild(optionsFrame) |
| 184 | |
| 185 | const correctAnswerFrame = figma.createFrame() |
| 186 | const correctAnswer = createText(triviaResult.correctAnswer, 24) |
| 187 | correctAnswerFrame.appendChild(correctAnswer) |
| 188 | |
| 189 | correctAnswerFrame.fills = [{type: 'SOLID', color: {r: .46, g: .86, b: .46} }] |
| 190 | correctAnswerFrame.resize(correctAnswer.width, correctAnswer.height) |
| 191 | |
| 192 | const answerCover = figma.createFrame() |
| 193 | answerCover.resize(correctAnswer.width, correctAnswer.height) |
| 194 | answerCover.fills = [{type: 'SOLID', color: {r: 0, g: 0, b: 0}}] |
| 195 | correctAnswerFrame.appendChild(answerCover) |
| 196 | frame.appendChild(correctAnswerFrame) |
| 197 | frame.layoutMode = "VERTICAL" |
| 198 | return frame |
| 199 | } |
| 200 | |
| 201 | function reorderOptions(correctAnswer: string, incorrectAnswers: string[]) { |
| 202 | const options = [...incorrectAnswers, correctAnswer] |
no test coverage detected