platform/plugins/workbench-resources/src/components/AppItem.svelte
Alexander Platov 1f7f1b05cf
New Tooltip (#167)
Signed-off-by: Alexander Platov <sas_lord@mail.ru>
2021-09-09 09:34:51 +02:00

92 lines
2.3 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 { IntlString, Asset } from '@anticrm/platform'
import { Icon, Tooltip } from '@anticrm/ui'
export let label: IntlString
export let icon: Asset
export let action: () => Promise<void>
export let selected: boolean
export let notify: boolean
</script>
<Tooltip {label}>
<button class="app" class:selected={selected} on:click={action}>
<div class="icon-container" class:noty={notify}>
<Icon icon={icon} size={'large'}/>
</div>
{#if notify}<div class="marker"/>{/if}
</button>
</Tooltip>
<style lang="scss">
.app {
position: relative;
padding: 0;
width: 3.25rem;
height: 3.25rem;
background-color: transparent;
border: 1px solid transparent;
border-radius: .5rem;
cursor: pointer;
outline: none;
.icon-container {
display: flex;
justify-content: center;
align-items: center;
width: 3.25rem;
height: 3.25rem;
opacity: .3;
.normal-font &.noty {
clip-path: url(#notify-normal);
}
.small-font &.noty {
clip-path: url(#notify-small);
}
}
&:hover .icon-container {
opacity: 1;
}
&:focus {
border: 1px solid var(--primary-button-focused-border);
box-shadow: 0 0 0 3px var(--primary-button-outline);
.icon-container {
opacity: 1;
}
}
&.selected {
background-color: var(--theme-menu-selection);
.icon-container {
opacity: 1;
}
}
}
.marker {
position: absolute;
top: .75rem;
right: .75rem;
width: .5rem;
height: .5rem;
border-radius: 50%;
background-color: var(--highlight-red);
}
</style>