Skip to content

Commit

Permalink
fix: notices slider on mobile
Browse files Browse the repository at this point in the history
  • Loading branch information
KeziahMoselle committed Oct 16, 2022
1 parent ddcaf49 commit 37d9d6d
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/components/NewNotices.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,21 @@
import { Swiper, SwiperSlide } from "swiper/react";
import { A11y, Pagination, Navigation } from "swiper";
import Link from "next/link";
import useBreakpoint from "@hooks/useBreakpoint";

export default function NewNotices({ notifications }) {
const breakpoint = useBreakpoint();

console.log(breakpoint);
return (
<div className="swiper--notices overflow-hidden relative pb-16">
<Swiper
modules={[A11y, Pagination, Navigation]}
slidesPerView={5}
slidesPerView={
(breakpoint === "sm" && 2) ||
(breakpoint === "md" && 3) ||
(breakpoint === "lg" && 5)
}
pagination={{ clickable: true }}
navigation
className="cursor-move"
Expand Down
11 changes: 11 additions & 0 deletions src/hooks/useBreakpoint.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { createBreakpoint } from 'react-use'

const useBreakpoint = createBreakpoint({
'sm': 640,
'md': 768,
'lg': 1024,
'xl': 1280,
'2xl': 1536
})

export default useBreakpoint
1 change: 1 addition & 0 deletions src/styles/components/_swiper.scss
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@

.swiper--notices {
.swiper-pagination {
@apply hidden md:block;
bottom: -3rem !important;
}

Expand Down

0 comments on commit 37d9d6d

Please sign in to comment.