Lazy load images by tab

This commit is contained in:
oitsjustjose 2021-06-08 15:35:20 -05:00
commit df3d3729ea
2 changed files with 8 additions and 1 deletions

BIN
public/img/vtweaks/tmp.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.6 KiB

View file

@ -33,6 +33,8 @@ export default () => {
versionFilter: null, versionFilter: null,
}); });
const [activeTab, setActiveTab] = useState('Block Tweaks');
useEffect(() => { useEffect(() => {
[].slice.call(document.querySelectorAll('[data-bs-toggle="tooltip"]')) [].slice.call(document.querySelectorAll('[data-bs-toggle="tooltip"]'))
.forEach((tooltipEl) => { .forEach((tooltipEl) => {
@ -171,6 +173,7 @@ export default () => {
aria-controls={`${comp.name.toLowerCase().replace(/ /g, '-')}`} aria-controls={`${comp.name.toLowerCase().replace(/ /g, '-')}`}
aria-selected={idx === 0 ? 'true' : 'false'} aria-selected={idx === 0 ? 'true' : 'false'}
key={comp.name} key={comp.name}
onClick={() => setActiveTab(comp.name)}
> >
{comp.name} {comp.name}
</button> </button>
@ -204,7 +207,11 @@ export default () => {
data-bs-placement={feature.experimental && 'top'} data-bs-placement={feature.experimental && 'top'}
title={feature.experimental && 'This Feature is Experimental!'} title={feature.experimental && 'This Feature is Experimental!'}
> >
<img src={feature.img} alt="" className="card-img-top" /> <img
src={comp.name === activeTab ? feature.img : '/img/vtweaks/tmp.png'}
alt=""
className="card-img-top"
/>
<div className="card-body"> <div className="card-body">
<h5 className="text-center card-title"> <h5 className="text-center card-title">
{feature.name} {feature.name}