Skip to content

Commit 8d9c21e

Browse files
committed
ui: compute topbarHeight & restHeight
1 parent 42c2fc5 commit 8d9c21e

File tree

3 files changed

+21
-15
lines changed

3 files changed

+21
-15
lines changed

ui/app/components/Kani.vue

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@ import { ofetch } from "ofetch";
33
import { URL_MERGE_DIFF, MergeKaniColumns, multiSort, type VecMergeHashKaniList, FILTERS, ProofKind } from "~/shared/utils/kani";
44
import { useStyleStore } from "~/stores/style";
55
6-
const { viewportHeight } = storeToRefs(useStyleStore());
6+
const { restHeight } = storeToRefs(useStyleStore());
7+
watch(restHeight, val => console.log(val));
78
89
const raw = ref<VecMergeHashKaniList>([]);
910
// Download JSON
@@ -30,7 +31,7 @@ useHead({ title: "Verify Rust Std - Kani" });
3031
<template>
3132
<DataTable :value="raw" paginator :rows="5" :rowsPerPageOptions="[5, 10, 20, 50]" sortMode="multiple" removableSort
3233
v-model:multi-sort-meta="multiSort" stripedRows tableStyle="min-width: 20rem" tableClass="m-2"
33-
:scrollHeight="`${(viewportHeight - 100) * 0.8}px`" v-model:filters="filters" :globalFilterFields="FILTERS.fields"
34+
:scrollHeight="`${restHeight - 10}px`" v-model:filters="filters" :globalFilterFields="FILTERS.fields"
3435
currentPageReportTemplate="{first} to {last} of {totalRecords}">
3536

3637
<template #header>

ui/app/layouts/default.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ if (localStorage.getItem(KEY) === DARK) {
2121

2222
<template>
2323
<div>
24-
<div class="flex justify-between p-2">
24+
<div class="flex justify-between p-2" id="topbar">
2525
<div></div>
2626
<div>
2727
<Button :icon='dark ? "pi pi-sun" : "pi pi-moon"' @click="toggleTheme" severity="contrast" raised />

ui/app/stores/style.ts

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,34 @@
1-
export const useStyleStore = defineStore('style', () => {
1+
export const useStyleStore = defineStore("style", () => {
22
const color = reactive({
33
green: "green", red: "red", grey: "grey",
44
topButton: "white", orange: "orange", orange_light: "orange",
55
});
66
const viewportHeight = ref(800);
7+
const topbarHeight = ref(800);
8+
const restHeight = computed(() => viewportHeight.value - topbarHeight.value);
79

810
onMounted(() => {
9-
// 获取元素的计算后的样式
11+
// Get styles after computation.
1012
const styles = window.getComputedStyle(document.documentElement);
1113

12-
// 获取CSS变量的值
13-
color.green = styles.getPropertyValue('--p-emerald-500').trim();
14-
color.red = styles.getPropertyValue('--p-red-500').trim();
15-
color.grey = styles.getPropertyValue('--p-gray-400').trim();
16-
color.topButton = styles.getPropertyValue('--p-button-primary-background').trim();
17-
color.orange_light = styles.getPropertyValue('--p-orange-400').trim();
18-
color.orange = styles.getPropertyValue('--p-orange-500').trim();
14+
// Set color shortcuts.
15+
color.green = styles.getPropertyValue("--p-emerald-500").trim();
16+
color.red = styles.getPropertyValue("--p-red-500").trim();
17+
color.grey = styles.getPropertyValue("--p-gray-400").trim();
18+
color.topButton = styles.getPropertyValue("--p-button-primary-background").trim();
19+
color.orange_light = styles.getPropertyValue("--p-orange-400").trim();
20+
color.orange = styles.getPropertyValue("--p-orange-500").trim();
1921

20-
// 视窗高度
22+
// Get heights
2123
viewportHeight.value = window.innerHeight;
22-
window.addEventListener('resize', () => {
24+
topbarHeight.value = document.getElementById("topbar")?.offsetHeight ?? 800;
25+
window.addEventListener("resize", () => {
2326
viewportHeight.value = window.innerHeight;
27+
topbarHeight.value = document.getElementById("topbar")?.offsetHeight ?? 800;
2428
});
29+
2530
});
2631

27-
return { color, viewportHeight }
32+
return { color, viewportHeight, topbarHeight, restHeight }
2833
});
2934

0 commit comments

Comments
 (0)