You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
educoder/public/react/src/common/course/WordsBtn.js

31 lines
1.1 KiB

import React, { Component } from 'react';
import {Link} from 'react-router-dom'
const map={"blue":"colorblue","white":"colorwhite","grey":"colorgrey", 'orange': "color-orange"}
class WordsBtn extends Component {
constructor(props) {
super(props);
}
render() {
let{to, href,targets, style2, style, ...others }=this.props
return(
<React.Fragment>
{
to==undefined&&targets==undefined ?
<a href={href || "javascript:void(0)"} onClick={this.props.onClick} className={"btn "+`${map[this.props.style]} ${this.props.className}`}
style={style2} {...others}
>{this.props.children}</a>:
targets!=undefined? <a href={to} target="_blank" className={"btn "+`${map[this.props.style]} ${this.props.className}`}
style={style2} {...others}
>{this.props.children}</a>
:
<Link to={to} className={"btn "+`${map[this.props.style]} ${this.props.className}`}
style={style2} {...others}
>{this.props.children}</Link>
}
</React.Fragment>
)
}
}
export default WordsBtn;