Skip to content

Commit 6cfcb2b

Browse files
committed
ui: SelectButton on ProofKind
1 parent 755eed7 commit 6cfcb2b

File tree

4 files changed

+39
-8
lines changed

4 files changed

+39
-8
lines changed

ui/app/components/Kani.vue

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
<script setup lang="ts">
22
import { ofetch } from "ofetch";
3-
import { URL_MERGE_DIFF, MergeKaniColumns, multiSort, type VecMergeHashKaniList, FILTERS, ProofKind } from "~/shared/utils/kani";
4-
import { useStyleStore } from "~/stores/style";
3+
import type { SelectButtonPassThroughMethodOptions } from "primevue";
4+
import { URL_MERGE_DIFF, MergeKaniColumns, multiSort, type VecMergeHashKaniList, FILTERS, ProofKind, optionsProofKind } from "~/shared/utils/kani";
5+
import { useDarkStore, useStyleStore } from "~/stores/style";
56
67
// Compute absolute scrollHeight for DataTable.
7-
const { viewportHeight } = storeToRefs(useStyleStore());
8+
const { color, viewportHeight } = storeToRefs(useStyleStore());
9+
const { fontColor } = storeToRefs(useDarkStore());
810
911
const raw = ref<VecMergeHashKaniList>([]);
1012
// Download JSON
@@ -23,6 +25,8 @@ const counts = computed<{ total: number, standard: number, contract: number }>((
2325
raw.value.filter(ele => ele.proof_kind === ProofKind.Contract).length,
2426
}));
2527
28+
const selectedProofKind = ref<string[]>([]);
29+
watch(selectedProofKind, val => console.log(val));
2630
2731
// Set title
2832
useHead({ title: "Verify Rust Std - Kani" });
@@ -37,7 +41,18 @@ useHead({ title: "Verify Rust Std - Kani" });
3741

3842
<template #header>
3943
<div class="flex justify-between items-center">
40-
<div>
44+
<div class="flex justify-between items-center gap-1">
45+
Proof Kind:
46+
<SelectButton v-model="selectedProofKind" :options="optionsProofKind" :option-label="x => x" multiple :pt="{
47+
pcToggleButton: {
48+
content: (opt: SelectButtonPassThroughMethodOptions) => ({
49+
style: {
50+
background: opt.context.active ? color.green : 'transparent',
51+
color: fontColor
52+
}
53+
})
54+
}
55+
}" />
4156
</div>
4257
<div>
4358
<IconField>

ui/app/layouts/default.vue

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,23 @@
11
<script setup lang="ts">
2+
import { useDarkStore } from '~/stores/style';
23
34
const CLASS_DARK = "my-app-dark";
45
const KEY = "theme";
56
const DARK = "dark";
67
78
const dark = ref(false);
9+
const storeDark = useDarkStore();
810
911
function toggleTheme() {
1012
const isDark = document.documentElement.classList.toggle(CLASS_DARK);
1113
dark.value = isDark;
14+
storeDark.setFontColor(isDark);
1215
localStorage.setItem(KEY, isDark ? DARK : "light");
1316
}
1417
15-
if (localStorage.getItem(KEY) === DARK) {
18+
const isInitDark = localStorage.getItem(KEY) === DARK;
19+
storeDark.setFontColor(isInitDark);
20+
if (isInitDark) {
1621
document.documentElement.classList.add(CLASS_DARK);
1722
dark.value = true;
1823
}

ui/app/shared/utils/kani.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,3 +59,5 @@ export const FILTERS = {
5959
},
6060
fields: ["file", "func"]
6161
};
62+
63+
export const optionsProofKind: string[] = [ProofKind.Standard, ProofKind.Contract];

ui/app/stores/style.ts

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
export const useStyleStore = defineStore("style", () => {
22
const color = reactive({
33
green: "green", red: "red", grey: "grey",
4-
topButton: "white", orange: "orange", orange_light: "orange",
4+
primary: "white", orange: "orange", orange_light: "orange",
55
});
66
const viewportHeight = ref(800);
77

@@ -10,10 +10,10 @@ export const useStyleStore = defineStore("style", () => {
1010
const styles = window.getComputedStyle(document.documentElement);
1111

1212
// Set color shortcuts.
13-
color.green = styles.getPropertyValue("--p-emerald-500").trim();
13+
color.green = styles.getPropertyValue("--p-emerald-300").trim();
1414
color.red = styles.getPropertyValue("--p-red-500").trim();
1515
color.grey = styles.getPropertyValue("--p-gray-400").trim();
16-
color.topButton = styles.getPropertyValue("--p-button-primary-background").trim();
16+
color.primary = styles.getPropertyValue("--p-button-primary-background").trim();
1717
color.orange_light = styles.getPropertyValue("--p-orange-400").trim();
1818
color.orange = styles.getPropertyValue("--p-orange-500").trim();
1919

@@ -27,3 +27,12 @@ export const useStyleStore = defineStore("style", () => {
2727
return { color, viewportHeight }
2828
});
2929

30+
/** Styling based on dark theme mode. */
31+
export const useDarkStore = defineStore('dark', {
32+
state: () => ({ fontColor: "black" }),
33+
actions: {
34+
setFontColor(isDark: boolean) {
35+
this.fontColor = isDark ? "grey" : "black"
36+
}
37+
}
38+
});

0 commit comments

Comments
 (0)