You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

38 lines
915 B

  1. package react.product;
  2. import react.ReactComponent;
  3. import react.ReactMacro.jsx;
  4. import Common;
  5. /**
  6. * A Product
  7. * @author fbarbut
  8. */
  9. class Product extends react.ReactComponentOfProps<{productInfo:ProductInfo}>
  10. {
  11. public function new(props)
  12. {
  13. super(props);
  14. }
  15. override public function render(){
  16. var p :ProductInfo = props.productInfo;
  17. //convert int to enum
  18. //p.unitType = Type.createEnumIndex(Common.Unit,cast p.unit);
  19. //var unit = ;
  20. var imgStyle = {width:'64px',height:'64px','backgroundImage':'url("${p.image}")'};
  21. var divStyle = p.active ? {} : {opacity: 0.4};
  22. return jsx('<div className="product row" style=$divStyle>
  23. <div className="col-md-4">
  24. <div src="${p.image}" className="productImg" style=$imgStyle/>
  25. </div>
  26. <div className="col-md-8">
  27. <strong>${p.name}</strong> ${p.qt} ${Formatting.unit(p.unitType)}<br/>
  28. ${p.price} &euro;
  29. </div>
  30. </div>');
  31. }
  32. }