MCPcopy Index your code
hub / github.com/figma/plugin-samples / startUI

Function startUI

trivia/code.ts:120–144  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

118}
119
120async function startUI() {
121 figma.showUI(__html__, { visible: false });
122 figma.ui.onmessage = async (msg) => {
123 if (msg.type === "category") {
124 categories = msg.response.trivia_categories.map(
125 (c: { name: string; id: number }) => ({ name: c.name, data: c.id })
126 );
127 } else if (msg.type === "questions") {
128 const response = msg.response
129 const triviaResponse: TriviaResponse = {
130 responseCode: response.response_code,
131 results: response.results.map(r => ({
132 category: r.category,
133 type: r.type,
134 difficulty: r.difficulty,
135 question: r.question,
136 correctAnswer: r.correct_answer,
137 incorrectAnswers: r.incorrect_answers
138 }))
139 }
140 displayQuestions(triviaResponse)
141 figma.closePlugin();
142 }
143 };
144}
145
146function displayQuestions(triviaResponse: TriviaResponse) {
147 const frame = figma.createFrame()

Callers 1

code.tsFile · 0.85

Calls 1

displayQuestionsFunction · 0.85

Tested by

no test coverage detected