From 0ae37f26bd5947ea253458f908dafcf5c2de8062 Mon Sep 17 00:00:00 2001 From: Ben Munoz Date: Sun, 6 Oct 2024 16:22:10 -0400 Subject: [PATCH 1/2] feat: accordion section and accordion toggle button component docs --- .../zero-core/modules/accordion/components.md | 72 +++++++++++++++++-- .../stores/use-zero-accordion-store.md | 35 --------- .../components/zero-accordion-section.vue | 33 ++++++++- .../zero-accordion-toggle-button.vue | 25 ++++++- .../stores/use-zero-accordion-store.js | 2 +- 5 files changed, 122 insertions(+), 45 deletions(-) delete mode 100644 packages/docs/content/zero-core/modules/accordion/stores/use-zero-accordion-store.md diff --git a/packages/docs/content/zero-core/modules/accordion/components.md b/packages/docs/content/zero-core/modules/accordion/components.md index 3400fe2..df38026 100644 --- a/packages/docs/content/zero-core/modules/accordion/components.md +++ b/packages/docs/content/zero-core/modules/accordion/components.md @@ -2,13 +2,39 @@ # Zero Accordion Section - +A single accordion section comprised of a header and content that expands and collapses when the header is clicked. ## Props | Prop | type | description | values | | ---- | ---- | ----------- | ------ | -| `accordionId` | string | | | +| `accordionId` | string | The ID of this section's parent accordion. | | + +## Computed properties + +#### accordion() + + +Returns the parent accordion of this section from the [accordions](/zero-core/modules/accordion/store#accordions) array in the accordion store. + + + - **returns:** `Object` + +#### active() + + +Returns an array of active sections in this [accordion](/zero-core/modules/accordion/components#zero-accordion). Each section is referenced by a Unique ID set from `instance.uid` where instance is given by the `getCurrentInstance()` composable. + + + - **returns:** `[number]` + +#### open() + + +Returns the open/expanded state of this section as a boolean; true for open, false for closed. + + + - **returns:** `boolean` ## Slots @@ -17,27 +43,57 @@ **name:** `header` **scoped:** `false` + +Header content for each section. This content is wrapped in a clickable div when will toggle the section's expanded state. + #### Content **name:** `content` **scoped:** `false` + +Collapsible content for each section. The content slot requires a single root HTML element to animate correctly. + ## Methods #### toggle() + +Toggles the expanded state of this section using the accordion store's [toggleAccordionSection](/zero-core/modules/accordion/store#toggleaccordionsection) method. + #### setHeight() -# Zero Accordion Toggle Button +Calculates and sets the height of the accordion section content. Called every time the [open](/zero-core/modules/accordion/components#open) state changes using a watcher. + +# Zero Accordion Toggle Button +An instance of the [zeroButton](/zero-core/modules/button/components) that expands and collapses all accordion sections of its associated accordion at once. ## Props | Prop | type | description | values | | ---- | ---- | ----------- | ------ | -| `accordionId` | string | | | +| `accordionId` | string | The ID of the target accordion for this component. | | + +## Computed properties + +#### accordion() + + +Returns the accordion associated with this component from the [accordions](/zero-core/modules/accordion/store#accordions) array in the accordion store. + + + - **returns:** `Object` + +#### allSectionsOpen() + + +A boolean indicating if all the sections belonging to this component's accordion are open or not. True if all are open, false if otherwise. + + + - **returns:** `boolean` ## Slots @@ -46,14 +102,20 @@ **name:** `default` **scoped:** `true` + +Button content + | binding | type | description | | ------- | ---- | ----------- | -| `all-sections-open` | | | +| `all-sections-open` | `mixed` | Binds the [allSectionsOpen](/zero-core/modules/accordion/components#allsectionsopen) computed prop to the slot. | ## Methods #### toggleAllAccordionSections() + +Called when the button is clicked. This method subsequently calls the [toggleAllSections](/zero-core/modules/accordion/store#toggleallsections) method from the accordion store. Sets the [zeroButton](/zero-core/modules/button/components) component instance to loading: `false`. + # Zero Accordion diff --git a/packages/docs/content/zero-core/modules/accordion/stores/use-zero-accordion-store.md b/packages/docs/content/zero-core/modules/accordion/stores/use-zero-accordion-store.md deleted file mode 100644 index 589fa7f..0000000 --- a/packages/docs/content/zero-core/modules/accordion/stores/use-zero-accordion-store.md +++ /dev/null @@ -1,35 +0,0 @@ -## Functions - -
-
setAccordion()
-
-
removeAccordion()
-
-
setAccordionSection()
-
-
toggleAccordionSection()
-
-
toggleAllSections()
-
-
- - - -## setAccordion() -**Kind**: global function - - -## removeAccordion() -**Kind**: global function - - -## setAccordionSection() -**Kind**: global function - - -## toggleAccordionSection() -**Kind**: global function - - -## toggleAllSections() -**Kind**: global function diff --git a/packages/zero-core/modules/accordion/components/zero-accordion-section.vue b/packages/zero-core/modules/accordion/components/zero-accordion-section.vue index 4c4bb7a..0c54b73 100644 --- a/packages/zero-core/modules/accordion/components/zero-accordion-section.vue +++ b/packages/zero-core/modules/accordion/components/zero-accordion-section.vue @@ -8,13 +8,13 @@ :class="['accordion-header', { open }]" @click="toggleSection" @keydown.enter="toggleSection"> - +
- +
@@ -22,11 +22,17 @@