forked from tsai/budibase
8 changed files with 161 additions and 148 deletions
@ -1,40 +1,51 @@ |
|||
<script> |
|||
import ripple from "../Ripple.js"; |
|||
import ClassBuilder from "../ClassBuilder.js"; |
|||
import ripple from "../Common/Ripple.js" |
|||
import ClassBuilder from "../ClassBuilder.js" |
|||
|
|||
const cb = new ClassBuilder("icon-button"); |
|||
const cb = new ClassBuilder("icon-button") |
|||
|
|||
export let onClick = () => {}; |
|||
export let disabled = false; |
|||
export let href = ""; |
|||
export let icon = ""; |
|||
export let onIcon = ""; //on state icon for toggle button |
|||
export let size = "medium"; |
|||
export let _bb |
|||
export let context = "" |
|||
export let onClick = () => {} |
|||
export let disabled = false |
|||
export let href = "" |
|||
export let icon = "" |
|||
export let onIcon = "" //on state icon for toggle button |
|||
export let size = "medium" |
|||
|
|||
$: isToggleButton = !!icon && !!onIcon; |
|||
$: useLinkButton = !!href; |
|||
$: isToggleButton = !!icon && !!onIcon |
|||
$: useLinkButton = !!href |
|||
|
|||
$: customs = { size }; |
|||
$: props = { customs, extras: ["material-icons"] }; |
|||
$: iconBtnClass = cb.build({ props }); |
|||
$: customs = { size } |
|||
$: props = { customs, extras: ["material-icons", context] } |
|||
$: iconBtnClass = cb.build({ props }) |
|||
</script> |
|||
|
|||
{#if useLinkButton} |
|||
<a on:click={onClick} class={iconBtnClass} {href} {disabled}> |
|||
{#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} |
|||
</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} |
|||
</a> |
|||
{:else} |
|||
<button on:click={onClick} use:ripple class={iconBtnClass} {disabled}> |
|||
<button |
|||
on:click={onClick} |
|||
class={iconBtnClass} |
|||
{disabled} |
|||
role="button" |
|||
tabindex="0"> |
|||
{#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} |
|||
</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} |
|||
</button> |
|||
{/if} |
|||
|
|||
@ -1,13 +1,19 @@ |
|||
@import "@material/icon-button/mdc-icon-button"; |
|||
|
|||
.bbmd-mdc-icon-button--size-large { |
|||
@include mdc-icon-button-icon-size(24px); |
|||
} |
|||
.mdc-icon-button { |
|||
|
|||
.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); |
|||
&.bbmd-mdc-icon-button--size-large { |
|||
@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