I wrote a small app while learning Elm.
When the user clicks the “Add shadow” button,  a new shadow is appended to the list of shadows, and  I would like to randomly generate a color for it.
Right now, I am able to append a new shadow to the list  and generate a random color  independently. I can’t figure out how to make it work togheter.
The code is way better at explaining my issue than my words:
I would like to replace the
#000000 at this line with a randomly generated color (the code to generate the color is in the same file)
If I understand correctly, you want to generate the color in the same step as the shadow is added?
If so, you’ll want to use
Ranrom.step, which will require you to store a
Random.Seed in your model.
I’ll look into Random.step, thanks.
I’ve found a simpler solution.
When the “Add a shadow” button is clicked, I run the command to generate a color,
when the color has been generated, I actually add the shadow with the generated color.
@carlotm Your project has introduced me to Devbox. Thanks! I currently use Nix flakes but Devbox seems to be more user friendly and also built upon Nix.
BTW, feel free to submit your app to Built with Elm.
Yeah, it’s a lovely tool.
With the limitations of json, but lovely
This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.