@comicrelief/component-library 8.86.4 → 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
@@ -651,8 +651,8 @@ function print() { __p += __j.call(arguments, '') }
651
651
  display: block;
652
652
  }
653
653
  }
654
- `}
655
654
  };
655
+ `}
656
656
 
657
657
  // New style is rounded square buttons with dark grey background, and animation.
658
658
  // When we've moved fully to the new design,
@@ -668,17 +668,14 @@ function print() { __p += __j.call(arguments, '') }
668
668
  width: 100%;
669
669
  height: 100%;
670
670
 
671
+ ${Q1(!0,1.15,2)}
672
+
671
673
  &:hover,
672
674
  &:focus {
673
675
  background-color: ${t.color("grey_4_hover")};
674
676
  opacity: 1;
675
677
  }
676
678
  `}
677
-
678
- // springScaleAnimation must stay a sibling — nesting it inside the $newStyle css block
679
- // breaks flattening so rules, it bugs out and compiles as global :hover, :focus
680
- // when you try to combine them
681
- ${({$newStyle:e})=>e&&Q1(!0,1.15,2)}
682
679
  `,aL=g(fe)`
683
680
  width: auto;
684
681
  color: ${({theme:e})=>e.color("black")};
@@ -7492,6 +7489,7 @@ gap: ${T("md")};
7492
7489
  width: 1.25rem;
7493
7490
  margin: 0;
7494
7491
  animation: ${Bh} 0.2s ease-in;
7492
+ height: auto;
7495
7493
  }
7496
7494
 
7497
7495
  > ${ka} {
@@ -7667,7 +7665,7 @@ gap: ${T("md")};
7667
7665
  display: flex;
7668
7666
  margin-top: 2rem;
7669
7667
  justify-content: center;
7670
- `,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="0rem",paddingBelow:p="1rem",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
+ `,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`
7671
7669
  width: 100%;
7672
7670
  `,uQ=g.div`
7673
7671
  position: relative;
package/dist/index.es.js CHANGED
@@ -7066,8 +7066,8 @@ const xE = /* @__PURE__ */ Go(wr), CE = 55, $E = 0.35, _E = b.a`
7066
7066
  display: block;
7067
7067
  }
7068
7068
  }
7069
- `}
7070
7069
  };
7070
+ `}
7071
7071
 
7072
7072
  // New style is rounded square buttons with dark grey background, and animation.
7073
7073
  // When we've moved fully to the new design,
@@ -7083,17 +7083,14 @@ const xE = /* @__PURE__ */ Go(wr), CE = 55, $E = 0.35, _E = b.a`
7083
7083
  width: 100%;
7084
7084
  height: 100%;
7085
7085
 
7086
+ ${g4(!0, 1.15, 2)}
7087
+
7086
7088
  &:hover,
7087
7089
  &:focus {
7088
7090
  background-color: ${t.color("grey_4_hover")};
7089
7091
  opacity: 1;
7090
7092
  }
7091
7093
  `}
7092
-
7093
- // springScaleAnimation must stay a sibling — nesting it inside the $newStyle css block
7094
- // breaks flattening so rules, it bugs out and compiles as global :hover, :focus
7095
- // when you try to combine them
7096
- ${({ $newStyle: e }) => e && g4(!0, 1.15, 2)}
7097
7094
  `, kE = b(he)`
7098
7095
  width: auto;
7099
7096
  color: ${({ theme: e }) => e.color("black")};
@@ -33382,6 +33379,7 @@ const ZJ = (e) => {
33382
33379
  width: 1.25rem;
33383
33380
  margin: 0;
33384
33381
  animation: ${Wh} 0.2s ease-in;
33382
+ height: auto;
33385
33383
  }
33386
33384
 
33387
33385
  > ${Ra} {
@@ -33671,8 +33669,8 @@ const vQ = ({ data: e }) => {
33671
33669
  title: o,
33672
33670
  firstFilterCardNodeAsHero: s = !1,
33673
33671
  loadingBehaviour: c = null,
33674
- paddingAbove: u = "0rem",
33675
- paddingBelow: h = "1rem",
33672
+ paddingAbove: u = "2rem",
33673
+ paddingBelow: h = "2rem",
33676
33674
  pageBackgroundColour: p = "transparent"
33677
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);
33678
33676
  Ue(() => {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@comicrelief/component-library",
3
3
  "author": "Comic Relief Engineering Team",
4
- "version": "8.86.4",
4
+ "version": "8.86.6",
5
5
  "main": "dist/index.cjs.js",
6
6
  "module": "dist/index.es.js",
7
7
  "files": [
@@ -63,8 +63,8 @@ const StyledLink = styled.a`
63
63
  display: block;
