Files
huly-platform/packages/ui/src/components/CircleButton.svelte
T
2021-10-27 17:57:07 +02:00

71 lines
2.0 KiB
Svelte

<!--
// Copyright © 2020 Anticrm Platform Contributors.
//
// Licensed under the Eclipse Public License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License. You may
// obtain a copy of the License at https://www.eclipse.org/legal/epl-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
//
// See the License for the specific language governing permissions and
// limitations under the License.
-->
<script lang="ts">
import type { Asset } from '@anticrm/platform'
import type { AnySvelteComponent } from '../types'
import Icon from './Icon.svelte'
export let icon: Asset | AnySvelteComponent
export let size: 'small' | 'medium' | 'large' = 'large'
export let transparent: boolean = false
export let selected: boolean = false
</script>
<div class="icon-button icon-{size}" class:selected class:transparent on:click>
<div class="content">
{#if typeof (icon) === 'string'}
<Icon {icon} size={'small'}/>
{:else}
<svelte:component this={icon} size={'small'} />
{/if}
</div>
</div>
<style lang="scss">
.icon-button {
display: flex;
justify-content: center;
align-items: center;
border: 1px solid var(--theme-card-divider);
border-radius: 50%;
backdrop-filter: blur(3px);
cursor: pointer;
.content {
transform-origin: center center;
transform: scale(.75);
pointer-events: none;
}
&.selected { background-color: var(--theme-button-bg-hovered); }
&.transparent { background-color: rgba(31, 31, 37, .3); }
&:hover { border-color: var(--theme-bg-focused-border); }
&:active { background-color: var(--theme-bg-accent-color); }
}
.icon-small {
width: 1.5rem;
height: 1.5rem;
.content { transform: scale(.55); }
}
.icon-medium {
width: 1.75rem;
height: 1.75rem;
}
.icon-large {
width: 2rem;
height: 2rem;
}
</style>