2026-09-10 17:13:36 +03:00
|
|
|
import { storeToRefs } from 'pinia'
|
2026-09-10 19:20:35 +03:00
|
|
|
import { computed, ref, watch } from 'vue'
|
2026-09-10 17:13:36 +03:00
|
|
|
|
|
|
|
|
import { useMergedConfigStore } from 'src/stores/merged_config.js'
|
|
|
|
|
|
|
|
|
|
export function useInterfaceSizes() {
|
|
|
|
|
const { mergedConfig } = storeToRefs(useMergedConfigStore())
|
|
|
|
|
|
|
|
|
|
// Getting the actual font size in pixels since UI might have
|
|
|
|
|
// a different scale
|
|
|
|
|
const fontSizeSetting = computed(() => mergedConfig.value.textSize)
|
|
|
|
|
const fontSize = ref(0)
|
|
|
|
|
const updateFontSize = () => {
|
|
|
|
|
const string = window
|
|
|
|
|
.getComputedStyle(document.body)
|
|
|
|
|
.getPropertyValue('font-size')
|
|
|
|
|
fontSize.value = Number.parseInt(string.slice(0, -2), 10) // remove the 'px'
|
|
|
|
|
}
|
|
|
|
|
// Update font size if user changed UI scale
|
|
|
|
|
watch(fontSizeSetting, updateFontSize, { immediate: true })
|
|
|
|
|
|
|
|
|
|
const navbarSize = computed(() => {
|
2026-09-10 19:20:35 +03:00
|
|
|
const string =
|
|
|
|
|
fontSize.value *
|
|
|
|
|
window.getComputedStyle(document.body).getPropertyValue('--navbarSize')
|
2026-09-10 17:13:36 +03:00
|
|
|
|
|
|
|
|
return fontSize.value * Number.parseInt(string.slice(0, -3), 10) // remove the 'rem'
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
const panelHeaderSize = computed(() => {
|
2026-09-10 19:20:35 +03:00
|
|
|
const string =
|
|
|
|
|
fontSize.value *
|
|
|
|
|
window
|
|
|
|
|
.getComputedStyle(document.body)
|
|
|
|
|
.getPropertyValue('--panelHeaderSize')
|
2026-09-10 17:13:36 +03:00
|
|
|
|
|
|
|
|
return fontSize.value * Number.parseInt(string.slice(0, -3), 10) // remove the 'rem'
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
return {
|
|
|
|
|
fontSize,
|
|
|
|
|
navbarSize,
|
|
|
|
|
panelHeaderSize,
|
|
|
|
|
}
|
|
|
|
|
}
|