-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #105 from BSims623/scroll
Single Project Page Navigation & Slider Component
- Loading branch information
Showing
13 changed files
with
140 additions
and
101 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import { useState } from 'react'; | ||
import 'keen-slider/keen-slider.min.css'; | ||
import { useKeenSlider } from 'keen-slider/react'; // import from 'keen-slider/react.es' for to get an ES module | ||
|
||
export default function Slider ({containerClass, children}) { | ||
const [currentSlide, setCurrentSlide] = useState(0); | ||
const [loaded, setLoaded] = useState(false); | ||
const [sliderRef, instanceRef] = useKeenSlider({ | ||
initial: 0, | ||
slideChanged(slider) { | ||
setCurrentSlide(slider.track.details.rel) | ||
}, | ||
created() { | ||
setLoaded(true) | ||
}, | ||
}); | ||
|
||
return ( | ||
<div className={containerClass}> | ||
<div ref={sliderRef} className="keen-slider"> | ||
{children} | ||
</div> | ||
{loaded && instanceRef.current && ( | ||
<div className="dots"> | ||
{[ | ||
...Array(instanceRef.current.track.details.slides.length).keys(), | ||
].map((idx) => { | ||
return ( | ||
<button | ||
key={idx} | ||
onClick={() => { | ||
instanceRef.current?.moveToIdx(idx) | ||
}} | ||
className={"dot" + (currentSlide === idx ? " active" : "")} | ||
></button> | ||
) | ||
})} | ||
</div> | ||
)} | ||
</div> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export { default as Slider } from './Slider'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
.navigation-wrapper { | ||
position: relative; | ||
} | ||
|
||
.project-screenshots-slider-container { | ||
.project-screenshot, .project-blank-screenshot { | ||
border: 1px solid $neutral-700; | ||
border-radius: 8px; | ||
} | ||
|
||
.dot { | ||
background: $primary-600; | ||
} | ||
|
||
.dot.active { | ||
background: $primary-400; | ||
} | ||
|
||
@media (min-width: $screen-md) { | ||
display: none; | ||
} | ||
} | ||
|
||
.dots { | ||
display: flex; | ||
padding: 10px 0; | ||
justify-content: center; | ||
} | ||
|
||
.dot { | ||
border: none; | ||
width: 10px; | ||
height: 10px; | ||
background: $secondary-50; | ||
border-radius: 50%; | ||
margin: 0 5px; | ||
padding: 5px; | ||
cursor: pointer; | ||
} | ||
|
||
.dot:focus { | ||
outline: none; | ||
} | ||
|
||
.dot.active { | ||
background: $secondary-500; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.