Skip to content

Instantly share code, notes, and snippets.

@ChaseH88
Created April 6, 2021 23:50
Show Gist options
  • Select an option

  • Save ChaseH88/3dfd9b09fca0f2e2189a9e464cd0d027 to your computer and use it in GitHub Desktop.

Select an option

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.
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