From e4d27eb3f6ec53fece6e8b8d78e8eb984db4c684 Mon Sep 17 00:00:00 2001 From: Dannon Baker Date: Thu, 9 Nov 2023 09:02:13 -0500 Subject: [PATCH] Refactor Heading collapse property to be open/closed/none, to avoid having separate 'collapsible' and 'collapsed' props. --- client/src/components/Common/Heading.vue | 44 ++++++++++++------- .../src/components/JobMetrics/AwsEstimate.vue | 4 +- .../CarbonEmissions/CarbonEmissions.vue | 2 +- 3 files changed, 32 insertions(+), 18 deletions(-) diff --git a/client/src/components/Common/Heading.vue b/client/src/components/Common/Heading.vue index 199446496de0..6e889839aae3 100644 --- a/client/src/components/Common/Heading.vue +++ b/client/src/components/Common/Heading.vue @@ -2,21 +2,25 @@ import { FontAwesomeIcon } from "@fortawesome/vue-fontawesome"; import { computed } from "vue"; -const props = defineProps<{ - h1?: boolean; - h2?: boolean; - h3?: boolean; - h4?: boolean; - h5?: boolean; - h6?: boolean; - bold?: boolean; - separator?: boolean; - inline?: boolean; - size?: "xl" | "lg" | "md" | "sm" | "text"; - icon?: string | [string, string]; - collapsible?: boolean; - collapsed?: boolean; -}>(); +const props = withDefaults( + defineProps<{ + h1?: boolean; + h2?: boolean; + h3?: boolean; + h4?: boolean; + h5?: boolean; + h6?: boolean; + bold?: boolean; + separator?: boolean; + inline?: boolean; + size?: "xl" | "lg" | "md" | "sm" | "text"; + icon?: string | [string, string]; + collapse?: "open" | "closed" | "none"; + }>(), + { + collapse: "none", + } +); defineEmits(["click"]); @@ -24,6 +28,14 @@ const sizeClass = computed(() => { return `h-${props.size ?? "lg"}`; }); +const collapsible = computed(() => { + return props.collapse !== "none"; +}); + +const collapsed = computed(() => { + return props.collapse === "closed"; +}); + const element = computed(() => { for (const key of ["h1", "h2", "h3", "h4", "h5", "h6"]) { if (props[key as keyof typeof props]) { @@ -39,7 +51,7 @@ const element = computed(() => {
diff --git a/client/src/components/JobMetrics/AwsEstimate.vue b/client/src/components/JobMetrics/AwsEstimate.vue index ae8e4a686609..76170db0e990 100644 --- a/client/src/components/JobMetrics/AwsEstimate.vue +++ b/client/src/components/JobMetrics/AwsEstimate.vue @@ -56,7 +56,9 @@ const computedAwsEstimate = computed(() => {