Rename IconButtonInner to InnerButton, as it does not necessarily contain an Icon

This commit is contained in:
Henrik Giesel 2021-03-29 23:26:08 +02:00
parent a12e39a15f
commit 0269c97b2e
3 changed files with 30 additions and 10 deletions

View File

@ -27,7 +27,7 @@
<script lang="typescript">
import ButtonItem from "./ButtonItem.svelte";
import IconButtonInner from "./IconButtonInner.svelte";
import InnerButton from "./InnerButton.svelte";
export let className = "";
export let icon = "";
@ -51,7 +51,7 @@
</script>
<ButtonItem>
<IconButtonInner {className} {active} {onClick}>
<InnerButton {className} {active} {onClick}>
{@html icon}
</IconButtonInner>
</InnerButton>
</ButtonItem>

View File

@ -1,6 +1,6 @@
<script lang="typescript">
import ButtonItem from "./ButtonItem.svelte";
import IconButtonInner from "./IconButtonInner.svelte";
import InnerButton from "./InnerButton.svelte";
export let className = "";
export let icon = "";
@ -8,7 +8,7 @@
</script>
<ButtonItem>
<IconButtonInner {className} active={false} {onClick}>
<InnerButton {className} {onClick}>
{@html icon}
</IconButtonInner>
</InnerButton>
</ButtonItem>

View File

@ -1,17 +1,19 @@
<script lang="typescript">
export let className: string;
export let className: string = '';
export let onClick: (event: ClickEvent) => void;
export let active: boolean;
export let active = false;
export let disabled = false;
</script>
<style lang="scss">
button {
display: inline-block;
width: 30px;
height: 30px;
background-color: white;
vertical-align: -webkit-baseline-middle;
padding: 2px;
& > :global(svg),
& > :global(img) {
@ -27,9 +29,27 @@
&:active, &.active {
box-shadow: inset 0 0 10px 3px rgb(0 0 0 / 30%);
}
&[disabled] {
opacity: 0.4;
&:hover {
background-color: white;
}
&:active, &.active {
box-shadow: none;
}
}
}
</style>
<button class={className} class:active on:click={onClick} on:mousedown|preventDefault>
<button
class="p-1 {className}"
class:active
{disabled}
on:click={onClick}
on:mousedown|preventDefault
>
<slot />
</button>