2021-08-06 08:31:17 +00:00
|
|
|
<!--
|
|
|
|
// 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">
|
2022-09-21 08:08:25 +00:00
|
|
|
import type { Ref } from '@hcengineering/core'
|
2023-06-02 07:05:43 +00:00
|
|
|
import { createQuery } from '@hcengineering/presentation'
|
2023-04-14 10:29:15 +00:00
|
|
|
import { Scroller } from '@hcengineering/ui'
|
|
|
|
import { NavLink } from '@hcengineering/view-resources'
|
2023-02-05 15:33:55 +00:00
|
|
|
import type { Application } from '@hcengineering/workbench'
|
2023-06-02 07:05:43 +00:00
|
|
|
import workbench from '@hcengineering/workbench'
|
2023-06-05 05:12:31 +00:00
|
|
|
import AppItem from './AppItem.svelte'
|
2021-08-06 08:31:17 +00:00
|
|
|
|
|
|
|
export let active: Ref<Application> | undefined
|
2021-11-29 10:06:53 +00:00
|
|
|
export let apps: Application[] = []
|
2022-10-04 15:49:11 +00:00
|
|
|
export let direction: 'vertical' | 'horizontal' = 'vertical'
|
2021-08-06 08:31:17 +00:00
|
|
|
|
2023-06-02 07:05:43 +00:00
|
|
|
let loaded: boolean = false
|
|
|
|
let hiddenAppsIds: Ref<Application>[] = []
|
|
|
|
const hiddenAppsIdsQuery = createQuery()
|
|
|
|
hiddenAppsIdsQuery.query(workbench.class.HiddenApplication, {}, (res) => {
|
|
|
|
hiddenAppsIds = res.map((r) => r.attachedTo)
|
|
|
|
loaded = true
|
|
|
|
})
|
2021-08-06 08:31:17 +00:00
|
|
|
</script>
|
|
|
|
|
2023-04-26 08:54:14 +00:00
|
|
|
<div class="flex-{direction === 'horizontal' ? 'row-center' : 'col-center'} clear-mins apps-{direction} relative">
|
2022-11-04 06:05:32 +00:00
|
|
|
{#if loaded}
|
|
|
|
<Scroller
|
|
|
|
invertScroll
|
2023-04-26 08:54:14 +00:00
|
|
|
padding={direction === 'horizontal' ? '.75rem .5rem' : '.5rem .75rem'}
|
2023-05-22 03:50:44 +00:00
|
|
|
gap={direction === 'horizontal' ? 'gap-1' : 'gapV-1'}
|
2022-11-04 06:05:32 +00:00
|
|
|
horizontal={direction === 'horizontal'}
|
|
|
|
contentDirection={direction}
|
2023-04-26 08:54:14 +00:00
|
|
|
buttons={'union'}
|
2022-11-04 06:05:32 +00:00
|
|
|
>
|
2023-06-02 07:05:43 +00:00
|
|
|
{#each apps.filter((it) => !hiddenAppsIds.includes(it._id)) as app}
|
2023-06-01 04:08:01 +00:00
|
|
|
<NavLink app={app.alias} shrink={0}>
|
2023-06-05 05:12:31 +00:00
|
|
|
<AppItem selected={app._id === active} icon={app.icon} label={app.label} />
|
2023-02-05 15:33:55 +00:00
|
|
|
</NavLink>
|
2022-11-04 06:05:32 +00:00
|
|
|
{/each}
|
|
|
|
<div class="apps-space-{direction}" />
|
|
|
|
</Scroller>
|
|
|
|
{/if}
|
2021-08-06 08:31:17 +00:00
|
|
|
</div>
|
2022-10-04 15:49:11 +00:00
|
|
|
|
|
|
|
<style lang="scss">
|
|
|
|
.apps-horizontal {
|
2022-11-01 15:48:20 +00:00
|
|
|
justify-content: center;
|
2023-04-26 08:54:14 +00:00
|
|
|
margin: 0 0.5rem 0 0.25rem;
|
2023-05-22 03:50:44 +00:00
|
|
|
height: var(--app-panel-width);
|
2022-11-01 15:48:20 +00:00
|
|
|
min-height: 4rem;
|
2022-10-04 15:49:11 +00:00
|
|
|
}
|
|
|
|
.apps-vertical {
|
2023-05-22 03:50:44 +00:00
|
|
|
margin: 0.5rem 0;
|
|
|
|
width: var(--app-panel-width);
|
2022-11-01 15:48:20 +00:00
|
|
|
min-width: 4rem;
|
|
|
|
}
|
|
|
|
.apps-space {
|
|
|
|
&-vertical {
|
2023-04-26 08:54:14 +00:00
|
|
|
min-height: 0.5rem;
|
|
|
|
height: 0.5rem;
|
2022-11-01 15:48:20 +00:00
|
|
|
}
|
|
|
|
&-horizontal {
|
2023-04-26 08:54:14 +00:00
|
|
|
min-width: 0.5rem;
|
|
|
|
width: 0.5rem;
|
2022-11-01 15:48:20 +00:00
|
|
|
}
|
|
|
|
}
|
2022-10-04 15:49:11 +00:00
|
|
|
</style>
|