mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-04-20 14:30:41 +00:00
## Summary Automated initial change, cleaned up manually. Please check the screenshot changes. Includes a11y updates to icon buttons. Doesn't hit the buttons in Desktop. ┆Issue is synchronized with this [Notion page](https://www.notion.so/PR-7649-WIP-Component-The-Rest-of-the-PrimeVue-buttons-2ce6d73d365081d68e06f200f1321267) by [Unito](https://www.unito.io) --------- Co-authored-by: GitHub Action <action@github.com> Co-authored-by: github-actions <github-actions@github.com> Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
104 lines
2.7 KiB
Vue
104 lines
2.7 KiB
Vue
<template>
|
|
<div class="space-y-4">
|
|
<div v-if="!hasBackgroundImage">
|
|
<label>
|
|
{{ $t('load3d.backgroundColor') }}
|
|
</label>
|
|
<input v-model="backgroundColor" type="color" class="w-full" />
|
|
</div>
|
|
|
|
<div>
|
|
<Checkbox v-model="showGrid" input-id="showGrid" binary name="showGrid" />
|
|
<label for="showGrid" class="pl-2">
|
|
{{ $t('load3d.showGrid') }}
|
|
</label>
|
|
</div>
|
|
|
|
<div v-if="!hasBackgroundImage && !disableBackgroundUpload">
|
|
<Button variant="secondary" class="w-full" @click="openImagePicker">
|
|
<i class="pi pi-image" />
|
|
{{ $t('load3d.uploadBackgroundImage') }}
|
|
</Button>
|
|
<input
|
|
ref="imagePickerRef"
|
|
type="file"
|
|
accept="image/*"
|
|
class="hidden"
|
|
@change="handleImageUpload"
|
|
/>
|
|
</div>
|
|
|
|
<div v-if="hasBackgroundImage" class="space-y-2">
|
|
<div class="flex gap-2">
|
|
<Button
|
|
:variant="backgroundRenderMode === 'tiled' ? 'primary' : 'secondary'"
|
|
class="flex-1"
|
|
@click="setBackgroundRenderMode('tiled')"
|
|
>
|
|
<i class="pi pi-th-large" />
|
|
{{ $t('load3d.tiledMode') }}
|
|
</Button>
|
|
<Button
|
|
:variant="
|
|
backgroundRenderMode === 'panorama' ? 'primary' : 'secondary'
|
|
"
|
|
class="flex-1"
|
|
@click="setBackgroundRenderMode('panorama')"
|
|
>
|
|
<i class="pi pi-globe" />
|
|
{{ $t('load3d.panoramaMode') }}
|
|
</Button>
|
|
</div>
|
|
<Button variant="secondary" class="w-full" @click="removeBackgroundImage">
|
|
<i class="pi pi-times" />
|
|
{{ $t('load3d.removeBackgroundImage') }}
|
|
</Button>
|
|
</div>
|
|
</div>
|
|
</template>
|
|
|
|
<script setup lang="ts">
|
|
import Checkbox from 'primevue/checkbox'
|
|
import { ref } from 'vue'
|
|
|
|
import Button from '@/components/ui/button/Button.vue'
|
|
|
|
const backgroundColor = defineModel<string>('backgroundColor')
|
|
const showGrid = defineModel<boolean>('showGrid')
|
|
const backgroundRenderMode = defineModel<'tiled' | 'panorama'>(
|
|
'backgroundRenderMode'
|
|
)
|
|
|
|
defineProps<{
|
|
hasBackgroundImage?: boolean
|
|
disableBackgroundUpload?: boolean
|
|
}>()
|
|
|
|
const emit = defineEmits<{
|
|
(e: 'updateBackgroundImage', file: File | null): void
|
|
}>()
|
|
|
|
const imagePickerRef = ref<HTMLInputElement | null>(null)
|
|
|
|
const openImagePicker = () => {
|
|
imagePickerRef.value?.click()
|
|
}
|
|
|
|
const handleImageUpload = (event: Event) => {
|
|
const input = event.target as HTMLInputElement
|
|
if (input.files && input.files[0]) {
|
|
emit('updateBackgroundImage', input.files[0])
|
|
}
|
|
|
|
input.value = ''
|
|
}
|
|
|
|
const removeBackgroundImage = () => {
|
|
emit('updateBackgroundImage', null)
|
|
}
|
|
|
|
const setBackgroundRenderMode = (mode: 'tiled' | 'panorama') => {
|
|
backgroundRenderMode.value = mode
|
|
}
|
|
</script>
|