UNPKG

@times-components/card

Version:

The card component fades in and lays out content that typically consists of an image and a collection of textual elements (although this content could be anything). Card manages the layout of these elements, whilst providing a consistent loading state for

1 lines • 8.65 kB
module.exports=function(e){var t={};function n(r){if(t[r])return t[r].exports;var o=t[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}return n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)n.d(r,o,function(t){return e[t]}.bind(null,o));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=7)}([function(e,t){e.exports=require("react")},function(e,t){e.exports=require("prop-types")},function(e,t){e.exports=require("@times-components/ts-styleguide/rnw")},function(e,t){e.exports=require("@times-components/utils/rnw")},function(e,t){e.exports=require("@times-components/gradient/rnw")},function(e,t){e.exports=require("styled-components")},function(e,t){e.exports=require("@times-components/image/rnw")},function(e,t,n){"use strict";n.r(t);var r=n(0),o=n.n(r),i=n(2),a=n(1),c=n.n(a);function l(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function s(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?l(Object(n),!0).forEach((function(t){u(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):l(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function u(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}s(s({},{contentContainerClass:c.a.string,imageContainerClass:c.a.string,imageRatio:c.a.number,isReversed:c.a.bool,showImage:c.a.bool}),{},{children:c.a.node,fadeImageIn:c.a.bool,highResSize:c.a.number,imageAccessibilityLabel:c.a.string,imageStyle:c.a.object,imageUri:c.a.string,isLoading:c.a.bool,isLcpItem:c.a.bool,lowResQuality:c.a.number,lowResSize:c.a.number});var f=s(s({},{contentContainerClass:"",imageContainerClass:"",imageRatio:1.5,isReversed:!1,showImage:!1}),{},{children:null,fadeImageIn:!1,highResSize:null,imageRatio:1,imageStyle:{},imageUri:null,isLoading:!1,isLcpItem:!1,lowResQuality:null,lowResSize:null}),p=n(3),m=n(5),b=n.n(m),y=n(6),g=n.n(y),d=n(4),O=n.n(d),h={cardContainer:{alignItems:"flex-start",display:"flex",flexDirection:"row",flexWrap:"wrap",justifyContent:"flex-end"},cardContainerTablet:{alignItems:"flex-start",flexDirection:"row",flexWrap:"wrap"},contentContainer:{flex:1,marginBottom:0,minWidth:"100%"},contentContainerTablet:{flex:1,marginBottom:0},headerContainer:{height:24,marginBottom:Object(i.spacing)(2),maxWidth:300},imageContainer:{flex:1,marginBottom:Object(i.spacing)(2),minWidth:"100%"},imageContainerTablet:{flex:1,maxWidth:320},lastBar:{marginBottom:0,maxWidth:240},loadingContentContainer:{minHeight:84},reversedCardContainer:{height:"auto"},reversedContentContainer:{marginBottom:Object(i.spacing)(2)},reversedImageContainer:{marginBottom:0},textContainer:{height:10,marginBottom:Object(i.spacing)(2)}};function j(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function w(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?j(Object(n),!0).forEach((function(t){v(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):j(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function v(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var C=function(){return o.a.createElement(r.Fragment,null,o.a.createElement(O.a,{degrees:264,style:h.headerContainer}),o.a.createElement(O.a,{degrees:267,style:h.textContainer}),o.a.createElement(O.a,{degrees:267,style:h.textContainer}),o.a.createElement(O.a,{degrees:267,style:w(w({},h.textContainer),h.lastBar)}))};function P(e){return(P="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function x(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function S(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?x(Object(n),!0).forEach((function(t){R(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):x(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function R(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function E(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function I(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function _(e,t){return(_=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function D(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var n,r=z(e);if(t){var o=z(this).constructor;n=Reflect.construct(r,arguments,o)}else n=r.apply(this,arguments);return L(this,n)}}function L(e,t){return!t||"object"!==P(t)&&"function"!=typeof t?function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e):t}function z(e){return(z=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}var B=function(e){!function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&_(e,t)}(a,e);var t,n,r,i=D(a);function a(){return E(this,a),i.apply(this,arguments)}return t=a,(n=[{key:"shouldComponentUpdate",value:function(e){var t=this.props,n=t.imageUri,r=t.lowResQuality,o=t.lowResSize,i=t.highResSize,a=t.isLoading,c=t.index;return n!==e.imageUri||r!==e.lowResQuality||o!==e.lowResSize||i!==e.highResSize||a!==e.isLoading||c!==e.index}},{key:"render",value:function(){var e=this.props,t=e.children,n=e.contentContainerClass,r=e.fadeImageIn,i=e.highResSize,a=e.imageAccessibilityLabel,c=e.imageContainerClass,l=e.imageRatio,s=e.imageStyle,u=e.imageUri,f=e.isLoading,m=e.isReversed,y=e.lowResQuality,d=e.lowResSize,O=e.relatedArticle,j=e.showImage,w=e.isLcpItem,v=b()(p.TcView).withConfig({displayName:"card-content__TcCardContainer",componentId:"sc-1w0wvq8-0"})(["",";"],(function(e){return e.styles&&e.styles})),P=function(){if(!j)return null;var e=O?h.imageContainer:h.imageContainerTablet;return o.a.createElement(p.TcView,{className:c,style:Object(p.checkStylesForUnits)(S(S(S({},e),s),m?h.reversedImageContainer:""))},o.a.createElement(g.a,{accessibilityLabel:a,aspectRatio:l,fadeImageIn:r,highResSize:i,lowResQuality:y,lowResSize:d,uri:u,isLcpItem:w}))},x=O?S(S({},h.cardContainer),{},{display:"block"}):h.cardContainer;return o.a.createElement(p.TcView,{style:Object(p.checkStylesForUnits)(S(S({},x),m?h.reversedCardContainer:""))},m?null:P(),o.a.createElement(v,{className:n,styles:Object(p.checkStylesForUnits)(S(S(S({},h.contentContainer),m?h.reversedContentContainer:""),f?h.loadingContentContainer:""))},f?o.a.createElement(C,null):t),m?P():null)}}])&&I(t.prototype,n),r&&I(t,r),a}(r.Component);B.defaultProps=f;var T=B,k=function(e){return e.isLoading?o.a.createElement(i.Animations.FadeIn,null,o.a.createElement(T,e)):o.a.createElement(T,e)};k.defaultProps=f;t.default=k}]);