@lanaco/lnc-react-ui
Version:
React component library
252 lines (213 loc) • 7.17 kB
JavaScript
"use strict";const e=require("react/jsx-runtime"),g=require("react"),u=require("./Chip.cjs"),m=require("./emotion-styled.browser.esm-DwHBgTPn.cjs"),h=require("./breakpoints-CcVm-gVm.cjs"),w=require("./useDetectMobile-DYV6V1yw.cjs"),p=require("./Button.cjs"),v=m.styled.div`
display: flex;
border: 1px solid var(--gray-200, #e4e9f0);
border-radius: 999px;
& .options__item {
display: flex;
padding: 0.5rem 2rem;
align-items: center;
gap: 6px;
color: var(--neutral-600, #0f2a46);
background: var(--gray-100, #f3f6fb);
border: 1px solid var(--gray-200, #e4e9f0);
font-size: 1rem;
font-style: normal;
font-weight: 500;
line-height: 1.5rem;
&:first-of-type {
padding-right: 3rem;
}
&:last-of-type {
padding-left: 3rem;
}
&.active {
color: var(--white, #fff);
background: var(--neutral-600, #0f2a46);
font-weight: 500;
&:hover {
color: var(--white, #fff);
background: var(--neutral-600, #0f2a46);
}
&:first-of-type {
margin-right: -1.5rem;
padding-right: 2rem;
z-index: 1;
}
&:last-of-type {
margin-left: -1.5rem;
padding-left: 2rem;
z-index: 1;
}
}
&:hover {
background: var(--gray-200, #e4e9f0);
}
&:focus {
outline: none;
}
}
@media ${h.down("S")} {
width: 100%;
& .options__item {
width: 100%;
}
}
`,y=m.styled.div`
display: flex;
gap: 1.25rem;
flex-wrap: wrap;
justify-content: center;
align-items: center;
align-items: stretch;
width: 100%;
& .section__show-more {
color: var(--neutral-600, #0f2a46);
font-size: 0.875rem;
font-style: normal;
font-weight: 500;
line-height: 1.25rem;
letter-spacing: -0.0056rem;
&:focus {
outline: none;
}
}
@media ${h.down("S")} {
flex-direction: column;
& .learn-more {
display: none;
}
}
`,b=m.styled.a`
text-decoration: none;
color: var(--gray-950);
display: flex;
padding: 2rem 1.25rem 1.25rem 1.25rem;
flex-direction: column;
align-items: center;
gap: 1.5rem;
border-radius: 0.75rem;
border: 1px solid var(--gray-200, #e4e9f0);
background: var(--white, #fff);
box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
width: 100%;
max-width: 17.5rem;
&:hover {
cursor: pointer;
}
& .card__content {
display: flex;
flex-direction: column;
align-items: center;
gap: 1.25rem;
& .card__image {
max-width: 3.5rem;
max-height: 3.5rem;
width: 100%;
height: 100%;
aspect-ratio: 1 / 1;
}
& .card__text {
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
gap: 1rem;
& .card__title {
color: var(--gray-900, #0c1520);
text-align: center;
font-size: 1.125rem;
font-style: normal;
font-weight: 500;
line-height: 1.5rem;
}
& .card__divider {
height: 1px;
width: 100%;
background: var(--gray-200, #e4e9f0);
}
& .card__description {
color: var(--gray-600, #5a6573);
text-align: center;
font-size: 0.875rem;
font-style: normal;
font-weight: 400;
line-height: 1.25rem;
letter-spacing: 0.0156rem;
}
}
}
@media ${h.down("S")} {
max-width: 100%;
flex-direction: row;
padding: 1rem;
& .card__content {
flex-direction: row;
align-items: flex-start;
& .card__image {
max-width: 2.5rem;
max-height: 2.5rem;
}
& .card__text {
align-items: flex-start;
gap: 0.625rem;
& .card__divider {
display: none;
}
& .card__title {
text-align: left;
font-size: 1rem;
}
& .card__description {
text-align: left;
}
}
}
}
`,j=g.forwardRef(({options:r=[],selectedOptionCode:o=null,onSelectOption:a=()=>{}},l)=>e.jsx(v,{ref:l,children:r==null?void 0:r.map((s,n)=>e.jsx(u,{label:s,borderRadius:"curved",color:"neutral",className:`options__item ${o===n?"active":""}`,onClick:()=>{a(n)}},`toggle-section-tag__${n+1}`))})),S=({title:r,description:o,image:a,learnMoreText:l,onSelectItem:s=()=>{},LinkComponent:n,link:c})=>{const d=n||"a";return e.jsxs(b,{onClick:s,as:d,...n?{to:`/${c}`}:{href:`/${c}`},children:[e.jsxs("div",{className:"card__content",children:[e.jsx("img",{src:a,alt:`Card ${r}`,className:"card__image"}),e.jsxs("div",{className:"card__text",children:[e.jsx("div",{className:"card__title",children:r}),e.jsx("div",{className:"card__divider"}),e.jsx("div",{className:"card__description",children:o})]})]}),e.jsx(p,{text:l,btnType:"basic",color:"neutral",className:"section__show-more learn-more"})]})},N=g.forwardRef(({items:r=[],showMoreText:o,learnMoreText:a,onSelectItem:l=()=>{},LinkComponent:s},n)=>{const c=w.useDetectMobile(),[d,_]=g.useState(!1),f=()=>{_(t=>!t)},i=g.useMemo(()=>r==null?void 0:r.map((t,x)=>e.jsx(S,{title:t==null?void 0:t.title,description:t==null?void 0:t.description,image:t==null?void 0:t.image,learnMoreText:a,onSelectItem:()=>l(t),LinkComponent:s,link:t==null?void 0:t.link},`toggle-section-item__${x+1}`)),[r]);return e.jsx(y,{ref:n,children:c?d?i:e.jsxs(e.Fragment,{children:[i==null?void 0:i.slice(0,4),(i==null?void 0:i.length)>4&&e.jsx(p,{text:o,btnType:"basic",color:"neutral",className:"section__show-more",onClick:f})]}):i})}),$=m.styled.div`
display: flex;
flex-direction: column;
align-items: center;
gap: 2rem;
& .section__heading {
display: flex;
flex-direction: column;
gap: 0.5rem;
text-align: center;
width: 100%;
}
& .section__title {
color: var(--navy-900, #0c1520);
text-align: center;
font-size: 1.5rem;
font-style: normal;
font-weight: 600;
line-height: 2rem;
}
& .section__description {
color: var(--navy-500, #7a8594);
text-align: center;
font-size: 1rem;
font-style: normal;
font-weight: 500;
line-height: 1.5rem;
}
@media ${h.down("S")} {
gap: 1.5rem;
& .section__heading {
gap: 0.5rem;
}
& .section__title {
font-size: 1.375rem;
font-weight: 600;
line-height: 1.75rem;
text-align: left;
}
& .section__description {
font-size: 0.875rem;
font-weight: 400;
line-height: 1.25rem;
letter-spacing: 0.25px;
text-align: left;
}
}
`,C=g.forwardRef(({title:r,description:o,showMoreText:a="Show more",learnMoreText:l="Learn more",options:s=[],items:n=[],onSelectItem:c=()=>{},LinkComponent:d},_)=>{const[f,i]=g.useState(0),t=x=>{i(x)};return e.jsxs($,{ref:_,children:[e.jsxs("div",{className:"section__heading",children:[r&&e.jsx("div",{className:"section__title",children:r}),o&&e.jsx("div",{className:"section__description",children:o})]}),e.jsx(j,{options:s,selectedOptionCode:f,onSelectOption:t,LinkComponent:d}),e.jsx(N,{items:n==null?void 0:n[f],showMoreText:a,learnMoreText:l,onSelectItem:c,LinkComponent:d},`toggle-section-items__${f}`)]})});module.exports=C;