budibase/packages/standard-components/src/Button.svelte

65 lines
1.1 KiB
Svelte
Raw Normal View History

2019-08-19 22:18:23 +02:00
<script>
2020-02-03 10:50:30 +01:00
export let className = "default"
export let disabled = false
2020-05-08 21:29:15 +02:00
export let text
2020-02-03 10:50:30 +01:00
export let _bb
let theButton
2020-02-25 16:21:23 +01:00
$: if (_bb.props._children && _bb.props._children.length > 0)
theButton && _bb.attachChildren(theButton)
2020-02-03 10:50:30 +01:00
const clickHandler = () => {
2020-09-10 22:11:05 +02:00
_bb.call("onClick")
2020-02-03 10:50:30 +01:00
}
2019-08-19 22:18:23 +02:00
</script>
2020-02-03 10:50:30 +01:00
<button
bind:this={theButton}
2020-06-03 23:49:55 +02:00
class="default"
2020-02-03 10:50:30 +01:00
disabled={disabled || false}
on:click={clickHandler}>
2020-05-21 15:28:32 +02:00
{#if !_bb.props._children || _bb.props._children.length === 0}{text}{/if}
2019-08-27 08:32:56 +02:00
</button>
<style>
2020-02-03 10:50:30 +01:00
.default {
2020-06-03 23:49:55 +02:00
align-items: center;
padding: var(--spacing-s) var(--spacing-l);
2020-02-03 10:50:30 +01:00
box-sizing: border-box;
2020-06-03 23:49:55 +02:00
border-radius: 4px;
2020-02-03 10:50:30 +01:00
outline: none;
2020-06-03 23:49:55 +02:00
cursor: pointer;
transition: all 0.2s ease 0s;
overflow: hidden;
outline: none;
user-select: none;
white-space: nowrap;
text-align: center;
2020-02-03 10:50:30 +01:00
}
.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>