Skip to content

Instantly share code, notes, and snippets.

@robozevel
Created January 10, 2019 21:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save robozevel/9b8910e7341d6af901e266f143971a49 to your computer and use it in GitHub Desktop.
Save robozevel/9b8910e7341d6af901e266f143971a49 to your computer and use it in GitHub Desktop.
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