-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
77 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
"use client"; | ||
import React, { useState } from "react"; | ||
import { getPintxoColor } from "../../utils/uiUtils"; | ||
import pintxosData from "../../constants/pintxosData"; | ||
|
||
interface PintxoNameCardProps { | ||
currentPintxoCondition: { | ||
time: string; | ||
condition: string; | ||
}[]; | ||
} | ||
function PintxoConditionNameCard({ | ||
currentPintxoCondition, | ||
}: PintxoNameCardProps) { | ||
const [pintxoOpen, setPintxoOpen] = useState<boolean>(false); | ||
|
||
const switchPintxoCard = ( | ||
event: React.MouseEvent<HTMLDivElement> | ||
): void => { | ||
event.preventDefault(); // Prevent the default behavior | ||
setPintxoOpen(!pintxoOpen); | ||
}; | ||
|
||
const pintxoExplain = pintxosData.find( | ||
(pintxo) => pintxo.title === currentPintxoCondition[0].condition | ||
); | ||
return ( | ||
<div onClick={switchPintxoCard} className="w-full flex"> | ||
{pintxoOpen ? ( | ||
<div | ||
className={`ml-4 flex w-full h-20 justify-center items-center mx-auto rounded-sm ${pintxoExplain?.color} opacity-80 hover:opacity-100`} | ||
> | ||
<div className="font-body text-xs text-dark"> | ||
{pintxoExplain?.short} | ||
</div> | ||
</div> | ||
) : ( | ||
<div | ||
className={`ml-4 flex w-full h-20 justify-center items-center mx-auto rounded-sm ${getPintxoColor( | ||
currentPintxoCondition[0].condition | ||
)} opacity-80 hover:opacity-100`} | ||
> | ||
<div className="font-display text-dark"> | ||
{currentPintxoCondition[0].condition} | ||
</div> | ||
</div> | ||
)} | ||
</div> | ||
); | ||
} | ||
|
||
export default PintxoConditionNameCard; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
export function getPintxoColor(condition: string): string { | ||
switch (condition) { | ||
case "Empty Plate": | ||
console.log("condition", condition); | ||
return "bg-purple-400"; | ||
case "Bread Only": | ||
return "bg-red-400"; | ||
case "Gilda": | ||
return "bg-orange-400"; | ||
case "Txistorra": | ||
return "bg-yellow-400"; | ||
case "Gambas": | ||
return "bg-lime-400"; | ||
case "Txuleta Feast": | ||
return "bg-green-400"; | ||
default: | ||
return "bg-gray-400"; | ||
} | ||
} |