Skip to content

Commit 351e33d

Browse files
feat: Accordion expand on load (#859) (#1583)
* feat: Setting up support for selected-index; history; and fix a few small styling bugs * feat: Adding variable hooks to pfe-layouts * feat: History in URL is working * feat: Adding multi-select to the expanded-index attribute * feat: Update documentation * feat: Updating baselines * feat: Update accordion header styles for disclosure to fix IE11 preview * feat: Update baseline for IE11 * feat: Updating disclosure regression * feat: Update accordion tests * feat: Uncomment out framework tests * feat: Update changelog; demo page * feat: Adding in spacing * feat: Update package-lock * feat: Add full-width demo example to pfe-band * feat: Update storybook * feat: Resolve failing tests on accordion; update storybook * feat: Update console log tests * feat: Resolve rounding error in pfe-card tests * feat: Resolving test errors * feat: Resolve pfelement console errors and content set inconsitencies * Apply suggestions from code review * feat: Update package-lock * Update CHANGELOG-1.x.md Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
1 parent 6db5178 commit 351e33d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+1447
-996
lines changed

CHANGELOG-1.x.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
# 1.7.0 (2021)
22

3+
- [](https://github.com/patternfly/patternfly-elements/commit/) feat: Accordion direct link / expand on load (#859)
4+
- [b57c5b0](https://github.com/patternfly/patternfly-elements/commit/b57c5b013acef370ba962b7796a870c37802a33f) feat: Adds Web Test Runner which will eventually replace Web Component Tester
35
- [20cb906](https://github.com/patternfly/patternfly-elements/commit/20cb906b5bf3d9340097170d6be7bdacbb4b12a5) fix: Updating PFElement.log (aka this.log) so it logs arrays and objects, instead of converting them to strings
4-
- [b57c5b0](https://github.com/patternfly/patternfly-elements/commit/b57c5b013acef370ba962b7796a870c37802a33f) feat: Adds Web Test Runner which will replace Web Component Tester
56

67
# 1.6.0 (2021-04-23)
78

elements/pfe-accordion/README.md

Lines changed: 64 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,16 @@
55
```
66
<pfe-accordion>
77
<pfe-accordion-header>
8-
<h2>Why do wizards need money if they could just create it?</h2>
8+
<h3>Consetetur sadipscing elitr?</h3>
99
</pfe-accordion-header>
1010
<pfe-accordion-panel>
11-
<p>There is legislation that decides what you can conjure and what you can not. Because things that you conjure out of thin air will not last, it is illegal in the wizarding world.</p>
11+
<p><a href="#">Lorem ipsum dolor sit amet</a>, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum.</p>
1212
</pfe-accordion-panel>
1313
<pfe-accordion-header>
14-
<h2>Why doesn't Harry have a portrait of his parents?</h2>
14+
<h3>Labore et dolore magna aliquyam erat?</h3>
1515
</pfe-accordion-header>
1616
<pfe-accordion-panel>
17-
<p>The characters in the portraits are not actually ghosts. They mainly are there just to repeat common phrases or serve as a general representation of the individual they depict. A portrait of his parents would not be of much help to Harry.</p>
17+
<p><a href="#">Lorem ipsum dolor sit amet</a>, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum.</p>
1818
</pfe-accordion-panel>
1919
</pfe-accordion>
2020
```
@@ -27,12 +27,11 @@ Place the `pfe-accordion-header` and `pfe-accordion-panel` elements here.
2727

2828
### Default slot in pfe-accordion-header
2929

30-
We expect the light DOM of the `pfe-accordion-header` to be a heading level tag
31-
(h1, h2, h3, h4, h5, h6)
30+
We expect the light DOM of the `pfe-accordion-header` to be a heading level tag (h1, h2, h3, h4, h5, h6). This content is copied into shadow DOM and so most external styles will not penetrate.
3231

3332
### Default slot in pfe-accordion-panel
3433

35-
Add the content for your accordion panel here.
34+
Add the content for your accordion panel here. This content remains in the light DOM; external styles will penetrate this region.
3635

3736
## Attributes
3837

@@ -47,6 +46,42 @@ This will override any context being passed from a parent component and will add
4746
**`disclosure`**
4847
If `pfe-accordion` has one `pfe-accordion-header`, it will get tagged with `disclosure="true"`. This applies a slightly different set of styles: chevron appears on the left side, the header has a single border on all four sides. Applying `disclosure="false"` to a `pfe-accordion` element containing only one header/panel pairing will set the element to display as a standard accordion.
4948

49+
**`history`**
50+
Updates window.history and the URL to create sharable links. With the `history` attribute, the accordion *must* have an `id`.
51+
52+
The URL pattern will be `?{id-of-tabs}={index-of-expanded-items}`. In the example
53+
below, selecting "Accordion 2" will update the URL as follows: `?lorem-ipsum=2`. The index value for the expanded items starts at 1.
54+
55+
```html
56+
<pfe-accordion history id="lorem-ipsum">
57+
<pfe-accordion-header>
58+
<h3>Accordion 1</h3>
59+
</pfe-accordion-header>
60+
<pfe-accordion-panel>
61+
<p>Accordion 1 panel content.</p>
62+
</pfe-accordion-panel>
63+
<pfe-accordion-header>
64+
<h3>Accordion 2</h3>
65+
</pfe-accordion-header>
66+
<pfe-accordion-panel>
67+
<p>Accordion 2 panel content.</p>
68+
</pfe-accordion-panel>
69+
</pfe-accordion>
70+
```
71+
72+
To expand multiple sets, you can dash separate indexes: `?lorem-ipsum=1-2`.
73+
74+
*Note:* This feature is not supported in IE11.
75+
76+
**`expanded-index`**
77+
Sets and reflects the currently expanded accordion indexes. Use commas to separate multiple indexes. The index value for the expanded items starts at 1.
78+
79+
```html
80+
<pfe-accordion expanded-index="2,3">
81+
...
82+
</pfe-accordion>
83+
```
84+
5085
## Events
5186

5287
### pfe-accordion:change
@@ -60,6 +95,28 @@ detail: {
6095
}
6196
```
6297

98+
## API
99+
100+
### toggle(index)
101+
102+
Accepts a 0-based index value (integer) for the set of accordion items to expand or collapse.
103+
104+
### expand(index)
105+
106+
Accepts a 0-based index value (integer) for the set of accordion items to expand.
107+
108+
### expandAll()
109+
110+
Expands all accordion items.
111+
112+
### collapse(index)
113+
114+
Accepts a 0-based index value (integer) for the set of accordion items to collapse.
115+
116+
### collapseAll()
117+
118+
Collapse all accordion items.
119+
63120
## Test
64121

65122
npm run test

elements/pfe-accordion/demo/demo.css

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@ section {
22
padding: 2rem;
33
}
44

5+
pfe-jump-links-nav {
6+
--pfe-accordion__panel-container--Padding: calc(var(--pfe-theme--container-spacer, 1rem) * 1.5);
7+
}
8+
59
.dark-background {
610
background-color: #252525;
711
--context: dark;

0 commit comments

Comments
 (0)