I'm looking to display the $colors
name depending on which color swatch button is clicked on. Here is my code to display the color swatch buttons, but I'm not sure on how I should change the $colors
name depending on what is clicked on. A lot of big brand retailers have examples of this on their websites. Here is an example on Urban Outfitters of what I'd like to happen when changing the color. When switching between the colors, the name changes from "Gold" to "Taupe" in this example.
$colors: (
'color-Navy' #2D2F3C,
'color-Ash' #EEF0F2,
'color-Black' #060606,
'color-White' #F6F6F6,
'color-Charcoal' #59545A,
);
@each $color in $colors {
$colorName: nth($color, 1);
$bgColor: nth($color, 2);
#ProductSelect-option-#{$colorName} + label {
background-color: $bgColor;
color: $bgColor;
width: 50px;
height: 50px;
overflow: hidden;
border-radius: 25px;
margin: 5px;
text-indent: 100%;
white-space: nowrap;
}
#ProductSelect-option-#{$colorName}:checked + label {
border-color: #555;
border-width: 3px;
}
}