Skip to content

Commit 60b9047

Browse files
authored
Merge pull request #346 from patternfly/pfe-content-set-fix
Fixes issue #345: pfe-content-set
2 parents cd6af03 + b017ec9 commit 60b9047

20 files changed

+6109
-6305
lines changed

elements/pfe-accordion/src/pfe-accordion.js

Lines changed: 30 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -185,8 +185,8 @@ class PfeAccordion extends PFElement {
185185
headers.forEach(header => {
186186
const panel = this._panelForHeader(header);
187187

188-
header.setAttribute("aria-controls", panel.id);
189-
panel.setAttribute("aria-labelledby", header.id);
188+
header.setAttribute("aria-controls", panel.pfeId);
189+
panel.setAttribute("aria-labelledby", header.pfeId);
190190
});
191191
}
192192

@@ -356,6 +356,18 @@ class PfeAccordionHeader extends PFElement {
356356
return "pfe-accordion-header.html";
357357
}
358358

359+
get pfeId() {
360+
return this.getAttribute("pfe-id");
361+
}
362+
363+
set pfeId(id) {
364+
if (!id) {
365+
return;
366+
}
367+
368+
this.setAttribute("pfe-id", id);
369+
}
370+
359371
static get observedAttributes() {
360372
return ["aria-expanded"];
361373
}
@@ -372,8 +384,8 @@ class PfeAccordionHeader extends PFElement {
372384
this.setAttribute("role", "header");
373385
}
374386

375-
if (!this.id) {
376-
this.id = `${PfeAccordionHeader.tag}-${generateId()}`;
387+
if (!this.pfeId) {
388+
this.pfeId = `${PfeAccordionHeader.tag}-${generateId()}`;
377389
}
378390

379391
this.button = this.shadowRoot.querySelector("button");
@@ -456,6 +468,18 @@ class PfeAccordionPanel extends PFElement {
456468
return "pfe-accordion-panel.html";
457469
}
458470

471+
get pfeId() {
472+
return this.getAttribute("pfe-id");
473+
}
474+
475+
set pfeId(id) {
476+
if (!id) {
477+
return;
478+
}
479+
480+
this.setAttribute("pfe-id", id);
481+
}
482+
459483
constructor() {
460484
super(PfeAccordionPanel);
461485
}
@@ -467,8 +491,8 @@ class PfeAccordionPanel extends PFElement {
467491
this.setAttribute("role", "region");
468492
}
469493

470-
if (!this.id) {
471-
this.id = `${PfeAccordionPanel.tag}-${generateId()}`;
494+
if (!this.pfeId) {
495+
this.pfeId = `${PfeAccordionPanel.tag}-${generateId()}`;
472496
}
473497
}
474498

elements/pfe-accordion/test/pfe-accordion_test.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,8 @@ <h2>Where do the main characters work as adults?</h2>
6868
assert.equal(header.getAttribute('role'), 'header');
6969
assert.isTrue(panel.hasAttribute('aria-labelledby'));
7070
assert.equal(panel.getAttribute('role'), 'region');
71-
assert.equal(header.id, panel.getAttribute('aria-labelledby'));
72-
assert.equal(panel.id, header.getAttribute('aria-controls'));
71+
assert.equal(header.pfeId, panel.getAttribute('aria-labelledby'));
72+
assert.equal(panel.pfeId, header.getAttribute('aria-controls'));
7373
});
7474

7575
test('it should expand a panel when a header is selected', () => {

elements/pfe-content-set/LICENSE.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Copyright 2018 Red Hat, Inc.
1+
Copyright 2019 Red Hat, Inc.
22

33
Permission is hereby granted, free of charge, to any person obtaining a copy
44
of this software and associated documentation files (the "Software"), to deal

elements/pfe-content-set/README.md

Lines changed: 9 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -3,35 +3,26 @@
33

44
## Overview
55

6-
`pfe-content-set` is a combo component, which brings together the utilities of the accordion and tabs components. Effectively both of these components do the same job, which is to encapsulate chunks of information under headings for easier browsing. Hiding some information and allowing the user to toggle through the headings to show other bits of information.
6+
`pfe-content-set` is a combo component, which brings together the utilities of the accordion and tabs components. Effectively both of these components do the same job, which is to encapsulate chunks of information under headings for easier browsing. Hiding some information and allowing the user to toggle through the headings to show other bits of information.
77

88
Since tabs can pose a layout issue on mobile because of the lack of horizontal space, this component will first assess the width of the parent container. If the width is less than 768px, the component will render the content within the `<pfe-accordion>` component. If it is larger than this value, the content will be rendered inside the `<pfe-tabs>` component.
99

1010
## Dependencies
1111

1212
Requires both the `pfe-accordion` and `pfe-tabs` components, as well as the base `pfelement`.
1313

14-
1514
## Usage
1615

17-
You must wrap each chunk of information (heading + content) in a `<pfe-content-set-group>` tag.
18-
19-
You must also apply the `pfe-heading` to the HTML heading element, like an H2 or H3. Otherwise content within the component will not be rendered.
16+
Each header must have an attribute of `pfe-content-set--header` and each panel must have an attribute of `pfe-content-set--panel`. Each header must be immediately followed by a panel.
2017

2118
```html
2219
<pfe-content-set>
23-
<pfe-content-set-group>
24-
<h2 pfe-heading>Heading 1</h2>
25-
<p>Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore </p>
26-
</pfe-content-set-group>
27-
<pfe-content-set-group>
28-
<h2 pfe-heading>Heading 2</h2>
29-
<p>Consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam volu et jen, no sea takimata sanctus est Lorem ipsum dolor sit amet.</p>
30-
</pfe-content-set-group>
31-
<pfe-content-set-group>
32-
<h2 pfe-heading>Heading 3</h2>
33-
<p>At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua.</p>
34-
</pfe-content-set-group>
20+
<h2 pfe-content-set--header>Heading 1</h2>
21+
<p pfe-content-set--panel>Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore </p>
22+
<h2 pfe-content-set--header>Heading 2</h2>
23+
<p pfe-content-set--panel>Consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam volu et jen, no sea takimata sanctus est Lorem ipsum dolor sit amet.</p>
24+
<h2 pfe-content-set--header>Heading 3</h2>
25+
<p pfe-content-set--panel>At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua.</p>
3526
</pfe-content-set>
3627

3728
```
@@ -48,7 +39,7 @@ You must also apply the `pfe-heading` to the HTML heading element, like an H2 or
4839
- Tabs: Borders are removed, only an indicator appears under the active heading.
4940
- `pfe-variant="secondary"`
5041
- Accordion: Headings are on a dark background, text color is reversed.
51-
- Tabs: Headings are encased in a block. The active heading is solid, with a caret pointing downward towards the content. Other headings have a border with no fill.
42+
- Tabs: Headings are encased in a block. The active heading is solid, with a caret pointing downward towards the content. Other headings have a border with no fill.
5243
- `vertical`
5344
- Accordion: No effect.
5445
- Tabs: Headings stack on the left, content pane is shown on the right.

0 commit comments

Comments
 (0)