-
Notifications
You must be signed in to change notification settings - Fork 375
[feat] integrate asset browser with widget system #5629
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
e142a27
ac559d5
0926b76
90e1bda
453d6a5
49f2ffd
434ecfe
2fc9598
d956b29
42450e3
6a69335
28f64b1
da358a1
908c8e4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,7 +12,7 @@ | |
:nav-items="availableCategories" | ||
> | ||
<template #header-icon> | ||
<i-lucide:folder class="size-4" /> | ||
<div class="icon-[lucide--folder] size-4" /> | ||
</template> | ||
<template #header-title>{{ $t('assetBrowser.browseAssets') }}</template> | ||
</LeftSidePanel> | ||
|
@@ -37,7 +37,7 @@ | |
</template> | ||
|
||
<script setup lang="ts"> | ||
import { computed } from 'vue' | ||
import { computed, provide } from 'vue' | ||
|
||
import SearchBox from '@/components/input/SearchBox.vue' | ||
import BaseModalLayout from '@/components/widget/layout/BaseModalLayout.vue' | ||
|
@@ -46,6 +46,7 @@ import AssetGrid from '@/platform/assets/components/AssetGrid.vue' | |
import type { AssetDisplayItem } from '@/platform/assets/composables/useAssetBrowser' | ||
import { useAssetBrowser } from '@/platform/assets/composables/useAssetBrowser' | ||
import type { AssetItem } from '@/platform/assets/schemas/assetSchema' | ||
import { OnCloseKey } from '@/types/widgetTypes' | ||
|
||
const props = defineProps<{ | ||
nodeType?: string | ||
|
@@ -61,35 +62,28 @@ const emit = defineEmits<{ | |
close: [] | ||
}>() | ||
|
||
// Use AssetBrowser composable for all business logic | ||
provide(OnCloseKey, props.onClose ?? (() => {})) | ||
|
||
const { | ||
searchQuery, | ||
selectedCategory, | ||
availableCategories, | ||
contentTitle, | ||
filteredAssets, | ||
selectAsset | ||
selectAssetWithCallback | ||
} = useAssetBrowser(props.assets) | ||
|
||
// Dialog controls panel visibility via prop | ||
const shouldShowLeftPanel = computed(() => { | ||
return props.showLeftPanel ?? true | ||
}) | ||
|
||
// Handle close button - call both the prop callback and emit the event | ||
const handleClose = () => { | ||
props.onClose?.() | ||
emit('close') | ||
} | ||
|
||
// Handle asset selection and emit to parent | ||
const handleAssetSelectAndEmit = (asset: AssetDisplayItem) => { | ||
selectAsset(asset) // This logs the selection for dev mode | ||
emit('asset-select', asset) // Emit the full asset object | ||
|
||
// Call prop callback if provided | ||
if (props.onSelect) { | ||
props.onSelect(asset.name) // Use asset name as the asset path | ||
} | ||
const handleAssetSelectAndEmit = async (asset: AssetDisplayItem) => { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: (This does not need to be done in this PR). We can consider moving the selection to the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Will look at this in follow up. |
||
emit('asset-select', asset) | ||
await selectAssetWithCallback(asset.id, props.onSelect) | ||
} | ||
</script> |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,7 +14,7 @@ | |
'bg-ivory-100 border border-gray-300 dark-theme:bg-charcoal-400 dark-theme:border-charcoal-600', | ||
'hover:transform hover:-translate-y-0.5 hover:shadow-lg hover:shadow-black/10 hover:border-gray-400', | ||
'dark-theme:hover:shadow-lg dark-theme:hover:shadow-black/30 dark-theme:hover:border-charcoal-700', | ||
'focus:outline-none focus:ring-2 focus:ring-blue-500 dark-theme:focus:ring-blue-400' | ||
'focus:outline-none focus:transform focus:-translate-y-0.5 focus:shadow-lg focus:shadow-black/10 dark-theme:focus:shadow-black/30' | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. more in line with current design system. |
||
], | ||
// Div-specific styles | ||
!interactive && [ | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just helper functions for myself.