Skip to content

Instantly share code, notes, and snippets.

@isabelandss
Last active July 1, 2020 14:07
Show Gist options
  • Save isabelandss/1f1344c67b3a81e040b762a0f6541ad0 to your computer and use it in GitHub Desktop.
Save isabelandss/1f1344c67b3a81e040b762a0f6541ad0 to your computer and use it in GitHub Desktop.
import { Component, h, Prop } from '@stencil/core'
const getButtonClass = (classname, color, small) =>
`custom-button ${classname} ${color} ${small ? 'small' : ''}`
export type Color = 'primary' | 'secondary' | 'tertiary'
@Component({
tag: 'custom-button',
styleUrl: 'custom-button.css',
shadow: true,
})
export class CustomButtonComponent {
@Prop() classname: string = ''
@Prop() color: Color = 'primary'
@Prop() small: boolean = false
render() {
return (
<button class={getButtonClass(this.classname, this.color, this.small)}>
<slot></slot>
</button>
)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment