Closed lucharo closed 1 year ago
So I'm working on this in the branch play-mode. The issue is that I need every ingredient to be assigned to a step, considering this I thought of expanding the current very simple YAML spec to include more info for ingredients such as: name, quantity, unit, and step. This I could do manually but I have refused (maybe wrong choice) and I've explored options such as having simple recipes in a simple format that then get turned into the slightly more complex yaml format after some fancy regex and nlp token matching. I have then considered incorporating the cooklang language to my recipes but then I have realised that the cooklang spec doesn't include the step info by default and I am not sure how easy it is to extend the language (I've raised an issue in the cooklang-ts repo). Maybe I just do the editing semi manually
To implement this feature, you can follow these steps:
Here's an updated version of your
Recipe.tsx
component with the changes:And then add the CSS classes in your
styles.css
:This implementation will:
currentSlide
to hold the index of the current slide.handleSpacebar
function to increment thecurrentSlide
value when the spacebar is pressed.useEffect
hook to add and remove the event listener for the spacebar event.handlePlayClick
function to increment thecurrentSlide
value when the play button is clicked.active-step
andinactive-step
CSS classes based on the value ofcurrentSlide
.Now, when you press the spacebar or click the play button, the steps will highlight one by one, and the ingredients corresponding to the highlighted step will turn bold, while the other ingredients will turn slightly transparent.