From ec57b73244eaf0bb4a825afcd9af7ca7377bc04e Mon Sep 17 00:00:00 2001 From: Steven Malaihollo Date: Fri, 26 Apr 2024 17:03:14 +0200 Subject: [PATCH 1/3] Add `open` option to Accordion --- .../src/components/BccAccordion/BccAccordion.stories.ts | 8 ++++++++ .../src/components/BccAccordion/BccAccordion.vue | 5 +++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/design-library/src/components/BccAccordion/BccAccordion.stories.ts b/design-library/src/components/BccAccordion/BccAccordion.stories.ts index f982d576..5b523628 100644 --- a/design-library/src/components/BccAccordion/BccAccordion.stories.ts +++ b/design-library/src/components/BccAccordion/BccAccordion.stories.ts @@ -72,6 +72,14 @@ Example.parameters = { }, }; +export const WithOpened = Template.bind({}); +WithOpened.args = { + title: "Example Accordion was expanded once the page was loaded", + variant: "desktop", + size: "base", + open: true, +}; + const TempWithPin: StoryFn = (args) => ({ components: { BccAccordion }, setup() { diff --git a/design-library/src/components/BccAccordion/BccAccordion.vue b/design-library/src/components/BccAccordion/BccAccordion.vue index 7b117a26..32d53c78 100644 --- a/design-library/src/components/BccAccordion/BccAccordion.vue +++ b/design-library/src/components/BccAccordion/BccAccordion.vue @@ -17,6 +17,7 @@ const sizes = { type Props = { title: string; + open?: boolean; subtitle?: string; variant?: keyof typeof variants; size?: keyof typeof sizes; @@ -25,7 +26,7 @@ type Props = { pin?: InstanceType["$props"]; }; -withDefaults(defineProps(), { +const props = withDefaults(defineProps(), { title: "", subtitle: "", variant: "readonly", @@ -35,7 +36,7 @@ withDefaults(defineProps(), { pin: undefined, }); -const isOpen = ref(false); +const isOpen = ref(props.open ?? false);