Files
speckle-server/packages/frontend-2/components/viewer/views/Menu.vue
T
andrewwallacespeckle c2a95b484f refactor(ui-components): define and use new font styles (#2524)
* New Text Styles. Initial FE2 changes

* More fe2 styling classes

* Minor update

* Minor update

* Fix build

* More updates for discussion

* More styling updates

* Minor updates to inputs

* More text updates

* More font class swapping

* Revert dui3 changes

* Confirmed Lineheights

* Add story files for new text styles

* Minor copy changes

* Minor typo

* andrew/web-1371-misalignment-in-account-dropdown

* andrew/web-1374-settings-text-styles-are-not-right

* andrew/web-1375-nav-texts-should-be-14px

* andrew/web-1376-decrease-size-of-versions-header

* andrew/web-1377-version-card-title

* semibold>medium

* Measure mode

* Changes from PR

* Tweaked nav menu

* Revert prose change. Add prose-sm

---------

Co-authored-by: Mike Tasset <mike.tasset@gmail.com>
2024-07-30 15:06:48 +01:00

84 lines
2.7 KiB
Vue

<template>
<div ref="menuWrapper" class="relative z-30">
<ViewerControlsButtonToggle flat secondary :active="open" @click="open = !open">
<IconViews class="w-5 h-5" />
</ViewerControlsButtonToggle>
<Transition
enter-active-class="transform ease-out duration-300 transition"
enter-from-class="translate-y-2 opacity-0 sm:translate-y-0 sm:translate-x-2"
enter-to-class="translate-y-0 opacity-100 sm:translate-x-0"
leave-active-class="transition ease-in duration-100"
leave-from-class="opacity-100"
leave-to-class="opacity-0"
>
<div
v-if="open"
class="absolute translate-x-0 w-32 left-10 sm:left-12 -top-0 sm:-top-2 bg-foundation max-h-64 simple-scrollbar overflow-y-auto outline outline-2 outline-primary-muted rounded-lg shadow-lg overflow-hidden flex flex-col"
>
<!-- Canonical views first -->
<div v-for="view in canonicalViews" :key="view.name">
<button
class="hover:bg-primary-muted text-foreground w-full h-full text-body-xs py-1"
@click="setView(view.name.toLowerCase() as CanonicalView)"
>
{{ view.name }}
</button>
</div>
<div v-if="views.length !== 0" class="w-full border-b"></div>
<!-- Any model other views -->
<div v-for="view in views" :key="view.id">
<button
class="hover:bg-primary-muted text-foreground w-full h-full text-body-xs py-1 transition"
:title="view.name"
@click="setView(view)"
>
<span class="block truncate max-w-28 mx-auto">
{{ view.name ? view.name : view.id }}
</span>
</button>
</div>
</div>
</Transition>
</div>
</template>
<script setup lang="ts">
import type { CanonicalView, SpeckleView } from '~~/../viewer/dist'
import { useMixpanel } from '~~/lib/core/composables/mp'
import { useInjectedViewerState } from '~~/lib/viewer/composables/setup'
import { useCameraUtilities } from '~~/lib/viewer/composables/ui'
import { onClickOutside } from '@vueuse/core'
const {
viewer: {
metadata: { views }
}
} = useInjectedViewerState()
const { setView: setViewRaw } = useCameraUtilities()
const mp = useMixpanel()
const open = ref(false)
const menuWrapper = ref(null)
const setView = (v: CanonicalView | SpeckleView) => {
setViewRaw(v)
mp.track('Viewer Action', {
type: 'action',
name: 'set-view',
view: (v as SpeckleView)?.name || v
})
}
const canonicalViews = [
{ name: 'Top' },
{ name: 'Front' },
{ name: 'Left' },
{ name: 'Back' },
{ name: 'Right' }
]
onClickOutside(menuWrapper, () => {
open.value = false
})
</script>