mirror of
https://github.com/haexhub/haex-hub.git
synced 2025-12-16 22:20:51 +01:00
Improve desktop grid positioning and spacing
- Increase icon spacing from 20px to 30px padding - Add vertical grid offset (-30px) to start grid higher - Remove screen-size dependent grid columns/rows (now fully dynamic) - Fix dropzone visualization to use consistent snapToGrid function - Clean up unused UI store dependencies
This commit is contained in:
@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "haex-hub",
|
"name": "haex-hub",
|
||||||
"private": true,
|
"private": true,
|
||||||
"version": "0.1.8",
|
"version": "0.1.9",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "nuxt build",
|
"build": "nuxt build",
|
||||||
|
|||||||
@ -301,7 +301,7 @@ const { x: mouseX, y: mouseY } = useMouse()
|
|||||||
const dropTargetZone = computed(() => {
|
const dropTargetZone = computed(() => {
|
||||||
if (!isDragging.value) return null
|
if (!isDragging.value) return null
|
||||||
|
|
||||||
// Use the actual icon position during drag, not the mouse position
|
// Use the actual icon position during drag
|
||||||
const iconX = currentDraggedItem.x
|
const iconX = currentDraggedItem.x
|
||||||
const iconY = currentDraggedItem.y
|
const iconY = currentDraggedItem.y
|
||||||
|
|
||||||
@ -313,11 +313,14 @@ const dropTargetZone = computed(() => {
|
|||||||
currentDraggedItem.height || undefined,
|
currentDraggedItem.height || undefined,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// Show dropzone at snapped position with grid cell size
|
||||||
|
const cellSize = desktopStore.gridCellSize
|
||||||
|
|
||||||
return {
|
return {
|
||||||
x: snapped.x,
|
x: snapped.x,
|
||||||
y: snapped.y,
|
y: snapped.y,
|
||||||
width: currentDraggedItem.width || desktopStore.gridCellSize,
|
width: currentDraggedItem.width || cellSize,
|
||||||
height: currentDraggedItem.height || desktopStore.gridCellSize,
|
height: currentDraggedItem.height || cellSize,
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
@ -24,8 +24,6 @@ export const useDesktopStore = defineStore('desktopStore', () => {
|
|||||||
const workspaceStore = useWorkspaceStore()
|
const workspaceStore = useWorkspaceStore()
|
||||||
const { currentWorkspace } = storeToRefs(workspaceStore)
|
const { currentWorkspace } = storeToRefs(workspaceStore)
|
||||||
const { $i18n } = useNuxtApp()
|
const { $i18n } = useNuxtApp()
|
||||||
const uiStore = useUiStore()
|
|
||||||
const { isSmallScreen } = storeToRefs(uiStore)
|
|
||||||
const deviceStore = useDeviceStore()
|
const deviceStore = useDeviceStore()
|
||||||
const settingsStore = useVaultSettingsStore()
|
const settingsStore = useVaultSettingsStore()
|
||||||
|
|
||||||
@ -69,33 +67,30 @@ export const useDesktopStore = defineStore('desktopStore', () => {
|
|||||||
iconSizePreset.value = preset
|
iconSizePreset.value = preset
|
||||||
}
|
}
|
||||||
|
|
||||||
// Reactive grid settings based on screen size
|
|
||||||
const effectiveGridColumns = computed(() => {
|
|
||||||
return isSmallScreen.value ? 4 : 8
|
|
||||||
})
|
|
||||||
|
|
||||||
const effectiveGridRows = computed(() => {
|
|
||||||
return isSmallScreen.value ? 5 : 6
|
|
||||||
})
|
|
||||||
|
|
||||||
const effectiveIconSize = computed(() => {
|
const effectiveIconSize = computed(() => {
|
||||||
return iconSizePresetValues[iconSizePreset.value]
|
return iconSizePresetValues[iconSizePreset.value]
|
||||||
})
|
})
|
||||||
|
|
||||||
// Calculate grid cell size based on icon size
|
// Calculate grid cell size based on icon size
|
||||||
const gridCellSize = computed(() => {
|
const gridCellSize = computed(() => {
|
||||||
// Add padding around icon (20px extra for spacing)
|
// Add padding around icon (30px extra for spacing)
|
||||||
return effectiveIconSize.value + 20
|
return effectiveIconSize.value + 30
|
||||||
})
|
})
|
||||||
|
|
||||||
|
// Grid offsets for start position (negative = move grid up)
|
||||||
|
const gridOffsetY = -30 // Start grid 30px higher
|
||||||
|
|
||||||
// Snap position to grid (centers icon in cell)
|
// Snap position to grid (centers icon in cell)
|
||||||
// iconWidth and iconHeight are optional - if provided, they're used for centering
|
// iconWidth and iconHeight are optional - if provided, they're used for centering
|
||||||
const snapToGrid = (x: number, y: number, iconWidth?: number, iconHeight?: number) => {
|
const snapToGrid = (x: number, y: number, iconWidth?: number, iconHeight?: number) => {
|
||||||
const cellSize = gridCellSize.value
|
const cellSize = gridCellSize.value
|
||||||
|
|
||||||
|
// Adjust y for grid offset
|
||||||
|
const adjustedY = Math.max(0, y - gridOffsetY)
|
||||||
|
|
||||||
// Calculate which grid cell the position falls into
|
// Calculate which grid cell the position falls into
|
||||||
const col = Math.floor(x / cellSize)
|
const col = Math.floor(x / cellSize)
|
||||||
const row = Math.floor(y / cellSize)
|
const row = Math.floor(adjustedY / cellSize)
|
||||||
|
|
||||||
// Use provided dimensions or fall back to cell size
|
// Use provided dimensions or fall back to cell size
|
||||||
const actualIconWidth = iconWidth || cellSize
|
const actualIconWidth = iconWidth || cellSize
|
||||||
@ -113,7 +108,7 @@ export const useDesktopStore = defineStore('desktopStore', () => {
|
|||||||
|
|
||||||
return {
|
return {
|
||||||
x: col * cellSize + paddingX,
|
x: col * cellSize + paddingX,
|
||||||
y: row * cellSize + paddingY,
|
y: row * cellSize + paddingY + gridOffsetY,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -439,8 +434,6 @@ export const useDesktopStore = defineStore('desktopStore', () => {
|
|||||||
iconSizePreset,
|
iconSizePreset,
|
||||||
syncDesktopIconSizeAsync,
|
syncDesktopIconSizeAsync,
|
||||||
updateDesktopIconSizeAsync,
|
updateDesktopIconSizeAsync,
|
||||||
effectiveGridColumns,
|
|
||||||
effectiveGridRows,
|
|
||||||
effectiveIconSize,
|
effectiveIconSize,
|
||||||
gridCellSize,
|
gridCellSize,
|
||||||
snapToGrid,
|
snapToGrid,
|
||||||
|
|||||||
Reference in New Issue
Block a user