@comicrelief/component-library 8.86.5 → 8.86.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs.js
CHANGED
|
@@ -7489,6 +7489,7 @@ gap: ${T("md")};
|
|
|
7489
7489
|
width: 1.25rem;
|
|
7490
7490
|
margin: 0;
|
|
7491
7491
|
animation: ${Bh} 0.2s ease-in;
|
|
7492
|
+
height: auto;
|
|
7492
7493
|
}
|
|
7493
7494
|
|
|
7494
7495
|
> ${ka} {
|
|
@@ -7664,7 +7665,7 @@ gap: ${T("md")};
|
|
|
7664
7665
|
display: flex;
|
|
7665
7666
|
margin-top: 2rem;
|
|
7666
7667
|
justify-content: center;
|
|
7667
|
-
`,Ry=({updateTotalResult:e,processedNodes:t,firstFilterCardNodeAsHero:r,nodeRenderLimit:n,currentFilters:o,hideShowMoreButton:s})=>{let c=0,u=0;const p=o.length>0,h=t.map((v,b)=>{const C=o.some(w=>v.tags.includes(w));(p&&C||!p)&&(u+=1);const x=!p||C,$=n===0||n>0&&c<n;if(x&&$){const{id:w,label:M,heading:O,description:A,image:F,imageLow:D,imageSet:ee,imageAltText:W,url:re,ctaText:le,ctaIcon:ge}=v,X=b===0&&r;return c+=1,f.jsxs(rQ,{$isHero:X,"data-testid":"FilterCard-Node",children:[f.jsx(i2,{children:f.jsx(nQ,{image:F,images:ee,imageLow:D,objectFit:"cover",width:"100%",height:"100%",alt:W,$isHero:X})}),f.jsxs(o2,{tabIndex:"0",children:[f.jsx(iQ,{tag:"p",color:"grey",weight:"500",$isHero:X,children:M}),f.jsx(aQ,{tag:X?"h2":"p",weight:"700",$isHero:X,$hasDescription:A,"data-testid":"FilterCard-Node--Heading",children:O}),A&&f.jsx(oQ,{tag:"p",$isHero:X,children:A}),f.jsx(fe,{tag:"p",children:f.jsx(sQ,{href:re,$underline:!0,target:"blank",icon:HJ(ge),children:le})})]})]},w)}return null}).filter(Boolean);return R.useEffect(()=>{e(u),s(c===u)},[h,e,s,c,u]),f.jsx(tQ,{children:h})};Ry.propTypes={processedNodes:l.arrayOf(l.shape()).isRequired,currentFilters:l.arrayOf(l.string).isRequired,firstFilterCardNodeAsHero:l.bool.isRequired,updateTotalResult:l.func.isRequired,nodeRenderLimit:l.number.isRequired,hideShowMoreButton:l.func.isRequired};const Iy=({data:e})=>{const{body:t,id:r,filterCardNodes:n,title:o,firstFilterCardNodeAsHero:s=!1,loadingBehaviour:c=null,paddingAbove:u="
|
|
7668
|
+
`,Ry=({updateTotalResult:e,processedNodes:t,firstFilterCardNodeAsHero:r,nodeRenderLimit:n,currentFilters:o,hideShowMoreButton:s})=>{let c=0,u=0;const p=o.length>0,h=t.map((v,b)=>{const C=o.some(w=>v.tags.includes(w));(p&&C||!p)&&(u+=1);const x=!p||C,$=n===0||n>0&&c<n;if(x&&$){const{id:w,label:M,heading:O,description:A,image:F,imageLow:D,imageSet:ee,imageAltText:W,url:re,ctaText:le,ctaIcon:ge}=v,X=b===0&&r;return c+=1,f.jsxs(rQ,{$isHero:X,"data-testid":"FilterCard-Node",children:[f.jsx(i2,{children:f.jsx(nQ,{image:F,images:ee,imageLow:D,objectFit:"cover",width:"100%",height:"100%",alt:W,$isHero:X})}),f.jsxs(o2,{tabIndex:"0",children:[f.jsx(iQ,{tag:"p",color:"grey",weight:"500",$isHero:X,children:M}),f.jsx(aQ,{tag:X?"h2":"p",weight:"700",$isHero:X,$hasDescription:A,"data-testid":"FilterCard-Node--Heading",children:O}),A&&f.jsx(oQ,{tag:"p",$isHero:X,children:A}),f.jsx(fe,{tag:"p",children:f.jsx(sQ,{href:re,$underline:!0,target:"blank",icon:HJ(ge),children:le})})]})]},w)}return null}).filter(Boolean);return R.useEffect(()=>{e(u),s(c===u)},[h,e,s,c,u]),f.jsx(tQ,{children:h})};Ry.propTypes={processedNodes:l.arrayOf(l.shape()).isRequired,currentFilters:l.arrayOf(l.string).isRequired,firstFilterCardNodeAsHero:l.bool.isRequired,updateTotalResult:l.func.isRequired,nodeRenderLimit:l.number.isRequired,hideShowMoreButton:l.func.isRequired};const Iy=({data:e})=>{const{body:t,id:r,filterCardNodes:n,title:o,firstFilterCardNodeAsHero:s=!1,loadingBehaviour:c=null,paddingAbove:u="2rem",paddingBelow:p="2rem",pageBackgroundColour:m="transparent"}=e,h=6,[v,b]=R.useState(!1),[C,x]=R.useState(!1),[$,w]=R.useState(!1),M=R.useRef(zJ(c,s)),[O,A]=R.useState(!1),[F,D]=R.useState([]),[ee,W]=R.useState(0),[re,le]=R.useState(M.current);R.useEffect(()=>{let Z;const{outputNodes:B,outputTags:J}=VJ(n);return B&&J&&(Z=setTimeout(()=>{b(B),x(J)},1e3)),()=>clearTimeout(Z)},[n]);const ge=R.useCallback(Z=>{le(M.current),w(!0);let B=F;B.includes(Z)?B=[...B.slice(0,B.indexOf(Z)),...B.slice(B.indexOf(Z)+1)]:B.push(Z),D([...B])},[F]),X=!(!O&&F.length===0),U=`${ee} ${ee===1?"result":"results"}`;return f.jsx(YJ,{$paddingAbove:u,$paddingBelow:p,$pageBackgroundColour:m,"data-testid":"FilterCard",id:r,children:f.jsxs(UJ,{children:[f.jsxs(GJ,{children:[f.jsx(qJ,{tag:"h1",children:o}),f.jsx(ZJ,{children:t}),C&&v?f.jsxs(f.Fragment,{children:[f.jsxs(KJ,{children:[f.jsx(XJ,{color:"white",$isActive:X,role:"checkbox","aria-checked":O,onClick:()=>{A(!O)},icon:O?f.jsx(y7,{}):f.jsx(XN,{}),"data-testid":"FilterCard-ShowHideButton",children:O?"Hide Filters":"Show Filters"}),f.jsx(QJ,{color:"white",icon:f.jsx(QN,{}),$show:X,disabled:F.length===0,onClick:()=>{D([]),le(M.current),w(!0)},"data-testid":"FilterCard-ClearSelectionButton",children:"Clear selection"}),f.jsx(JJ,{"data-testid":"FilterCard-Results",role:"status",children:f.jsx(fe,{tag:"span",children:U})})]}),f.jsx(Ay,{$show:O,"data-testid":"FilterCard-FilterButtonsWrapper",children:Object.keys(C).map(Z=>{const{tag:B,selectedIcon:J,unselectedIcon:de}=C[Z],P=F.includes(B);return f.jsx(eQ,{type:"button",color:"grey_light",value:B,name:B,iconLeft:!0,$isSelected:P,role:"checkbox","aria-checked":P,icon:P?J:de,onClick:()=>{ge(B)},iconKey:`${P}`,"data-testid":"FilterCard-FilterButton",children:B},B)})})]}):f.jsx(m7,{color:"black",style:{textAlign:"center",display:"block"}})]}),C&&v&&f.jsx(Ry,{processedNodes:v,firstFilterCardNodeAsHero:s,nodeRenderLimit:re,currentFilters:F,updateTotalResult:W,hideShowMoreButton:w,"data-testid":"FilterCard-Nodes"}),!$&&C&&v&&f.jsx(lQ,{children:f.jsx(to,{onClick:()=>le(re+h),"data-testid":"FilterCard-ShowMoreButton",children:"Show more"})})]})})};Iy.propTypes={data:l.shape({id:l.string.isRequired,title:l.string.isRequired,body:l.oneOfType([l.node,l.string]).isRequired,paddingAbove:l.string,paddingBelow:l.string,pageBackgroundColour:l.string,loadingBehaviour:l.string,firstFilterCardNodeAsHero:l.bool,filterCardNodes:l.arrayOf(l.shape({id:l.string.isRequired,title:l.string.isRequired,label:l.string.isRequired,heading:l.string.isRequired,ctaText:l.string.isRequired,url:l.string.isRequired,description:l.string,image:l.string.isRequired,imageLow:l.string.isRequired,imageSet:l.string.isRequired,imageAltText:l.string.isRequired,filterTags:l.arrayOf(l.shape({tag:l.string.isRequired,title:l.string.isRequired,filterIconSelected:l.shape({file:l.shape({url:l.string.isRequired})}),filterIconUnselected:l.shape({file:l.shape({url:l.string.isRequired})})}))})).isRequired}).isRequired};const cQ=g.div`
|
|
7668
7669
|
width: 100%;
|
|
7669
7670
|
`,uQ=g.div`
|
|
7670
7671
|
position: relative;
|
package/dist/index.es.js
CHANGED
|
@@ -33379,6 +33379,7 @@ const ZJ = (e) => {
|
|
|
33379
33379
|
width: 1.25rem;
|
|
33380
33380
|
margin: 0;
|
|
33381
33381
|
animation: ${Wh} 0.2s ease-in;
|
|
33382
|
+
height: auto;
|
|
33382
33383
|
}
|
|
33383
33384
|
|
|
33384
33385
|
> ${Ra} {
|
|
@@ -33668,8 +33669,8 @@ const vQ = ({ data: e }) => {
|
|
|
33668
33669
|
title: o,
|
|
33669
33670
|
firstFilterCardNodeAsHero: s = !1,
|
|
33670
33671
|
loadingBehaviour: c = null,
|
|
33671
|
-
paddingAbove: u = "
|
|
33672
|
-
paddingBelow: h = "
|
|
33672
|
+
paddingAbove: u = "2rem",
|
|
33673
|
+
paddingBelow: h = "2rem",
|
|
33673
33674
|
pageBackgroundColour: p = "transparent"
|
|
33674
33675
|
} = e, f = 6, [m, y] = ke(!1), [C, w] = ke(!1), [$, x] = ke(!1), M = Vt(XJ(c, s)), [T, A] = ke(!1), [I, D] = ke([]), [te, U] = ke(0), [ne, ce] = ke(M.current);
|
|
33675
33676
|
Ue(() => {
|
package/package.json
CHANGED
|
@@ -34,8 +34,8 @@ const FilterCard = ({ data }) => {
|
|
|
34
34
|
title,
|
|
35
35
|
firstFilterCardNodeAsHero = false,
|
|
36
36
|
loadingBehaviour = null,
|
|
37
|
-
paddingAbove = '
|
|
38
|
-
paddingBelow = '
|
|
37
|
+
paddingAbove = '2rem',
|
|
38
|
+
paddingBelow = '2rem',
|
|
39
39
|
pageBackgroundColour = 'transparent'
|
|
40
40
|
} = data;
|
|
41
41
|
|
package/src/data/data.js
CHANGED
|
@@ -353,8 +353,6 @@ const ButtonIconSvgPath = 'https://images.ctfassets.net/0p265iutoxgq/3GaahqcCBaX
|
|
|
353
353
|
|
|
354
354
|
// Reused config and 'top' content for the FilterCard examples:
|
|
355
355
|
const filterCardConfig = {
|
|
356
|
-
paddingAbove: '2rem',
|
|
357
|
-
paddingBelow: '2rem',
|
|
358
356
|
pageBackgroundColour: 'grey_light',
|
|
359
357
|
loadingBehaviour: 'Load all cards at once',
|
|
360
358
|
body:
|