mirror of https://github.com/Budibase/budibase.git
8 changed files with 161 additions and 148 deletions
@ -1,40 +1,51 @@ |
|||||
<script> |
<script> |
||||
import ripple from "../Ripple.js"; |
import ripple from "../Common/Ripple.js" |
||||
import ClassBuilder from "../ClassBuilder.js"; |
import ClassBuilder from "../ClassBuilder.js" |
||||
|
|
||||
const cb = new ClassBuilder("icon-button"); |
const cb = new ClassBuilder("icon-button") |
||||
|
|
||||
export let onClick = () => {}; |
export let _bb |
||||
export let disabled = false; |
export let context = "" |
||||
export let href = ""; |
export let onClick = () => {} |
||||
export let icon = ""; |
export let disabled = false |
||||
export let onIcon = ""; //on state icon for toggle button |
export let href = "" |
||||
export let size = "medium"; |
export let icon = "" |
||||
|
export let onIcon = "" //on state icon for toggle button |
||||
|
export let size = "medium" |
||||
|
|
||||
$: isToggleButton = !!icon && !!onIcon; |
$: isToggleButton = !!icon && !!onIcon |
||||
$: useLinkButton = !!href; |
$: useLinkButton = !!href |
||||
|
|
||||
$: customs = { size }; |
$: customs = { size } |
||||
$: props = { customs, extras: ["material-icons"] }; |
$: props = { customs, extras: ["material-icons", context] } |
||||
$: iconBtnClass = cb.build({ props }); |
$: iconBtnClass = cb.build({ props }) |
||||
</script> |
</script> |
||||
|
|
||||
{#if useLinkButton} |
{#if useLinkButton} |
||||
<a on:click={onClick} class={iconBtnClass} {href} {disabled}> |
<a on:click={onClick} class={iconBtnClass} {href} {disabled}> |
||||
{#if isToggleButton} |
{#if isToggleButton} |
||||
<i class="material-icons mdc-icon-button__icon mdc-icon-button__icon--on"> |
<i |
||||
|
use:ripple |
||||
|
class="material-icons mdc-icon-button__icon mdc-icon-button__icon--on"> |
||||
{onIcon} |
{onIcon} |
||||
</i> |
</i> |
||||
<i class="material-icons mdc-icon-button__icon">{icon}</i> |
<i use:ripple class="material-icons mdc-icon-button__icon">{icon}</i> |
||||
{:else}{icon}{/if} |
{:else}{icon}{/if} |
||||
</a> |
</a> |
||||
{:else} |
{:else} |
||||
<button on:click={onClick} use:ripple class={iconBtnClass} {disabled}> |
<button |
||||
|
on:click={onClick} |
||||
|
class={iconBtnClass} |
||||
|
{disabled} |
||||
|
role="button" |
||||
|
tabindex="0"> |
||||
{#if isToggleButton} |
{#if isToggleButton} |
||||
<i class="material-icons mdc-icon-button__icon mdc-icon-button__icon--on"> |
<i |
||||
|
use:ripple |
||||
|
class="material-icons mdc-icon-button__icon mdc-icon-button__icon--on"> |
||||
{onIcon} |
{onIcon} |
||||
</i> |
</i> |
||||
<i class="material-icons mdc-icon-button__icon">{icon}</i> |
<i use:ripple class="material-icons mdc-icon-button__icon">{icon}</i> |
||||
{:else}{icon}{/if} |
{:else}{icon}{/if} |
||||
</button> |
</button> |
||||
{/if} |
{/if} |
||||
|
|||||
@ -1,13 +1,19 @@ |
|||||
@import "@material/icon-button/mdc-icon-button"; |
@import "@material/icon-button/mdc-icon-button"; |
||||
|
|
||||
.bbmd-mdc-icon-button--size-large { |
.mdc-icon-button { |
||||
@include mdc-icon-button-icon-size(24px); |
|
||||
} |
|
||||
|
|
||||
.bbmd-mdc-icon-button--size-medium { |
|
||||
@include mdc-icon-button-icon-size(20px); |
|
||||
} |
|
||||
|
|
||||
.bbmd-mdc-icon-button--size-small { |
&.bbmd-mdc-icon-button--size-large { |
||||
@include mdc-icon-button-icon-size(16px); |
@include mdc-icon-button-icon-size(24px); |
||||
|
} |
||||
|
|
||||
|
&.bbmd-mdc-icon-button--size-medium { |
||||
|
@include mdc-icon-button-icon-size(20px); |
||||
|
} |
||||
|
|
||||
|
&.bbmd-mdc-icon-button--size-small { |
||||
|
@include mdc-icon-button-icon-size(16px); |
||||
|
} |
||||
} |
} |
||||
|
|
||||
|
|
||||
|
|||||
Loading…
Reference in new issue