Skip to content

Commit 4448752

Browse files
committed
US206196 pfe-modal code revisions and automatated tests
* added ATs. * removed pfe-sass from demo file * updated pacakge.json pfe versions. * added z-index sass map and mixin
1 parent 57b55f9 commit 4448752

File tree

5 files changed

+50
-11
lines changed

5 files changed

+50
-11
lines changed

elements/pfe-modal/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"className": "PfeModal",
55
"elementName": "pfe-modal"
66
},
7-
"version": "1.0.0-prerelease.17",
7+
"version": "1.0.0-prerelease.19",
88
"publishConfig": {
99
"access": "public"
1010
},
@@ -36,8 +36,8 @@
3636
],
3737
"license": "MIT",
3838
"dependencies": {
39-
"@patternfly/pfe-sass": "1.0.0-prerelease.17",
40-
"@patternfly/pfelement": "1.0.0-prerelease.17"
39+
"@patternfly/pfe-sass": "1.0.0-prerelease.19",
40+
"@patternfly/pfelement": "1.0.0-prerelease.19"
4141
},
4242
"generator-pfelement-version": "1.1.0"
4343
}

elements/pfe-modal/src/pfe-modal.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ $pfe-modal--breakpoint--medium: 640px;
3030
flex-direction: column;
3131
align-items: center;
3232
justify-content: center;
33-
z-index: var(--pfe-z--modal, 2000); // Reset this to use the z-index map.
33+
z-index: #{pfe-var($cssvar: modal, $map: $z-index)};
3434

3535
&[hidden] {
3636
display: none;

elements/pfe-modal/test/pfe-modal_test.html

Lines changed: 39 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,51 @@
88
<script type="module" src="../pfe-modal.js"></script>
99
</head>
1010
<body>
11-
1211
<pfe-modal>
13-
This is the element content.
12+
<button slot="pfe-modal--trigger">Open the modal</button>
13+
<h2 slot="pfe-modal--header">Modal with a header</h2>
14+
<p>Lorem ipsum dolor sit amet, <a href="#foo">consectetur adipisicing</a> elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
15+
<pfe-cta>
16+
<a href="#bar">Learn more</a>
17+
</pfe-cta>
1418
</pfe-modal>
15-
1619
<script>
1720
suite('<pfe-modal>', () => {
18-
test('it should upgrade', () => {
19-
assert.instanceOf(document.querySelector('pfe-modal'), customElements.get("pfe-modal", 'pfe-modal should be an instance of pfeModal'));
21+
test('it should upgrade pfe-modal', () => {
22+
assert.instanceOf(document.querySelector('pfe-modal'), customElements.get("pfe-modal", 'pfe-modal should be an instance of PfeModal'));
23+
});
24+
25+
test('it should add the proper attributes to the modal window', () => {
26+
const pfeModal = document.querySelector('pfe-modal');
27+
const outer = pfeModal.querySelector('pfe-modal__outer');
28+
const modalWindow = pfeModal.querySelector('pfe-modal__window');
29+
const button = pfeModal.querySelector('pfe-modal__close');
30+
31+
assert.isTrue(pfeModal.hasAttribute('has_trigger'));
32+
assert.isTrue(pfeModal.hasAttribute('has_header'));
33+
assert.isTrue(pfeModal.hasAttribute('has_body'));
34+
assert.equal(modalWindow.getAttribute('tabindex'), '0');
35+
assert.isTrue(modalWindow.hasAttribute('hidden'));
36+
assert.equal(button.getAttribute('aria-label'), 'Close dialog');
37+
});
38+
39+
test('it should open the modal window when the trigger is clicked', () => {
40+
const pfeModal = document.querySelector('pfe-modal');
41+
const outer = pfeModal.querySelector('pfe-modal__outer');
42+
const modalWindow = pfeModal.querySelector('pfe-modal__window');
43+
const button = pfeModal.querySelector('pfe-modal__close');
44+
const trigger = pfeModal.querySelector('[slot=pfe-modal--trigger');
45+
46+
trigger.click();
47+
48+
assert.isNotTrue(modalWindow.hasAttribute('hidden'));
49+
50+
// reset
51+
button.click();
52+
assert.isTrue(modalWindow.hasAttribute('hidden'));
53+
2054
});
2155

22-
// you need to write more tests!!!
2356

2457
});
2558
</script>

elements/pfe-sass/variables/_maps.scss

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -227,3 +227,10 @@ $pfe-vars: (
227227
animation-timing: cubic-bezier(0.465, 0.183, 0.153, 0.946),
228228
opacity: .3
229229
);
230+
231+
$z-index: (
232+
modal: 99,
233+
navigation: 98,
234+
overlay: 97,
235+
content: 0
236+
);

examples/index.html

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ <h1>Demos</h1>
2727
<li><a href="../elements/pfe-number/demo">pfe-number</a></li>
2828
<li><a href="../elements/pfe-page-status/demo">pfe-page-status</a></li>
2929
<li><a href="../elements/pfe-progress-indicator/demo">pfe-progress-indicator</a></li>
30-
<li><a href="../elements/pfe-styles/demo">pfe-styles</a></li>
3130
<li><a href="../elements/pfe-tabs/demo">pfe-tabs</a></li>
3231
</ul>
3332
</body>

0 commit comments

Comments
 (0)