Files
classroomio/src/components/IconButton/index.svelte
T

70 lines
1.4 KiB
Svelte
Raw Normal View History

2021-05-29 20:47:46 +03:00
<script>
2021-08-18 19:47:02 +03:00
import ToolTip from '../ToolTip/index.svelte';
export let onClick = () => {};
2021-05-29 20:47:46 +03:00
export let disabled = false;
export let selected = false;
2021-08-18 19:47:02 +03:00
export let buttonClassName = '';
2021-06-26 21:32:42 +03:00
export let contained = false;
2021-08-18 19:47:02 +03:00
export let value = '';
2021-08-26 13:35:56 +03:00
export let size = 'large';
2021-08-28 22:44:06 +03:00
export let color = '';
2021-05-31 11:28:46 +03:00
export let toolTipProps = {
2021-08-18 19:47:02 +03:00
title: '',
2021-05-31 11:28:46 +03:00
hotkeys: [],
2021-08-18 19:47:02 +03:00
direction: '',
2021-05-31 11:28:46 +03:00
};
2021-05-29 20:47:46 +03:00
function handleClick() {
onClick(value);
}
</script>
2021-07-04 19:52:16 +03:00
<ToolTip
title={toolTipProps.title}
hotkeys={toolTipProps.hotkeys}
direction={toolTipProps.direction}
>
2021-06-01 07:19:19 +03:00
<button
2021-08-28 22:44:06 +03:00
class="root {color} {selected && 'active'} {size} {contained &&
2021-07-04 19:52:16 +03:00
'contained'} {buttonClassName}"
2021-06-01 07:19:19 +03:00
{disabled}
on:click={handleClick}
>
<slot />
</button>
</ToolTip>
2021-05-29 20:47:46 +03:00
<style lang="scss">
.root {
flex: 0 0 auto;
padding: 12px;
font-size: 1.5rem;
text-align: center;
transition: background-color 150ms cubic-bezier(0.4, 0, 0.2, 1) 0ms;
border-radius: 50%;
border: 0;
cursor: pointer;
margin: 0;
display: flex;
outline: 0;
align-items: center;
justify-content: center;
text-decoration: none;
-webkit-appearance: none;
-webkit-tap-highlight-color: transparent;
width: fit-content;
&:hover {
background-color: rgba(0, 0, 0, 0.04);
}
}
2021-06-26 21:32:42 +03:00
2021-08-26 13:35:56 +03:00
.root.small {
padding: 5px;
}
2021-06-26 21:32:42 +03:00
.contained {
background-color: rgba(0, 0, 0, 0.04);
}
</style>