11import {
2- HiArrowLeft ,
3- HiArrowRight ,
42 HiArrowTopRightOnSquare ,
53 HiOutlineQuestionMarkCircle ,
64 HiPencil ,
75 HiUserCircle ,
86} from "react-icons/hi2" ;
97import { FiSettings } from "react-icons/fi" ;
8+ import { Navigation , Pagination , A11y } from "swiper" ;
9+ import { Swiper , SwiperSlide } from "swiper/react" ;
10+ import "swiper/swiper-bundle.min.css" ;
1011import OpenSaucedLogo from "../../assets/opensauced-logo.svg" ;
1112import { useAuth } from "../../hooks/useAuth" ;
1213import { useOpensaucedUserCheck } from "../../hooks/useOpensaucedUserCheck" ;
@@ -22,13 +23,13 @@ import Settings from "./settings";
2223import { OPEN_SAUCED_INSIGHTS_DOMAIN } from "../../constants" ;
2324import type { Highlight } from "../../ts/types" ;
2425import { useIsGithubPRPageCheck } from "../../hooks/useGithubPRPageCheck" ;
26+ import { HighlightSlide } from "../components/HighlightSlide" ;
2527
2628const Home = ( ) => {
2729 const { user } = useAuth ( ) ;
2830 const { currentTabIsOpensaucedUser, checkedUser } = useOpensaucedUserCheck ( ) ;
2931 const { isGithubPRPage, prUrl, prTitle } = useIsGithubPRPageCheck ( ) ;
3032 const [ highlights , setHighlights ] = useState < Highlight [ ] > ( [ ] ) ;
31- const [ currentPage , setCurrentPage ] = useState ( 0 ) ;
3233
3334 useEffect ( ( ) => {
3435 const fetchHighlights = async ( ) => {
@@ -49,14 +50,6 @@ const Home = () => {
4950 void fetchHighlights ( ) ;
5051 } , [ ] ) ;
5152
52- const handlePrevious = ( ) => {
53- setCurrentPage ( prevPage => prevPage - 1 ) ;
54- } ;
55-
56- const handleNext = ( ) => {
57- setCurrentPage ( prevPage => prevPage + 1 ) ;
58- } ;
59-
6053 return (
6154 < div className = "p-4 bg-slate-800" >
6255 < div className = "grid grid-cols-1 divide-y divide-white/40 divider-y-center-2 min-w-[320px] text-white" >
@@ -87,76 +80,40 @@ const Home = () => {
8780 </ header >
8881
8982 < main className = "main-content" >
90- < h3 className = "text font-medium text-base leading-10" > Latest Highlight:</ h3 >
83+ < a
84+ className = "flex items-center text-white hover:text-orange no-underline gap-2 w-full font-medium text-lg leading-10"
85+ href = { `https://${ OPEN_SAUCED_INSIGHTS_DOMAIN } /feed` }
86+ rel = "noreferrer"
87+ target = "_blank"
88+ >
89+ Highlights feed
90+ < HiArrowTopRightOnSquare />
91+ </ a >
9192
9293 { highlights . length > 0 && (
94+ < Swiper
95+ navigation
96+ modules = { [ Navigation , Pagination , A11y ] }
97+ pagination = { { clickable : true } }
98+ slidesPerView = { 1 }
99+ spaceBetween = { 50 }
100+ >
101+ {
102+ highlights . map ( ( highlight , index ) => (
103+ < SwiperSlide key = { index } >
104+ < HighlightSlide
105+ highlight = { highlight }
106+ />
107+ </ SwiperSlide >
108+ ) )
109+ }
110+ </ Swiper >
111+ ) }
93112
94- < div className = "border border-white/40 rounded-sm p-3 mt-2" >
95- < h3 className = "text-base font-medium" >
96- < a
97- className = "text-blue-500 hover:text-blue-700 underline cursor-pointer"
98- href = { highlights [ currentPage ] ?. url }
99- rel = "noopener noreferrer"
100- target = "_blank"
101- >
102- { highlights [ currentPage ] ?. title }
103- </ a >
104- </ h3 >
105-
106-
107- < div className = "flex items-center" >
108- < div className = "mr-2" > Author:</ div >
109-
110- < a
111- className = "text-blue-500 hover:text-blue-700 underline cursor-pointer"
112- href = { `https://insights.opensauced.pizza/user/${ highlights [ currentPage ] ?. login } ` }
113- rel = "noopener noreferrer"
114- target = "_blank"
115-
116-
117- >
118- { highlights [ currentPage ] ?. login }
119- </ a >
120- </ div >
121-
122- < p className = "py-2" >
123- { highlights [ currentPage ] ?. highlight }
124- </ p >
125-
126- < div className = "flex justify-center" >
127- < div className = "flex justify-center mt-4" >
128- < button
129- className = "px-4 py-2 rounded-md bg-blue-500 text-white disabled:opacity-50"
130- disabled = { currentPage === 0 }
131- onClick = { handlePrevious }
132- >
133- < HiArrowLeft />
134- </ button >
135-
136- < button
137- className = "px-4 py-2 rounded-md bg-blue-500 text-white disabled:opacity-50 ml-4"
138- disabled = { currentPage === highlights . length - 1 }
139- onClick = { handleNext }
140- >
141- < HiArrowRight />
142- </ button >
143- </ div >
144- </ div >
145- </ div > ) }
146113
147114 < h3 className = "text font-medium text-base leading-10" > Tools:</ h3 >
148115
149116 < div className = "tools flex flex-col gap-2" >
150- < a
151- className = "flex items-center bg-slate-700 hover:bg-slate-700/70 text-white hover:text-orange no-underline gap-2 p-1.5 px-3 w-full rounded-sm font-medium text-sm"
152- href = { `https://${ OPEN_SAUCED_INSIGHTS_DOMAIN } /feed` }
153- rel = "noreferrer"
154- target = "_blank"
155- >
156- < HiArrowTopRightOnSquare />
157- Highlights feed
158- </ a >
159-
160117 < a
161118 className = "flex items-center bg-slate-700 hover:bg-slate-700/70 hover:text-orange text-white gap-2 p-1.5 px-3 w-full rounded-sm font-medium text-sm"
162119 href = { `https://${ OPEN_SAUCED_INSIGHTS_DOMAIN } /feed` }
0 commit comments