react-flop

react-flop组件
提供一个小功能翻转卡片功能可作为开奖翻转使用

react-flop

A simple flop component for React

Installation

1
2
$ npm install react-flop --save
$ yarn add react-flop

Usage

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
class App extends React.Component {
constructor(props) {
super(props);
const that = this;

that.state = {
haveGift: false,
isFlop: false
};
}

render() {
const that = this;
const { haveGift, isFlop } = that.state;
const slot = () => {
if (!isFlop) {
return null;
}

if (haveGift) {
return <div>获奖了</div>;
} else {
return <div>GG</div>;
}
};

const onClick = () => {
that.setState({
isFlop: true,
haveGift: true
});
};

return (
<Flop
imgFLop={require("./images/WechatIMG3.png")}
imgFLoped={require("./images/WechatIMG2.png")}
slot={slot()}
onClick={onClick}
haveGift={haveGift}
isFlop={isFlop}
imgFLopWidth={686}
imgFLopHeight={272}
/>
);
}
}

export default App;

Properties

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
static propTypes = {
imgFLop: PropTypes.string.isRequired, //Preflip picture
imgFLoped: PropTypes.string.isRequired, //Flipped picture
cardName: PropTypes.string, //Custom Components classname
slot: PropTypes.node, //Reserved Node Slot
onClick: PropTypes.func.isRequired, //onclick
haveGift: PropTypes.bool, //awarded or not
isFlop: PropTypes.bool, //Flop or not
imgFLopWidth: PropTypes.number.isRequired, //Picture width
imgFLopHeight: PropTypes.number.isRequired,//Picture height


};

static defaultProps = {
cardName: '',
slot: null,
isFlop: false,
haveGift: false,
};

License

MIT

PenZ wechat
交个朋友吧
点滴分享,您的支持将极大的鼓励我!