2019-09-26 16:40:58 +12:00
|
|
|
<script>
|
|
|
|
import {buildStyle} from "./buildStyle";
|
2019-10-03 18:12:13 +13:00
|
|
|
import cssVars from "./cssVars";
|
2019-09-26 16:40:58 +12:00
|
|
|
|
|
|
|
export let component="";
|
|
|
|
export let text="";
|
|
|
|
export let containerClass="";
|
|
|
|
export let background="";
|
|
|
|
export let border="";
|
|
|
|
export let borderRadius="";
|
|
|
|
export let font="";
|
|
|
|
export let display="";
|
|
|
|
export let textAlign="";
|
|
|
|
export let color="";
|
|
|
|
export let padding="";
|
2019-10-03 18:12:13 +13:00
|
|
|
export let margin="";
|
|
|
|
export let hoverBackground="";
|
|
|
|
export let hoverColor="";
|
|
|
|
export let onClick;
|
|
|
|
export let height;
|
|
|
|
export let width;
|
2019-09-26 16:40:58 +12:00
|
|
|
|
2019-09-28 04:03:31 +12:00
|
|
|
export let _bb;
|
2019-09-26 16:40:58 +12:00
|
|
|
|
2019-10-03 18:12:13 +13:00
|
|
|
let styleVars;
|
2019-09-26 16:40:58 +12:00
|
|
|
let style="";
|
|
|
|
let componentElement;
|
2019-10-10 18:18:02 +13:00
|
|
|
let componentInitialised=false;
|
2019-09-26 16:40:58 +12:00
|
|
|
|
|
|
|
$: {
|
|
|
|
style=buildStyle({
|
2019-10-03 18:12:13 +13:00
|
|
|
border, background, font, margin,
|
|
|
|
padding, display, color, height, width,
|
2019-09-26 16:40:58 +12:00
|
|
|
"text-align": textAlign,
|
2019-10-03 18:12:13 +13:00
|
|
|
"border-radius":borderRadius,
|
|
|
|
cursor: onClick ? "pointer" : "none"
|
2019-09-26 16:40:58 +12:00
|
|
|
});
|
|
|
|
|
2019-10-10 18:18:02 +13:00
|
|
|
if(_bb && component && componentElement && !componentInitialised) {
|
2019-10-19 19:24:20 +13:00
|
|
|
_bb.hydrateComponent(_bb.props.component, componentElement);
|
2019-10-10 18:18:02 +13:00
|
|
|
componentInitialised = true;
|
2019-09-26 16:40:58 +12:00
|
|
|
}
|
2019-10-03 18:12:13 +13:00
|
|
|
|
|
|
|
styleVars = {
|
|
|
|
hoverBackground:hoverBackground || background,
|
|
|
|
hoverColor:hoverColor || color
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
const clickHandler = () => {
|
2019-10-19 05:32:03 +13:00
|
|
|
if(onClick) {
|
|
|
|
_bb.call(onClick);
|
|
|
|
}
|
2019-09-26 16:40:58 +12:00
|
|
|
}
|
|
|
|
|
|
|
|
</script>
|
|
|
|
|
2019-10-03 18:12:13 +13:00
|
|
|
<div class="{containerClass} panel"
|
2019-09-26 16:40:58 +12:00
|
|
|
style={style}
|
2019-10-03 18:12:13 +13:00
|
|
|
use:cssVars={styleVars}
|
2019-10-10 18:18:02 +13:00
|
|
|
bind:this={componentElement}
|
2019-10-03 18:12:13 +13:00
|
|
|
on:click={clickHandler}>
|
|
|
|
{component && component._component ? "" : text}
|
2019-09-26 16:40:58 +12:00
|
|
|
</div>
|
2019-10-03 18:12:13 +13:00
|
|
|
|
|
|
|
<style>
|
|
|
|
|
|
|
|
.panel:hover {
|
|
|
|
background: var(--hoverBackground);
|
|
|
|
color: var(--hoverColor);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
</style>
|