UNPKG

@lanaco/lnc-react-ui

Version:

React component library

86 lines (80 loc) 2.85 kB
"use strict";const i=require("react/jsx-runtime"),p=require("react"),v=require("./emotion-styled.browser.esm-DwHBgTPn.cjs"),r=require("./utils-BK6B_Y9X.cjs"),j=require("./index-DOkcmaFO.cjs"),k=v.styled.a` text-decoration: none; color: var(--gray-950); display: flex; flex-direction: column; justify-content: end; position: relative; border-radius: 0.75rem; overflow: hidden; cursor: pointer; background: linear-gradient( 178.16deg, rgba(0, 0, 0, 0) 1.5%, rgba(0, 0, 0, 0) 37.37%, #000000 98.39% ); & .text-block { padding: 0.75rem; z-index: 1; display: flex; flex-direction: column; gap: 0.5rem; position: absolute; bottom: 0rem; left: 0rem; } & .img-wrapper { position: absolute; top: 0; left: 0; z-index: 0; background: linear-gradient( 178deg, rgba(0, 0, 0, 0) 1.5%, rgba(0, 0, 0, 0.16) 8.95%, #000 98.39% ); } & img { width: 100%; aspect-ratio: 1 / 1; /* defining the aspect ratio of the image */ object-fit: cover; /* making sure the image isn't distorted */ border-radius: 0.75rem; mix-blend-mode: multiply; border: 1px solid var(--gray-95008, #14161a14); } & .fallback-image { mix-blend-mode: multiply; } font-size: 0.875rem; font-weight: 500; & .price-chip { font-size: 0.75rem; font-weight: 500; padding: 0 0.38rem; min-height: 1.25rem; max-height: 1.25rem; min-width: fit-content; width: fit-content; display: flex; align-items: center; justify-content: center; border-radius: 62.4375rem; z-index: 1; background-color: var(--white, #fff); color: var(--gray-950, #14161a); white-space: nowrap; } & .title-simple-product-card { z-index: 1; color: var(--white, #fff); transition: all 0.2s ease; ${r.truncateTextInRows(2)} } &:hover { & .title-simple-product-card { z-index: 1; } } `,C=p.forwardRef((u,$)=>{const{uuid:o,title:f,price:n=0,currency:a,isNegotiable:c,isFree:s,image:g,sellerUuid:N,nameSlug:t,onSelectCard:x=()=>{},imageComponent:d,negotiableText:b="Negotiable",freeText:h="Free",metadata:e,LinkComponent:l}=u,y=l||"a",m=p.useRef();return i.jsxs(k,{ref:m,className:"simple-product-card","data-accessor":e==null?void 0:e.accessor,name:e==null?void 0:e.name,onClick:w=>x(w,m),as:y,...l?{to:`/product/${r.isDefinedNotEmptyString(t)?`${t}-`:""}${o}`}:{href:`/product/${r.isDefinedNotEmptyString(t)?`${t}-`:""}${o}`},children:[r.isDefined(d)?d:i.jsx(j.ProductImageWrapper,{src:g}),i.jsxs("div",{className:"text-block",children:[i.jsx("div",{className:"title-simple-product-card",children:f}),i.jsxs("div",{className:"price-chip",children:[n>0&&a&&c!==!0&&s!==!0&&`${r.formatPrice(n)} ${r.GetCurrencySymbol(a)}`,c&&b,s&&h]})]})]})});exports.SimpleProductCard=C;