Improve Zeckendorf Search Trick: label cards 1-8, add spoiler mode with highlights, use emoji buttons
This commit is contained in:
parent
2580f76025
commit
342e608b3a
1 changed files with 27 additions and 5 deletions
|
|
@ -57,6 +57,7 @@ const ZeckendorfSearchTrick = ({ showSocialShare = true }: ZeckendorfSearchTrick
|
||||||
const [showResult, setShowResult] = useState(false);
|
const [showResult, setShowResult] = useState(false);
|
||||||
const [isOneByOne, setIsOneByOne] = useState(false);
|
const [isOneByOne, setIsOneByOne] = useState(false);
|
||||||
const [isRandomized, setIsRandomized] = useState(true);
|
const [isRandomized, setIsRandomized] = useState(true);
|
||||||
|
const [isSpoiler, setIsSpoiler] = useState(false);
|
||||||
const [currentCardIndex, setCurrentCardIndex] = useState(0);
|
const [currentCardIndex, setCurrentCardIndex] = useState(0);
|
||||||
const [cards, setCards] = useState<Array<{id: number; title: string; numbers: number[]}>>([]);
|
const [cards, setCards] = useState<Array<{id: number; title: string; numbers: number[]}>>([]);
|
||||||
|
|
||||||
|
|
@ -72,7 +73,7 @@ const ZeckendorfSearchTrick = ({ showSocialShare = true }: ZeckendorfSearchTrick
|
||||||
|
|
||||||
// Generate cards with optional randomization
|
// Generate cards with optional randomization
|
||||||
const generateCards = () => {
|
const generateCards = () => {
|
||||||
const baseCards = FIBONACCI_NUMBERS.map(fib => {
|
const baseCards = FIBONACCI_NUMBERS.map((fib, index) => {
|
||||||
const numbers: number[] = [];
|
const numbers: number[] = [];
|
||||||
// Check numbers from 1 to 33 to see which ones contain this Fibonacci number
|
// Check numbers from 1 to 33 to see which ones contain this Fibonacci number
|
||||||
for (let i = 1; i <= 33; i++) {
|
for (let i = 1; i <= 33; i++) {
|
||||||
|
|
@ -83,7 +84,7 @@ const ZeckendorfSearchTrick = ({ showSocialShare = true }: ZeckendorfSearchTrick
|
||||||
|
|
||||||
return {
|
return {
|
||||||
id: fib,
|
id: fib,
|
||||||
title: `Card ${fib}`,
|
title: `Card ${index + 1}`,
|
||||||
numbers: numbers
|
numbers: numbers
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
@ -116,6 +117,11 @@ const ZeckendorfSearchTrick = ({ showSocialShare = true }: ZeckendorfSearchTrick
|
||||||
setCurrentCardIndex(0);
|
setCurrentCardIndex(0);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Handle spoiler toggle
|
||||||
|
const handleSpoilerToggle = (checked: boolean) => {
|
||||||
|
setIsSpoiler(checked);
|
||||||
|
};
|
||||||
|
|
||||||
// Navigation functions for one-by-one mode
|
// Navigation functions for one-by-one mode
|
||||||
const goToPreviousCard = () => {
|
const goToPreviousCard = () => {
|
||||||
setCurrentCardIndex(prev => Math.max(0, prev - 1));
|
setCurrentCardIndex(prev => Math.max(0, prev - 1));
|
||||||
|
|
@ -252,6 +258,15 @@ const ZeckendorfSearchTrick = ({ showSocialShare = true }: ZeckendorfSearchTrick
|
||||||
<Label htmlFor="randomized">Randomized order</Label>
|
<Label htmlFor="randomized">Randomized order</Label>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div className="flex items-center space-x-2">
|
||||||
|
<Switch
|
||||||
|
id="spoiler"
|
||||||
|
checked={isSpoiler}
|
||||||
|
onCheckedChange={handleSpoilerToggle}
|
||||||
|
/>
|
||||||
|
<Label htmlFor="spoiler">Spoiler</Label>
|
||||||
|
</div>
|
||||||
|
|
||||||
<Button onClick={reset} variant="outline" size="sm">
|
<Button onClick={reset} variant="outline" size="sm">
|
||||||
<RefreshCw className="w-4 h-4 mr-2" />
|
<RefreshCw className="w-4 h-4 mr-2" />
|
||||||
Reset
|
Reset
|
||||||
|
|
@ -298,7 +313,14 @@ const ZeckendorfSearchTrick = ({ showSocialShare = true }: ZeckendorfSearchTrick
|
||||||
<CardContent className="pt-0">
|
<CardContent className="pt-0">
|
||||||
<div className="grid grid-cols-4 gap-1 text-xs">
|
<div className="grid grid-cols-4 gap-1 text-xs">
|
||||||
{card.numbers.map(num => (
|
{card.numbers.map(num => (
|
||||||
<div key={num} className="bg-muted p-1 text-center rounded">
|
<div
|
||||||
|
key={num}
|
||||||
|
className={`p-1 text-center rounded ${
|
||||||
|
isSpoiler && num === card.id
|
||||||
|
? 'bg-yellow-200 font-bold'
|
||||||
|
: 'bg-muted'
|
||||||
|
}`}
|
||||||
|
>
|
||||||
{num}
|
{num}
|
||||||
</div>
|
</div>
|
||||||
))}
|
))}
|
||||||
|
|
@ -311,7 +333,7 @@ const ZeckendorfSearchTrick = ({ showSocialShare = true }: ZeckendorfSearchTrick
|
||||||
size="sm"
|
size="sm"
|
||||||
className="flex-1"
|
className="flex-1"
|
||||||
>
|
>
|
||||||
Contains my number
|
✅
|
||||||
</Button>
|
</Button>
|
||||||
<Button
|
<Button
|
||||||
onClick={() => handleCardSelection(card.id, 'absent')}
|
onClick={() => handleCardSelection(card.id, 'absent')}
|
||||||
|
|
@ -319,7 +341,7 @@ const ZeckendorfSearchTrick = ({ showSocialShare = true }: ZeckendorfSearchTrick
|
||||||
size="sm"
|
size="sm"
|
||||||
className="flex-1"
|
className="flex-1"
|
||||||
>
|
>
|
||||||
Does not contain
|
❌
|
||||||
</Button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
</CardContent>
|
</CardContent>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue