Created
January 10, 2019 21:53
-
-
Save robozevel/9b8910e7341d6af901e266f143971a49 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
module.exports = { | |
name: 'StarRating', | |
functional: true, | |
props: { | |
stars: { | |
type: Number, | |
default: 0 | |
}, | |
tag: { | |
type: String, | |
default: 'span' | |
}, | |
size: { | |
type: Number, | |
default: 16 | |
}, | |
spacing: { | |
type: Number, | |
default: 2 | |
} | |
}, | |
render(h, { props }) { | |
return h( | |
props.tag, | |
{ | |
style: { | |
fontSize: `${props.size}px`, | |
letterSpacing: `${props.spacing}px`, | |
color: '#ed8a19' | |
} | |
}, | |
Array.from({ length: 5 }, (x, i) => | |
i >= props.stars ? '\u2606' : '\u2605' | |
).join('') | |
) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment