Skip to content

Commit

Permalink
edit-mode: Resize mini-widget placeholders if they overflow container
Browse files Browse the repository at this point in the history
  • Loading branch information
rafaellehmkuhl authored and patrickelectric committed Sep 24, 2024
1 parent c3a1240 commit 227a2df
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions src/components/EditMenu.vue
Original file line number Diff line number Diff line change
Expand Up @@ -520,6 +520,7 @@
>
<div
v-for="miniWidget in availableMiniWidgetTypes"
:ref="(el) => (miniWidgetContainers[miniWidget.component] = el as HTMLElement)"
:key="miniWidget.hash"
class="flex flex-col items-center justify-between rounded-md bg-[#273842] hover:brightness-125 h-[90%] aspect-square cursor-pointer elevation-4 overflow-clip"
>
Expand Down Expand Up @@ -867,6 +868,24 @@ onMounted(() => {
const widgetMode = ref('Regular widgets' || 'Mini widgets')
// Resize mini widgets so they fit the layout when the widget mode is set to mini widgets
const miniWidgetContainers = ref<Record<string, HTMLElement>>({})
watch(widgetMode, () => {
if (widgetMode.value !== 'Mini widgets') return
nextTick(() => {
Object.values(miniWidgetContainers.value).forEach((element) => {
if (element.scrollWidth > element.clientWidth) {
let scale = 1
while (element.scrollWidth > element.clientWidth) {
scale -= 0.01
const actualElement = element.children[1] as HTMLElement
actualElement.style.scale = `${scale}`
}
}
})
})
})
const availableVehicleTypes = computed(() => Object.keys(MavType))
const vehicleTypesAssignedToCurrentProfile = computed({
Expand Down

0 comments on commit 227a2df

Please sign in to comment.