Build a reusable ColorList that starts with a supplied array of green and red items. Each item is a button, and its current color determines what happens when it is clicked.
A green click turns only the clicked item red, keeps it in the same position, and appends one new green item to the end of that list. A red click removes only the clicked item. Repeated colors are separate items: changing one must never change every item with that color.
The supplied App renders primary, secondary, empty, and red-only lists. Implement the interactions in the selected framework and keep each instance independent.
Input: Mount ColorList with colors=["green", "red", "green"] and groupId="primary". Output: Green, Red, Green, Item count: 3
Input: From ["green", "red", "green"], click the first Green button. Output: Red, Red, Green, Green, Item count: 4
Input: From ["red", "red", "green", "green"], click the second Red button. Output: Red, Green, Green, Item count: 3
Input: From ["red"], click its Red button. Output: No colors left., Item count: 0
colors supplies the initial ordered list, and groupId scopes that instance. Clicking green increases its length by one; clicking red decreases its length by one. Green items remain available as long as the initial list contains any green. The all-red demo demonstrates deletion down to an empty list.