2019-08-19 22:18:23 +02:00
|
|
|
<script>
|
2020-02-21 12:43:21 +01:00
|
|
|
import { cssVars, createClasses } from "./cssVars"
|
2020-02-03 10:50:30 +01:00
|
|
|
import { buildStyle } from "./buildStyle"
|
|
|
|
export let className = "default"
|
|
|
|
export let disabled = false
|
|
|
|
export let contentText
|
|
|
|
export let onClick
|
|
|
|
export let background
|
|
|
|
export let color
|
|
|
|
export let border
|
|
|
|
export let padding
|
|
|
|
export let hoverColor
|
|
|
|
export let hoverBackground
|
|
|
|
export let hoverBorder
|
|
|
|
|
|
|
|
export let _bb
|
|
|
|
let theButton
|
|
|
|
let cssVariables
|
|
|
|
let buttonStyles
|
|
|
|
|
|
|
|
let customHoverColorClass
|
|
|
|
let customHoverBorderClass
|
|
|
|
let customHoverBackClass
|
|
|
|
|
|
|
|
let customClasses = ""
|
|
|
|
|
2020-02-25 16:21:23 +01:00
|
|
|
$: if (_bb.props._children && _bb.props._children.length > 0)
|
2020-02-18 13:29:38 +01:00
|
|
|
theButton && _bb.attachChildren(theButton)
|
2020-02-03 10:50:30 +01:00
|
|
|
|
|
|
|
$: {
|
|
|
|
cssVariables = {
|
|
|
|
hoverColor,
|
|
|
|
hoverBorder,
|
|
|
|
hoverBackground,
|
|
|
|
background,
|
|
|
|
color,
|
|
|
|
border,
|
|
|
|
}
|
|
|
|
|
|
|
|
buttonStyles = buildStyle({
|
|
|
|
padding,
|
|
|
|
})
|
|
|
|
|
|
|
|
customClasses = createClasses({
|
|
|
|
hoverColor,
|
|
|
|
hoverBorder,
|
|
|
|
hoverBackground,
|
|
|
|
background,
|
|
|
|
border,
|
|
|
|
color,
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
const clickHandler = () => {
|
|
|
|
_bb.call(onClick)
|
|
|
|
}
|
2019-08-19 22:18:23 +02:00
|
|
|
</script>
|
|
|
|
|
2020-02-03 10:50:30 +01:00
|
|
|
<button
|
|
|
|
bind:this={theButton}
|
|
|
|
use:cssVars={cssVariables}
|
|
|
|
class="{className}
|
|
|
|
{customClasses}"
|
|
|
|
disabled={disabled || false}
|
|
|
|
on:click={clickHandler}
|
|
|
|
style={buttonStyles}>
|
2020-02-25 16:21:23 +01:00
|
|
|
{#if !_bb.props._children || _bb.props._children.length === 0}
|
|
|
|
{contentText}
|
|
|
|
{/if}
|
2019-08-27 08:32:56 +02:00
|
|
|
</button>
|
|
|
|
|
|
|
|
<style>
|
2020-02-03 10:50:30 +01:00
|
|
|
.default {
|
|
|
|
font-family: inherit;
|
|
|
|
font-size: inherit;
|
|
|
|
padding: 0.4em;
|
|
|
|
margin: 0 0 0.5em 0;
|
|
|
|
box-sizing: border-box;
|
|
|
|
border: 1px solid #ccc;
|
|
|
|
border-radius: 2px;
|
2020-03-17 12:16:49 +01:00
|
|
|
color: #000333;
|
2020-02-03 10:50:30 +01:00
|
|
|
outline: none;
|
|
|
|
}
|
|
|
|
|
|
|
|
.default:active {
|
2020-03-17 12:16:49 +01:00
|
|
|
background-color: #f9f9f9;
|
2020-02-03 10:50:30 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
.default:focus {
|
|
|
|
border-color: #666;
|
|
|
|
}
|
|
|
|
|
|
|
|
.border {
|
|
|
|
border: var(--border);
|
|
|
|
}
|
|
|
|
|
|
|
|
.color {
|
|
|
|
color: var(--color);
|
|
|
|
}
|
|
|
|
|
|
|
|
.background {
|
|
|
|
background: var(--background);
|
|
|
|
}
|
|
|
|
|
|
|
|
.hoverBorder:hover {
|
|
|
|
border: var(--hoverBorder);
|
|
|
|
}
|
|
|
|
|
|
|
|
.hoverColor:hover {
|
|
|
|
color: var(--hoverColor);
|
|
|
|
}
|
|
|
|
|
|
|
|
.hoverBack:hover {
|
|
|
|
background: var(--hoverBackground);
|
|
|
|
}
|
|
|
|
</style>
|