Skip to content

Commit

Permalink
widgets: create ImageView
Browse files Browse the repository at this point in the history
  • Loading branch information
Williangalvani authored and rafaellehmkuhl committed May 29, 2023
1 parent d37d456 commit 9f93964
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 0 deletions.
42 changes: 42 additions & 0 deletions src/components/widgets/ImageView.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<template>
<div>
<img :src="src" />
<v-btn
class="options-btn"
icon="mdi-dots-vertical"
size="x-small"
variant="text"
flat
@click="showOptionsDialog = !showOptionsDialog"
/>
<v-dialog v-model="showOptionsDialog" min-width="400" max-width="35%">
<v-card class="pa-2">
<v-card-title>Image URL</v-card-title>
<v-card-text>
<v-text-field v-model="src" label="Image URL" outlined></v-text-field>
</v-card-text>
<v-card-actions>
<v-btn color="primary" text @click="showOptionsDialog = false">Close</v-btn>
</v-card-actions>
</v-card>
</v-dialog>
</div>
</template>

<script setup lang="ts">
import { ref } from 'vue'
const src = ref<string | undefined>()
const showOptionsDialog = ref(false)
</script>

<style scoped>
img {
object-fit: cover;
width: 100%;
}
div {
width: 100%;
height: 100%;
}
</style>
1 change: 1 addition & 0 deletions src/types/widgets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ export enum WidgetType {
PowerSupply = 'PowerSupply',
VideoPlayer = 'VideoPlayer',
VideoRecorder = 'VideoRecorder',
ImageViewer = 'ImageViewer',
}

export type Widget = {
Expand Down
4 changes: 4 additions & 0 deletions src/views/WidgetsView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@
<template v-if="widget.component === WidgetType.VideoRecorder">
<VideoRecorder :widget="widget" />
</template>
<template v-if="widget.component === WidgetType.ImageViewer">
<ImageView :widget="widget" />
</template>
<!-- TODO: Use the line below instead of the 12 lines above -->
<!-- <component :is="componentFromType(widget.component)"></component> -->
</WidgetHugger>
Expand All @@ -65,6 +68,7 @@ import {
ref,
} from 'vue'
import ImageView from '@/components/widgets/ImageView.vue'
import { useWidgetManagerStore } from '@/stores/widgetManager'
import { WidgetType } from '@/types/widgets'
Expand Down

0 comments on commit 9f93964

Please sign in to comment.