64
64
  }
65
65
  }
66
- `}
67
66
  };
67
+ `}
68
68
 
69
69
  // New style is rounded square buttons with dark grey background, and animation.
70
70
  // When we've moved fully to the new design,
@@ -80,17 +80,14 @@ const StyledLink = styled.a`
80
80
  width: 100%;
81
81
  height: 100%;
82
82
 
83
+ ${springScaleAnimation(true, 1.15, 2)}
84
+
83
85
  &:hover,
84
86
  &:focus {
85
87
  background-color: ${theme.color('grey_4_hover')};
86
88
  opacity: 1;
87
89
  }
88
90
  `}
89
-
90
- // springScaleAnimation must stay a sibling — nesting it inside the $newStyle css block
91
- // breaks flattening so rules, it bugs out and compiles as global :hover, :focus
92
- // when you try to combine them
93
- ${({ $newStyle }) => $newStyle && springScaleAnimation(true, 1.15, 2)}
94
91
  `;
95
92
 
96
93
  const RevealText = styled(Text)`
@@ -139,7 +136,7 @@ const Icon = ({
139
136
  $newStyle={newStyle}
140
137
  >
141
138
  <StyledImage src={icon} alt={brand} $invertColor={invertColor} />
142
- { isHeader && (
139
+ {isHeader && (
143
140
  <RevealText>{title}</RevealText>
144
141
  )}
145
142
 
@@ -34,8 +34,8 @@ const FilterCard = ({ data }) => {
34
34
  title,
35
35
  firstFilterCardNodeAsHero = false,
36
36
  loadingBehaviour = null,
37
- paddingAbove = '0rem',
38
- paddingBelow = '1rem',
37
+ paddingAbove = '2rem',
38
+ paddingBelow = '2rem',
39
39
  pageBackgroundColour = 'transparent'
40
40
  } = data;
41
41
 
@@ -199,6 +199,7 @@ const FilterButton = styled(CustomisedButton)`
199
199
  width: 1.25rem;
200
200
  margin: 0;
201
201
  animation: ${fadeIn} 0.2s ease-in;
202
+ height: auto;
202
203
  }
203
204
 
204
205
  > ${Copywrapper} {
@@ -89,13 +89,13 @@ exports[`does not render copyright text when not supplied 1`] = `
89
89
 
90
90
  .c29:hover,
91
91
  .c29:focus {
92
- background-color: #3A3A3A;
93
- opacity: 1;
92
+ transform: scale(1.15);
94
93
  }
95
94
 
96
95
  .c29:hover,
97
96
  .c29:focus {
98
- transform: scale(1.15);
97
+ background-color: #3A3A3A;
98
+ opacity: 1;
99
99
  }
100
100
 
101
101
  .c31 {
@@ -1454,13 +1454,13 @@ exports[`renders correctly 1`] = `
1454
1454
 
1455
1455
  .c29:hover,
1456
1456
  .c29:focus {
1457
- background-color: #3A3A3A;
1458
- opacity: 1;
1457
+ transform: scale(1.15);
1459
1458
  }
1460
1459
 
1461
1460
  .c29:hover,
1462
1461
  .c29:focus {
1463
- transform: scale(1.15);
1462
+ background-color: #3A3A3A;
1463
+ opacity: 1;
1464
1464
  }
1465
1465
 
1466
1466
  .c31 {
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: