DnD Coin Purse
November 6, 2021
Just when I thought I was out, DnD pulls me back in!
This was more complicated than I expected. I wanted to make something simple that used modular math to calculate coin amounts based on some total, but making it functional meant a lot of little UI tweaks.
I originally used ‘+’ and ‘-’ buttons to change coin values, but realized that would be awful for large amounts, so I switched to managing exchanges in a popup window. The popup sorta needed to be its own component to prevent my code from turning to spaghetti, so I had to use a bit of parent-child communication, and making inputs more pleasant to use required controlling them, allowing only number values and highlighting the contents when the user clicks into the box.
I’m a bit under the weather right now, so I’ll add the finished pouch to this page another day. For now, you can find the CodePen here.