@lanaco/lnc-react-ui
Version:
React component library
106 lines (93 loc) • 5.92 kB
JavaScript
"use strict";const t=require("react/jsx-runtime"),u=require("react"),S=require("./emotion-styled.browser.esm-DwHBgTPn.cjs"),w=require("./breakpoints-CcVm-gVm.cjs"),$=require("./useDetectMobile-DYV6V1yw.cjs"),a=require("./utils-BK6B_Y9X.cjs"),R=require("./style-cJUZrJoG.cjs"),q=require("./Button.cjs"),L=require("./index-DOkcmaFO.cjs"),O=require("./index-BskHxjAq.cjs"),D=S.styled.div`
display: grid;
grid-template-columns: ${o=>`repeat(${o.limit}, minmax(0, 1fr))`};
gap: 1.25rem;
@media ${w.down("M")} {
grid-template-columns: repeat(2, 1fr);
}
@media ${w.down("S")} {
grid-template-columns: repeat(2, 1fr);
}
@media ${w.down("XS")} {
grid-template-columns: repeat(1, 1fr);
}
`,A=S.styled.a`
text-decoration: none;
color: var(--gray-950);
display: flex;
flex-direction: column;
width: 100%;
box-shadow: 0px 1px 3px 0px rgba(0, 0, 0, 0.1),
0px 1px 2px 0px rgba(0, 0, 0, 0.06);
background-color: var(--white, #fff);
border-radius: 0.75rem;
border: 1px solid var(--gray-95008, #14161a14);
overflow: hidden;
min-height: 23rem;
cursor: pointer;
height: 100%;
& .blog-card-content {
display: flex;
padding: 1rem;
flex-direction: column;
justify-content: space-between;
height: 100%;
border-top: 1px solid var(--gray-95008, #14161a14);
gap: 1.25rem;
}
& img {
max-height: 12.5rem;
min-height: 12.5rem;
object-fit: cover;
width: 100%;
}
& .tags-wr {
display: flex;
flex-wrap: wrap;
gap: 0.5rem;
}
@media ${w.down("S")} {
max-height: 100%;
min-height: 100%;
}
`,B=S.styled.div`
display: flex;
flex-direction: column;
gap: 0;
color: var(--gray-950, #14161a);
& .text-wr-title {
font-weight: 600;
font-size: 1rem;
}
& .text-wr {
font-weight: 400;
font-size: 0.875rem;
flex: 1;
color: var(--gray-700, #4e555f);
${a.truncateTextInRows(2)}
}
& .info-wr {
display: flex;
align-items: center;
gap: 0.25rem;
justify-content: space-between;
color: var(--gray-600, #676e79);
font-size: 0.75rem;
font-weight: 400;
padding-bottom: 0.75rem;
& .mng {
font-size: 0.875rem;
color: var(--gray-300, #c4c8cf);
}
}
& .info-wr-1 {
display: flex;
align-items: center;
gap: 0.25rem;
}
& .info-wr-2 {
display: flex;
align-items: center;
gap: 1rem;
}
`,z=u.forwardRef((o,C)=>{const{title:p,imageUrl:y,text:N,numberOfLikes:r,numberOfComments:f,timeToRead:l,publishedAt:c,tags:s,onCardClick:h,timeToReadText:d="{0} min read",metadata:i,titleSlug:m,LinkComponent:g}=o,b=g||"a",j=u.useRef();return t.jsxs(A,{ref:j,className:"blog-card","data-accessor":i==null?void 0:i.accessor,name:i==null?void 0:i.name,onClick:e=>h(e,j),as:b,...g?{to:`/blog/${m}`}:{href:`/blog/${m}`},children:[t.jsx(L.ProductImageWrapper,{src:y}),t.jsxs("div",{className:"blog-card-content",children:[t.jsxs(B,{children:[t.jsxs("div",{className:"info-wr",children:[t.jsxs("div",{className:"info-wr-1",children:[t.jsxs("span",{children:[a.formatLocaleDateString(c)," "]}),t.jsx("span",{className:"small-dot",children:"●"}),l&&d?`${a.formatString(d,l)}`:"N/A"]}),t.jsxs("div",{className:"info-wr-2",children:[t.jsxs("span",{className:"info-wr-1",children:[t.jsx("i",{className:"mng mng-lnc-thumbs-up--filled"}),t.jsx("span",{children:a.getRoundedNumber(r)})]}),t.jsxs("span",{className:"info-wr-1",children:[t.jsx("i",{className:"mng mng-lnc-messages-filled"}),t.jsx("span",{children:a.getRoundedNumber(f)})]})]})]}),t.jsx("div",{className:"text-wr-title",children:p}),t.jsx("div",{className:"text-wr",children:N})]}),s&&t.jsx("div",{className:"tags-wr",children:s==null?void 0:s.map((e,n)=>t.jsx(R.BlogTag,{color:e==null?void 0:e.color,children:e==null?void 0:e.name},n))})]})]})}),k=u.memo(z),M=u.forwardRef((o,C)=>{const{icon:p,title:y,onButtonAction:N,items:r,buttonText:f,timeToReadText:l,limit:c=3,onSelectCard:s=()=>{},isLoading:h=!1,buttonLink:d,getImage:i=()=>{},componentName:m,LinkComponent:g}=o,b=$.useDetectMobile(),j=u.useMemo(()=>t.jsx(t.Fragment,{children:b===!0?r==null?void 0:r.map((e,n)=>t.jsx(k,{title:e==null?void 0:e.title,text:e==null?void 0:e.description,titleSlug:e==null?void 0:e.titleSlug,numberOfLikes:e==null?void 0:e.numberOfLikes,numberOfComments:e==null?void 0:e.numberOfComments,publishedAt:e==null?void 0:e.publishedAt,timeToRead:e==null?void 0:e.timeToRead,timeToReadText:l,tags:e==null?void 0:e.tags,onCardClick:(T,v)=>s(e==null?void 0:e.titleSlug,v),imageUrl:i(e==null?void 0:e.imageUrl,e==null?void 0:e.uuid)||null,metadata:{name:m,accessor:e==null?void 0:e.accessor},LinkComponent:g},n)):r==null?void 0:r.slice(0,c).map((e,n)=>t.jsx(k,{title:e==null?void 0:e.title,imageUrl:i(e==null?void 0:e.imageUrl,e==null?void 0:e.uuid)||null,text:e==null?void 0:e.description,titleSlug:e==null?void 0:e.titleSlug,tags:e==null?void 0:e.tags,numberOfLikes:e==null?void 0:e.numberOfLikes,numberOfComments:e==null?void 0:e.numberOfComments,publishedAt:e==null?void 0:e.publishedAt,timeToRead:e==null?void 0:e.timeToRead,timeToReadText:l,onCardClick:(T,v)=>s(e==null?void 0:e.titleSlug,v),metadata:{name:m,accessor:e==null?void 0:e.accessor},LinkComponent:g},n))}),[r,b,c,s]);return t.jsxs(R.RegulatTitleSectionWrapper,{ref:C,className:"lp-section lp-blogs-section-detailed",children:[t.jsxs("div",{className:"regular-title",children:[t.jsxs("div",{className:"regular-title-text",children:[a.isDefinedNotEmptyString(p)&&t.jsx("i",{className:p}),t.jsx("span",{children:y})]}),a.isDefinedNotEmptyString(f)&&a.isDefinedNotEmptyString(d)&&!h&&t.jsx(q,{type:"button",btnType:"tinted",color:"neutral",onClick:e=>{var n;(n=e==null?void 0:e.target)==null||n.blur(),N(d)},borderRadius:"curved",className:"button-link",children:f})]}),t.jsx(O.SuspenseBlogsSectionDetailed,{isLoading:h,keyPrefix:"blogs-detailed-skeleton",children:t.jsx(D,{limit:c,children:j})})]})});module.exports=M;