Repository URL to install this package:
Version:
0.14.1 ▾
|
.. |
RadioOption |
SelectOption |
SquareOption |
state |
ProductOptions.tsx |
README.md |
TODO |
deps.tsx |
index.tsx |
styled.tsx |
typings.tsx |
onOptionClick
to onChange
item
attribute alongside product
ProductBlock
renderSku
to other placesproductList
which should be productOptionsListthis is the list of colors/images/sizes/fits ReactComponent for StockKeepingUnitChoices (SKU Props -> UI)
sku1: color: red, size: 10, fit: 'm' sku2: color: blue, size: 5, fit: 's', sku3: color: yellow, size: 20, fit: 's' sku4: color: pink, size: 40, fit: 'm' sku5: color: red, size: 50, fit: 'm' forEach key: color value: red color, size, fit red 10 m autoSelectSkuForValue(key, value) { // .find will return the first one it finds that matches const firstSkuMatching = this.skus.find(sku => { // value matches the key we are selecting return sku.skuinfo[key] === value }) this.currentlySelectedSku = firstSkuMatching } updateSkusForSelectedValue(key, value) { // set the keyvalue in our map this.currentlySelectedSkuProps[key] = value this.skus.forEach(sku => { const hasValidValue = sku.skuinfo[key] === value if (hasValidValue) { sku.isSelectAble = true } else { sku.isDisabled = true } }) } selectSkuValue(key, value) { this.updateSkusForSelectedValue(key, value) this.autoSelectSkuForValue(key, value) } .selectSkuValue('color', 'red')