From 9e97b0ebd6cc6c251b3e1afa0d7b11fd5f7cdf3a Mon Sep 17 00:00:00 2001 From: Vahid Menu Nesro Date: Thu, 16 Nov 2023 06:34:36 +0100 Subject: [PATCH 1/7] feat: sd-accordion refresh --- .../accordion-group/accordion-group.stories.ts | 16 ++++++++++++++++ .../accordion-group/accordion-group.ts | 6 +++++- .../src/components/accordion/accordion.ts | 11 ++++++++--- 3 files changed, 29 insertions(+), 4 deletions(-) diff --git a/packages/components/src/components/accordion-group/accordion-group.stories.ts b/packages/components/src/components/accordion-group/accordion-group.stories.ts index 6685345a7..991a00ba5 100644 --- a/packages/components/src/components/accordion-group/accordion-group.stories.ts +++ b/packages/components/src/components/accordion-group/accordion-group.stories.ts @@ -50,6 +50,22 @@ export const CloseOthers = { } }; +/** + * Use 'background' property to set the background color to 'white', 'neutral-100', or 'primary-100'. + */ +export const Background = { + parameters: { controls: { exclude: 'background' } }, + render: (args: any) => { + return generateTemplate({ + axis: { + y: { type: 'attribute', name: 'background' } + }, + args, + constants: { type: 'template', name: 'width', value: '
%TEMPLATE%
' } + }); + } +}; + /** * Part of sd-accordion-group */ diff --git a/packages/components/src/components/accordion-group/accordion-group.ts b/packages/components/src/components/accordion-group/accordion-group.ts index 165505c0d..d635966ca 100644 --- a/packages/components/src/components/accordion-group/accordion-group.ts +++ b/packages/components/src/components/accordion-group/accordion-group.ts @@ -24,6 +24,9 @@ export default class SdAccordionGroup extends SolidElement { /** Closes other accordions. */ @property({ attribute: 'close-others', type: Boolean }) closeOthers = false; + /** Set the background color of the accordion group. */ + @property({ reflect: true }) background: 'white' | 'neutral-100' | 'primary-100' = 'white'; + connectedCallback() { super.connectedCallback(); this.addEventListener('sd-show', this.handleAccordionShow); @@ -52,7 +55,7 @@ export default class SdAccordionGroup extends SolidElement { render() { return html` -
+
`; @@ -64,6 +67,7 @@ export default class SdAccordionGroup extends SolidElement { css` :host { display: block; + background-color: var(--sd-color-white); } ::slotted(sd-accordion:not(:first-of-type)) { margin-top: -1px; diff --git a/packages/components/src/components/accordion/accordion.ts b/packages/components/src/components/accordion/accordion.ts index 26937f9d9..4dfdc5d38 100644 --- a/packages/components/src/components/accordion/accordion.ts +++ b/packages/components/src/components/accordion/accordion.ts @@ -150,13 +150,12 @@ export default class SdAccordion extends SolidElement { render() { return html` -
+