zrób śmieszne zdania i przetłumacz na polski
import React, { useState, useEffect } from ‘react’; import { Dices, Save, Trash2, BookOpen, Star, RefreshCw, Sparkles, Snowflake } from ‘lucide-react’; const SentenceBuilder = () => { // Dane z obrazka const sentenceData = { starts: [ { id: 1, text: “There are” }, { id: 2, text: “I have” }, { id: 3, text: “I can see” }, { id: 4, text: “My friends are” }, { id: 5, text: “I’m eating” }, { id: 6, text: “I love” } ], adjectives: [ { id: 1, text: “tiny” }, { id: 2, text: “colourful” }, { id: 3, text: “delicious” }, { id: 4, text: “magical” }, { id: 5, text: “glowing” }, { id: 6, text: “frozen” } ], nouns: [ { id: 1, text: “dumplings” }, { id: 2, text: “stockings” }, { id: 3, text: “elves” }, { id: 4, text: “reindeer” }, { id: 5, text: “gingerbread cookies” }, { id: 6, text: “Santas” } ], places: [ { id: 1, text: “on the roof” }, { id: 2, text: “by the fireplace” }, { id: 3, text: “under the Christmas tree” }, { id: 4, text: “inside the box” }, { id: 5, text: “in the snow” }, { id: 6, text: “on the sleigh” } ] }; const [mode, setMode] = useState(‘manual’); // ‘manual’ or ‘dice’ const [currentSentence, setCurrentSentence] = useState({ start: null, adjective: null, noun: null, place: null }); const [savedSentences, setSavedSentences] = useState([]); const [diceRolling, setDiceRolling] = useState(null); // ‘start’, ‘adjective’, ‘noun’, ‘place’ or null const [diceResult, setDiceResult] = useState(1); // Funkcja do wyboru elementu const selectPart = (partType, item) => { setCurrentSentence(prev => ({ …prev, [partType]: item })); }; // Funkcja rzutu kostką const rollDice = (partType) => { setDiceRolling(partType); let counter = 0; const interval = setInterval(() => { setDiceResult(Math.ceil(Math.random() * 6)); counter++; if (counter > 10) { clearInterval(interval); const finalRoll = Math.ceil(Math.random() * 6); setDiceResult(finalRoll); setDiceRolling(null); // Znajdź odpowiednie słowo dla wyniku rzutu let collection; switch(partType) { case ‘start’: collection = sentenceData.starts; break; case ‘adjective’: collection = sentenceData.adjectives; break; case ‘noun’: collection = sentenceData.nouns; break; case ‘place’: collection = sentenceData.places; break; default: collection = []; } const selectedItem = collection.find(item => item.id === finalRoll); selectPart(partType, selectedItem); } }, 100); }; const saveSentence = () => { if (isSentenceComplete()) { setSavedSentences([currentSentence, …savedSentences]); setCurrentSentence({ start: null, adjective: null, noun: null, place: null }); } }; const isSentenceComplete = () => { return currentSentence.start && currentSentence.adjective && currentSentence.noun && currentSentence.place; }; const getFullSentenceText = (s) => { if (!s.start) return “”; return `${s.start.text} ${s.adjective.text} ${s.noun.text} ${s.place.text}.`; }; const clearHistory = () => { setSavedSentences([]); }; return (
{/* Header */}
{/* Mode Switcher */}
{/* Active Sentence Display */}
{/* Builder Area */}
)}
Christmas Sentence Builder
Ułóż świąteczne zdanie po angielsku!
Twoje Zdanie
{currentSentence.start ? currentSentence.start.text : “Start…”}
{currentSentence.adjective ? currentSentence.adjective.text : “Adjective…”}
{currentSentence.noun ? currentSentence.noun.text : “Noun…”}
{currentSentence.place ? currentSentence.place.text : “Place…”}
{/* Column 1: Start */}
selectPart(‘start’, item)}
mode={mode}
onRoll={() => rollDice(‘start’)}
isRolling={diceRolling === ‘start’}
diceResult={diceResult}
/>
{/* Column 2: Adjective */}
selectPart(‘adjective’, item)}
mode={mode}
onRoll={() => rollDice(‘adjective’)}
isRolling={diceRolling === ‘adjective’}
diceResult={diceResult}
/>
{/* Column 3: Noun */}
selectPart(‘noun’, item)}
mode={mode}
onRoll={() => rollDice(‘noun’)}
isRolling={diceRolling === ‘noun’}
diceResult={diceResult}
/>
{/* Column 4: Place */}
selectPart(‘place’, item)}
mode={mode}
onRoll={() => rollDice(‘place’)}
isRolling={diceRolling === ‘place’}
diceResult={diceResult}
/>
{/* Saved Sentences */}
{savedSentences.length > 0 && (
Moje Świąteczne Opowieści ({savedSentences.length})
{savedSentences.map((s, idx) => (
{savedSentences.length – idx}
))}
{getFullSentenceText(s)}
{title}
{mode === ‘dice’ && (
)}
{mode === ‘dice’ && (
{isRolling && (
)}
{items.map((item) => {
const isSelected = selectedId === item.id;
const isDiceMatch = mode === ‘dice’ && isRolling && diceResult === item.id;
return (
)
})}
{diceResult}
)}