Research
Security News
Kill Switch Hidden in npm Packages Typosquatting Chalk and Chokidar
Socket researchers found several malicious npm packages typosquatting Chalk and Chokidar, targeting Node.js developers with kill switches and data theft.
@glitch-txs/react-swiper
Advanced tools
1. import Swiper component 2. import useSwiper hook 3. setup CSS files for the swiper component
Install npm package
npm i @glitch-txs/react-swiper
import Swiper component and useSwiper hook:
import { Swiper, useSwiper } from '@glitch-txs/react-swiper'
Set up the swiper, you will need to pass CSS classes to the swiper to be able to have full control on styling (wrapperClass and containerClass).
Here I'm using CSS modules:
export default function YourComponent() {
const { provider, handleNext, handlePrev } = useSwiper()
return (
<div className={styles.container}>
<Swiper provider={provider} wrapperClass={styles.wrapperClass} containerClass={styles.containerClass}>
Your slides here...
</Swiper>
<div className={styles.controlsContainer} >
<button onClick={handlePrev}>
Left
</button>
<button onClick={handleNext}>
Right
</button>
</div>
</div>
If you want to have clickable components inside the swiper use the prop clickable
.
If you are using images remember to add the prop draggable={false}
<Swiper provider={provider} clickable wrapperClass={styles.wrapperClass} containerClass={styles.containerClass}>
<Image src='mySrc' draggable={false} alt='myImg' />
</Swiper>
const { provider, handleNext, handlePrev, handleGoTo, autoStart, autoStop, inView } = useSwiper()
useEffect(()=>{
//the auto-slide will only be active when the component is in view.
if(inView){
//the argument taken by autoStart is the time in miliseconds for each slide.
autoStart()
} else {
autoStop()
}
//autoStart uses eventListeners so we need to pass the same params used when returning.
return ()=> autoStop()
},[inView])
The Swiper component is built with two HTML Div's. One is the window (it will have overflow: hidden, so you will only see through it) that will wrap everything. And the child div that will be the container for all your slides, this one will be hidden by the most part.
.wrapperClass{
/* the width and height must be equal to each slide individuly including their margins */
width: 100%;
max-width: 1000px;
height: 250px;
/* Needed overflow hidden - comment this line to see how the swiper works internaly */
overflow: hidden;
}
.containerClass{
/* Display flex will align the slides elements in one row */
display: flex;
/* Width is calculated multiplying the full width of the parent container by the number of slider elements inside the swiper,
this way THIS container will take the width of the sum of all children elements. Width: calc(100% * numberOfCards) */
/* Here there's number four because I'm using 4 cards */
width: calc(100% * 4);
height: 100%;
z-index: 10;
}
if you want to add a fixed component INSIDE the swiper you can pass a JSX variable to the component as progress
useSwiper hook takes an object as arguments with the following vaiables:
rerender: default = true
, (This will render the whole component each time the currentIndex changes, you can turn this off if you're not using curentIndex variable)
widthOffset: default = 0
, ( margin of the sliders if any. E.g: margin: 0 5px 0 5px
==> widthOffset = 10
)
transitionTime: default = 300
(The time in miliseconds it takes to slide)
animationTime: default = 4000
(The time in miliseconds it will automatically move to the next slide)
async: default = false
(if contenct is async set this to true and add a conditional for the Swipper component to render, you won't need to add width to the containerClass in this case.)
example:
export default function YourComponent() {
const { provider } = useSwiper({ async: true })
const [isData, setIsData] = useState<boolean>(false)
useEffect(()=>{
setIsData(true)
},[isData])
return (
{
isData && <Swiper provider={provider} wrapperClass={s.container} containerClass={s.slideContainer}>
{ data?.map((item, index)=>(
<div key={index} className={s.slide}>
Content Here
</div>
))}
</Swiper>
}
)
}
All functions must be disabled until the content is loaded.
GitHub examples are currently outdated.
FAQs
1. import Swiper component 2. import useSwiper hook 3. setup CSS files for the swiper component
The npm package @glitch-txs/react-swiper receives a total of 1 weekly downloads. As such, @glitch-txs/react-swiper popularity was classified as not popular.
We found that @glitch-txs/react-swiper demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
Socket researchers found several malicious npm packages typosquatting Chalk and Chokidar, targeting Node.js developers with kill switches and data theft.
Security News
pnpm 10 blocks lifecycle scripts by default to improve security, addressing supply chain attack risks but sparking debate over compatibility and workflow changes.
Product
Socket now supports uv.lock files to ensure consistent, secure dependency resolution for Python projects and enhance supply chain security.