A Pen by Aaron Goldsmith on CodePen.
Created
June 13, 2019 20:02
-
-
Save AaronGoldsmith/bb9af306b8a8523d24b507f0cd935525 to your computer and use it in GitHub Desktop.
SVG props
This file contains hidden or 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
<div id="root"></div> |
This file contains hidden or 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
const ChevronRight = (props) => ( | |
<div {...props}> | |
<svg width={24} height={24} viewBox="0 0 24 24" > | |
<path | |
fill="#000000" | |
d="M8.59,16.58L13.17,12L8.59,7.41L10,6L16,12L10,18L8.59,16.58Z" /> | |
</svg> | |
</div> | |
); | |
class Chicken extends React.Component{ | |
constructor(props){ | |
super(props); | |
this.state = {clicked: false} | |
} | |
handleClick=()=>{ | |
this.setState({ clicked: !this.state.clicked }) | |
} | |
render(){ | |
const clicked = this.state.clicked ? 'clicked' : '' | |
return ( | |
<ChevronRight | |
onClick={this.handleClick} | |
className={`chevron ${clicked}`} /> | |
) | |
} | |
} | |
ReactDOM.render(<Chicken options={[]} />, document.getElementById('root')); |
This file contains hidden or 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
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/16.7.0/umd/react.production.min.js"></script> | |
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script> | |
<script src="https://cdnjs.cloudflare.com/ajax/libs/react-dom/16.6.3/umd/react-dom.production.min.js"></script> |
This file contains hidden or 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
.chevron{ | |
margin: 100px; | |
width: 30px; | |
transform: scale(2); | |
} | |
.chevron.clicked { | |
transform: rotate(180deg) scale(2); | |
transition: all 200ms ease-in; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment