Skip to content

Commit

Permalink
Open accordion when media is print (#1363)
Browse files Browse the repository at this point in the history
* Adjust CSS so rule isn't overwritten

* test chromatic media print

* add story for check media print

* update testing settings
  • Loading branch information
ataker authored Oct 10, 2024
1 parent a423ac7 commit 1ec1cb9
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 7 deletions.
31 changes: 30 additions & 1 deletion packages/storybook/stories/va-accordion-uswds.stories.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -351,4 +351,33 @@ Internationalization.args = {
export const ManyAccordions = ManyItemsTemplate.bind(null);
ManyAccordions.args = {
...defaultArgs,
};
};


const PrintTemplate = args => (
<va-accordion {...args}>
<va-accordion-item id="first" header="First Item">
<p>
This story is for the Design System Team to be able to test the
accordion items being opened when the page they're on is being printed.
</p>
</va-accordion-item>
<va-accordion-item id="second" header="Second Item">
<p>
Accordion items will always open when being printed.
</p>
</va-accordion-item>
</va-accordion>
);

// todo: after upgrading to storybook 8 we can hide this story from the sidebar: https://storybook.js.org/docs/writing-stories/tags
export const PrintAccordion = PrintTemplate.bind(null);
PrintAccordion.args = {
...defaultArgs,
};
PrintAccordion.parameters = {
chromatic: {
media: 'print'
},

}
Original file line number Diff line number Diff line change
Expand Up @@ -64,15 +64,15 @@ button {
max-width: 64ex;
}

:host(:not([open])) #content,
:host([open='false']) #content {
display: none;
}

/* overrides hidden attribute on #content */
@media print {
:host(:not([open])) #content,
:host([open='false']) #content {
display: block;
}
}

:host(:not([open])) #content,
:host([open='false']) #content {
display: none;
}
}
1 change: 1 addition & 0 deletions packages/web-components/stencil.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ export const config: Config = {
}
],
testing: {
browserArgs: ['--no-sandbox', '--disable-setuid-sandbox'],
moduleNameMapper: {
'^.+.(svg)$': 'jest-transformer-svg',
},
Expand Down

0 comments on commit 1ec1cb9

Please sign in to comment.