2019-08-19 22:18:23 +02:00
|
|
|
<script>
|
2019-10-07 07:03:41 +02:00
|
|
|
import cssVars from "./cssVars";
|
|
|
|
import {buildStyle} from "./buildStyle";
|
2019-08-27 08:32:56 +02:00
|
|
|
export let className = "default";
|
2019-08-19 22:18:23 +02:00
|
|
|
export let disabled = false;
|
2019-08-27 08:32:56 +02:00
|
|
|
export let contentText;
|
|
|
|
export let contentComponent;
|
2019-10-10 07:18:02 +02:00
|
|
|
export let onClick;
|
2019-10-07 07:03:41 +02:00
|
|
|
export let background;
|
|
|
|
export let color;
|
|
|
|
export let border;
|
|
|
|
export let padding;
|
|
|
|
export let hoverColor;
|
|
|
|
export let hoverBackground;
|
|
|
|
export let hoverBorder;
|
2019-08-27 08:32:56 +02:00
|
|
|
|
2019-09-27 18:03:31 +02:00
|
|
|
export let _bb;
|
2019-09-03 11:42:19 +02:00
|
|
|
let contentComponentContainer;
|
2019-10-07 07:03:41 +02:00
|
|
|
let cssVariables;
|
|
|
|
let buttonStyles;
|
|
|
|
|
|
|
|
let customHoverColorClass;
|
|
|
|
let customHoverBorderClass;
|
|
|
|
let customHoverBackClass;
|
2019-09-03 11:42:19 +02:00
|
|
|
|
|
|
|
$:{
|
2019-09-27 18:03:31 +02:00
|
|
|
if(_bb && contentComponentContainer && contentComponent._component)
|
|
|
|
_bb.initialiseComponent(contentComponent, contentComponentContainer);
|
2019-10-07 07:03:41 +02:00
|
|
|
|
|
|
|
cssVariables = {
|
|
|
|
hoverColor, hoverBorder,
|
|
|
|
hoverBackground
|
|
|
|
};
|
|
|
|
|
|
|
|
buttonStyles = buildStyle({
|
|
|
|
background, color, border, padding
|
|
|
|
})
|
|
|
|
|
|
|
|
customHoverColorClass = hoverColor ? "customHoverColor" : "";
|
|
|
|
customHoverBorderClass = hoverBorder ? "customHoverBorder" : "";
|
|
|
|
customHoverBackClass = hoverBackground ? "customHoverBack" : "";
|
2019-09-03 11:42:19 +02:00
|
|
|
}
|
|
|
|
|
2019-09-22 06:02:33 +02:00
|
|
|
|
2019-10-07 07:03:41 +02:00
|
|
|
|
|
|
|
|
2019-09-22 06:02:33 +02:00
|
|
|
const clickHandler = () => {
|
2019-10-07 07:03:41 +02:00
|
|
|
_bb.call(onClick);
|
2019-09-22 06:02:33 +02:00
|
|
|
}
|
|
|
|
|
2019-08-19 22:18:23 +02:00
|
|
|
</script>
|
|
|
|
|
|
|
|
|
2019-10-07 07:03:41 +02:00
|
|
|
<button use:cssVars={cssVariables}
|
|
|
|
class="{className} {customHoverColorClass} {customHoverBorderClass} {customHoverBackClass}"
|
2019-10-10 07:18:02 +02:00
|
|
|
disabled={disabled || false}
|
2019-10-07 07:03:41 +02:00
|
|
|
on:click={clickHandler}
|
|
|
|
style={buttonStyles}>
|
2019-08-27 08:32:56 +02:00
|
|
|
{#if contentComponent && contentComponent._component}
|
2019-09-03 11:42:19 +02:00
|
|
|
<div bind:this={contentComponentContainer}>
|
|
|
|
</div>
|
2019-08-27 08:32:56 +02:00
|
|
|
{:else if contentText}
|
2019-08-19 22:18:23 +02:00
|
|
|
{contentText}
|
|
|
|
{:else}
|
2019-08-27 08:32:56 +02:00
|
|
|
<slot />
|
2019-08-19 22:18:23 +02:00
|
|
|
{/if}
|
2019-08-27 08:32:56 +02:00
|
|
|
</button>
|
|
|
|
|
|
|
|
|
|
|
|
<style>
|
|
|
|
|
|
|
|
.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;
|
|
|
|
color: #333;
|
|
|
|
background-color: #f4f4f4;
|
|
|
|
outline: none;
|
|
|
|
}
|
|
|
|
|
|
|
|
.default:active {
|
|
|
|
background-color: #ddd;
|
|
|
|
}
|
|
|
|
|
|
|
|
.default:focus {
|
|
|
|
border-color: #666;
|
|
|
|
}
|
|
|
|
|
2019-10-07 07:03:41 +02:00
|
|
|
.customHoverBorder:hover {
|
|
|
|
border: var(--hoverBorder);
|
|
|
|
}
|
|
|
|
|
|
|
|
.customHoverColor:hover {
|
|
|
|
color: var(--hoverColor);
|
|
|
|
}
|
|
|
|
|
|
|
|
.customHoverBack:hover {
|
|
|
|
background: var(--hoverBackground);
|
|
|
|
}
|
2019-08-27 08:32:56 +02:00
|
|
|
</style>
|