Last active
July 10, 2017 19:51
-
-
Save adammark/0a31e67735bbb9e64ec300a5b3ef1882 to your computer and use it in GitHub Desktop.
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
var Bubble = function (props) { | |
var { | |
percent = 0, // a number between 0 and 1, inclusive | |
size = 20, // the width and height of the bubble | |
color = "#0078bc", // the fill color | |
label = null // a label to describe the contents (for accessibility) | |
} = props; | |
var c = size / 2; | |
var r = Math.sqrt(Math.pow(c, 2) * percent); | |
return ( | |
<svg width={size} height={size} aria-label={label} data-tooltip={label}> | |
<circle cx={c} cy={c} r={c} fill="#ddd"/> | |
<circle cx={c} cy={c} r={r} fill={color}/> | |
</svg> | |
); | |
}; | |
module.exports = Bubble; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment