Skip to content

Commit

Permalink
feat: zoomable indicator preview
Browse files Browse the repository at this point in the history
  • Loading branch information
Tucsky committed Oct 17, 2024
1 parent a7ce503 commit 5d3fdf2
Show file tree
Hide file tree
Showing 11 changed files with 283 additions and 92 deletions.
2 changes: 1 addition & 1 deletion src/components/chart/Chart.vue
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
@click="toggleTimeframeDropdown($event, $refs.timeframeButton)"
class="-arrow -cases pane-header__highlight pane-chart__timeframe-selector"
>
{{ !isKnownTimeframe ? timeframeForHuman : '' }}
<span>{{ !isKnownTimeframe ? timeframeForHuman : '' }}</span>
</Btn>
<hr />
</pane-header>
Expand Down
20 changes: 14 additions & 6 deletions src/components/chart/TimeframeDropdown.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<template>
<dropdown v-model="value">
<dropdown :value="value" @input="$emit('input', $event)">
<div class="timeframe-dropdown">
<div class="dropdown-item timeframe-dropdown__header" @click.stop>
<timeframe-input
Expand Down Expand Up @@ -233,14 +233,22 @@ export default {
}
}
&:hover {
.icon-star {
display: block;
@media (hover: hover) and (pointer: fine) {
&:hover {
.icon-star {
display: block;
&:hover {
color: var(--theme-color-base);
&:hover {
color: var(--theme-color-base);
}
}
}
}
@media (hover: none) and (pointer: coarse) {
.icon-star {
display: block;
}
}
}
</style>
4 changes: 4 additions & 0 deletions src/components/chart/controls.ts
Original file line number Diff line number Diff line change
Expand Up @@ -593,6 +593,10 @@ export default class ChartControl {
components.timeframeDropdown = createComponent(module.default, propsData)

mountComponent(components.timeframeDropdown)

components.timeframeDropdown.$on('input', value => {
components.timeframeDropdown.value = value
})
} else {
if (components.timeframeDropdown.value === event.currentTarget) {
components.timeframeDropdown.value = null
Expand Down
14 changes: 9 additions & 5 deletions src/components/framework/Btn.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@
class="btn"
@click="onClick"
>
<loader v-if="loading" class="btn__loader" small />
<loader v-if="isLoading" class="btn__loader" small />
<slot />
</component>
</template>

<script lang="ts">
import { Component, Vue } from 'vue-property-decorator'
import { Component, Vue, Watch } from 'vue-property-decorator'

This comment has been minimized.

Copy link
@adeacetis

adeacetis Oct 17, 2024

Collaborator

Quick comment about this:
Vue 2.7.14 and above provides built-in support for Composition API. You could easily remove that library which is no longer maintained.

This comment has been minimized.

Copy link
@Tucsky

Tucsky Oct 17, 2024

Author Owner

Yeah but vue-property-decorator has nothing to do with composition API. This is just the old way of doing clean vue components, but I'm aware it's not longer recommended 👍

Unfortunately switching to composition api isn't just a npm install thing i'd have to rewirte everything in script setup kind of components

import Loader from '@/components/framework/Loader.vue'
@Component({
Expand Down Expand Up @@ -50,10 +50,15 @@ import Loader from '@/components/framework/Loader.vue'
}
})
export default class Btn extends Vue {
loading: boolean
isLoading = false
@Watch('loading')
onLoadingChange(value) {
this.isLoading = value
}
onClick(event) {
if (!this.loading) {
if (!this.isLoading) {
this.$emit('click', event)
}
}
Expand All @@ -63,7 +68,6 @@ export default class Btn extends Vue {
<style lang="scss" scoped>
.btn {
&__loader {
margin-right: 0.5rem;
width: 0.5em;
height: 0.5em;
Expand Down
57 changes: 10 additions & 47 deletions src/components/indicators/IndicatorDetail.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,13 @@
<transition name="indicator-detail" @after-leave="$emit('close')">
<div v-if="opened" class="indicator-detail" @click="onBackdropClick">
<div class="indicator-detail__wrapper hide-scrollbar">
<div
<IndicatorPreview
class="indicator-detail__preview"
:style="{ '--image-height': imageHeight + 'px' }"
>
<Btn class="indicator-detail__close -text" @click="close">
<i class="icon-cross"></i>
</Btn>
<code class="indicator-detail__id -filled">
<small>#{{ indicator.id }}</small>
</code>
<img v-if="image" :src="image" @load="onImageLoad" />
</div>
:id="indicator.id"
:preview="indicator.preview"
:path="indicator.imagePath"
@close="close"
></IndicatorPreview>
<div class="indicator-detail__content">
<div class="indicator-detail__head">
<div class="indicator-detail__name">
Expand Down Expand Up @@ -128,7 +123,7 @@
</transition>
</template>

<script>
<script lang="ts">
import Btn from '@/components/framework/Btn.vue'
import importService from '@/services/importService'
import { ago, sleep } from '@/utils/helpers'
Expand All @@ -137,6 +132,7 @@ import workspacesService from '@/services/workspacesService'
import EditResourceDialog from '@/components/library/EditResourceDialog.vue'
import { openPublishDialog } from '@/components/library/helpers'
import { computeThemeColorAlpha } from '@/utils/colors'
import IndicatorPreview from './IndicatorPreview.vue'
export default {
props: {
Expand All @@ -150,12 +146,12 @@ export default {
}
},
components: {
Btn
Btn,
IndicatorPreview
},
data() {
return {
opened: false,
imageHeight: 100,
isInstalling: false,
isPublishing: false,
isFetchingVersions: false,
Expand Down Expand Up @@ -473,10 +469,6 @@ export default {
await workspacesService.saveIndicator(indicator, true)
this.$emit('reload', indicator.id)
}
},
onImageLoad(event) {
const img = event.target
this.imageHeight = img.naturalHeight
}
}
}
Expand All @@ -493,37 +485,8 @@ export default {
z-index: 27;
&__preview {
height: 100px;
width: 100%;
position: relative;
overflow: hidden;
border-radius: 0.75rem 0.75rem 0 0;
background-color: var(--theme-background-o75);
transition: height 0.2s $ease-out-expo;
max-height: 420px;
img {
width: 100%;
height: 100%;
object-fit: cover;
border-radius: 0.75rem 0.75rem 0 0;
}
&:hover {
height: var(--image-height);
}
}
&__id {
position: absolute;
top: 0.5rem;
left: 0.5rem;
}
&__close {
position: absolute;
top: 0.5rem;
right: 0.5rem;
}
&__name {
Expand Down
5 changes: 1 addition & 4 deletions src/components/indicators/IndicatorLibraryDialog.vue
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,7 @@
<template #subheader>
<tabs v-model="tab">
<tab name="installed"> Installed </tab>
<tab v-if="communityTabEnabled" name="community">
Community
<span class="badge -red ml8">new</span>
</tab>
<tab v-if="communityTabEnabled" name="community"> Community </tab>
</tabs>
</template>

Expand Down
Loading

0 comments on commit 5d3fdf2

Please sign in to comment.