Añadir un selector de tamaño de anillo personalizado
Paso 1:
Agregar el script tngSelect.js y los estilos al tangiblee-mapper.js.
![](https://cdn.prod.website-files.com/6125ee5e44f54b746e2b7c3b/63cfff8cd80cc7aec5740407_Screenshot%202023-01-16%20at%2010.14.24%20AM.png)
//=require 'shared/helpers/tngSelect/tngSelect.js'
(function() {
var tgcarousel = tngCarouselModule.getCss();
var tgSelect = tngSelectModule.getCss();
var css = tgcarousel + tgSelect + '<< style.css >>';
var style = document.createElement('style');
if (style.styleSheet) {
style.styleSheet.cssText = css;
} else {
style.appendChild(document.createTextNode(css));
}
document.getElementsByTagName('head')[0].appendChild(style);
})();
Paso 2:
Agregar nuestra selección personalizada al mapeador.
Por ejemplo:
![](https://cdn.prod.website-files.com/6125ee5e44f54b746e2b7c3b/63cfffd48b1f206528f2aeec_Screenshot%202023-01-16%20at%2010.17.18%20AM.png)
var origSelect = document.querySelector('#js-sku-change');
var handlerSizeSelectClick = function(event) {
origSelect.value = event.target.dataset.value;
};
var outsideSelect = (function() {
var selectInstance = null;
var getActiveItemIndex = function() {
if (!origSelect) return -1;
var activeIndex = origSelect.selectedIndex;
return activeIndex;
};
var insert = function() {
remove();
selectInstance = new tngSelectModule.tngSelect(origSelect, {
current: getActiveItemIndex()
},
handlerSizeSelectClick,
triggerPdpATCClick);
};
var remove = function() {
[].forEach.call(document.querySelectorAll('.tng-select-wrapper'), function(el) {
el && el.parentNode && el.parentNode.removeChild(el);
});
};
return {
insert: insert,
remove: remove
};
})();
Paso 3:
La selección se añadiría cuando un usuario hiciera clic en una CTA y abriera el widget.
![](https://cdn.prod.website-files.com/6125ee5e44f54b746e2b7c3b/63d0001b65e5cbe470874f72_Screenshot%202023-01-16%20at%2010.20.29%20AM.png)
var onWidgedRendered = function() {
outsideSelect.insert();
}
Paso 4:
Para insertar el selector, necesitaríamos agregar un espacio libre en el pie de página del widget donde deberíamos agregar las clases externas (tg-size-selector/tg-color-selector) en la integración. También deberíamos añadir los siguientes estilos en el widget (el archivo css del cliente).
/*===COLOR AND SIZE SELECTORS===*/
.ux4:not(.from-qr).tg-color-selector .header,
.ux4:not(.from-qr).tg-size-selector .header {
max-height: 128px; /*for animation*/
}
.ux4:not(.from-qr).tg-color-selector.tg-size-selector .header {
max-height: 182px; /*for animation*/
}
.ux4:not(.from-qr).tg-color-selector .header--hidden,
.ux4:not(.from-qr).tg-size-selector .header--hidden,
.ux4:not(.from-qr).tg-color-selector.tg-size-selector .header--hidden {
max-height: 0; /*for animation*/
}
.ux4:not(.from-qr).tg-color-selector .header__text-container,
.ux4:not(.from-qr).tg-size-selector .header__text-container {
padding-top: 74px;
margin-bottom: 10px;
}
.ux4:not(.from-qr).tg-color-selector.tg-size-selector .header__text-container {
margin-bottom: 0;
padding-top: 110px;
}
.ux4:not(.from-qr).tg-color-selector .minicart__add-to-cart,
.ux4:not(.from-qr).tg-size-selector .minicart__add-to-cart {
margin-top: auto;
}
.ux4:not(.from-qr).tg-color-selector .header::before,
.ux4:not(.from-qr).tg-size-selector .header::before {
content: '';
position: absolute;
left: 0;
display: block;
width: 100%;
height: 6px;
box-shadow: inset 0 -6px 6px -6px rgb(0 0 0 / 20%);
box-sizing: border-box;
}
.ux4:not(.from-qr).tg-color-selector .header::before {
bottom: 70px;
}
.ux4:not(.from-qr).tg-size-selector .header::before {
bottom: 126px;
}
.ux4:not(.from-qr).tg-color-selector .control-panel-ux4__wrapper,
.ux4:not(.from-qr).tg-size-selector .control-panel-ux4__wrapper{
box-shadow: none;
}
@media screen and (width: 480px) {
.ux4:not(.from-qr).tg-color-selector .qr-block,
.ux4:not(.from-qr).tg-size-selector .qr-block {
padding-top: 55px;
}
.ux4:not(.from-qr).tg-size-selector.tg-color-selector .qr-block {
padding-top: 15px;
}
}
@media (min-height: 799px) {
.ux4:not(.from-qr).tg-size-selector.tg-color-selector .qr-block {
padding-top: 195px;
}
}
/*===COLOR SELECTOR===*/
.ux4:not(.from-qr).tg-color-selector .header {
max-height: 126px; /*for animation*/
}
.ux4:not(.from-qr).tg-color-selector .header--hidden {
max-height: 0; /*for animation*/
}
.ux4:not(.from-qr).tg-color-selector .header__text-container {
padding-top: 74px;
margin-bottom: 10px;
}
.ux4:not(.from-qr).tg-color-selector .minicart__add-to-cart {
margin-top: auto;
}
.ux4:not(.from-qr).tg-color-selector .header::before {
content: '';
position: absolute;
left: 0;
display: block;
width: 100%;
height: 6px;
box-shadow: inset 0 -6px 6px -6px rgb(0 0 0 / 20%);
box-sizing: border-box;
}
.ux4:not(.from-qr).tg-color-selector .header::before {
bottom: 70px;
}
.ux4:not(.from-qr).tg-color-selector .control-panel-ux4__wrapper {
box-shadow: none;
}
@media screen and (width: 480px) {
.ux4:not(.from-qr).tg-color-selector .qr-block {
padding-top: 55px;
}
}
/*===SIZE SELECTOR===*/
.ux4:not(.from-qr).tg-size-selector .header {
max-height: 128px; /*for animation*/
}
.ux4:not(.from-qr).tg-size-selector .header--hidden {
max-height: 0; /*for animation*/
}
.ux4:not(.from-qr).tg-size-selector .header__text-container {
padding-top: 74px;
margin-bottom: 10px;
}
.ux4:not(.from-qr).tg-size-selector .minicart__add-to-cart {
margin-top: auto;
}
.ux4:not(.from-qr).tg-size-selector .header::before {
content: '';
position: absolute;
left: 0;
display: block;
width: 100%;
height: 6px;
box-shadow: inset 0 -6px 6px -6px rgb(0 0 0 / 20%);
box-sizing: border-box;
}
.ux4:not(.from-qr).tg-size-selector .header::before {
bottom: 126px;
}
.ux4:not(.from-qr).tg-size-selector .control-panel-ux4__wrapper{
box-shadow: none;
}
@media screen and (width: 480px) {
.ux4:not(.from-qr).tg-size-selector .qr-block {
padding-top: 55px;
}
}