Created
April 6, 2021 23:50
-
-
Save ChaseH88/3dfd9b09fca0f2e2189a9e464cd0d027 to your computer and use it in GitHub Desktop.
Quick component I put together that gives you some shapes you can use in the UI.
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
| import React, { FC } from 'react'; | |
| interface ShapeInterface { | |
| type: 'rectangle' | 'circle' | 'triangle', | |
| backgroundColor?: string | |
| style?: { [key: string]: any } | |
| } | |
| const Shape: FC<ShapeInterface> = ({ type, backgroundColor = '#252525', style }): JSX.Element => { | |
| const styles = { | |
| 'rectangle': { | |
| width: '200px', | |
| height: '100px', | |
| backgroundColor | |
| }, | |
| 'circle': { | |
| width: '100px', | |
| height: '100px', | |
| borderRadius: '50%', | |
| backgroundColor, | |
| }, | |
| 'triangle': { | |
| width: '0', | |
| height: '0', | |
| borderLeft: '50px solid transparent', | |
| borderRight: '50px solid transparent', | |
| borderBottom: `100px solid ${backgroundColor}` | |
| } | |
| } | |
| return <div className='shape' style={{ | |
| ...style, | |
| ...styles[type] | |
| }} /> | |
| } | |
| export { Shape } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment