-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
jiangbo11
committed
Oct 20, 2021
1 parent
a9f6864
commit caaba92
Showing
9 changed files
with
203 additions
and
100 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,13 @@ | ||
# Change Log | ||
|
||
## 1.0.5 | ||
|
||
support custom dots | ||
|
||
## 1.0.4 | ||
|
||
add a live demo | ||
|
||
## 1.0.3 | ||
|
||
fix export default from syntax | ||
|
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,33 @@ | ||
import React from 'react' | ||
import {ArrowProps} from './types' | ||
|
||
const baseArrowStyle: React.CSSProperties = { | ||
position: "absolute", | ||
width: "50px", | ||
height: "50px", | ||
backgroundColor: "rgba(0,0,0,0.5)", | ||
top: "50%", | ||
transform: "translateY(-50%)", | ||
borderRadius: "50%", | ||
color: "#fff", | ||
fontSize: "20px", | ||
display: "flex", | ||
alignItems: "center", | ||
justifyContent: "center", | ||
cursor: "pointer", | ||
} | ||
|
||
const Arrow = ({ left = false, children, onClick }: ArrowProps) => ( | ||
<div | ||
onClick={onClick} | ||
style={{ | ||
...baseArrowStyle, | ||
left: left ? "20px" : "initial", | ||
right: !left ? "10px" : "initial", | ||
}} | ||
> | ||
{children} | ||
</div> | ||
) | ||
|
||
export default Arrow |
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,38 @@ | ||
import React from "react" | ||
import { DotProps } from "./types" | ||
|
||
const dotWrapStyle: React.CSSProperties = { | ||
position: "absolute", | ||
bottom: "10px", | ||
left: "50%", | ||
transform: "translateX(-50%)", | ||
} | ||
|
||
const dotItemStyle: React.CSSProperties = { | ||
width: "20px", | ||
height: "20px", | ||
borderRadius: "50%", | ||
margin: "0 10px", | ||
display: "inline-block", | ||
cursor: "pointer", | ||
} | ||
|
||
const Dots = ({ length, activeIndex, setActiveIndex }: DotProps) => { | ||
return ( | ||
<div style={dotWrapStyle}> | ||
{new Array(length).fill("").map((_, i) => ( | ||
<span | ||
onClick={() => setActiveIndex(i)} | ||
key={i} | ||
style={{ | ||
...dotItemStyle, | ||
background: i === activeIndex ? "#000" : "#999", | ||
transform: `scale(${i === activeIndex ? 1.3 : 1})`, | ||
}} | ||
></span> | ||
))} | ||
</div> | ||
) | ||
} | ||
|
||
export default Dots |
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,29 @@ | ||
|
||
import React from 'react' | ||
import { motion, MotionStyle } from 'framer-motion' | ||
import { SliderProps } from './types' | ||
|
||
const pageStyle: MotionStyle = { | ||
width: "100%", | ||
height: "100%", | ||
display: "inline-block", | ||
flex: "none", | ||
} | ||
|
||
const Slider = ({ x, i, onDragEnd, children }: SliderProps) => ( | ||
<motion.div | ||
style={{ | ||
...pageStyle, | ||
x, | ||
left: `${i * 100}%`, | ||
right: `${i * 100}%`, | ||
}} | ||
drag="x" | ||
dragElastic={0.3} | ||
onDragEnd={onDragEnd} | ||
> | ||
{children} | ||
</motion.div> | ||
) | ||
|
||
export default Slider |
Oops, something went wrong.