Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion CHANGELOG-prerelease.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,14 @@
Tag: [v1.0.0-prerelease.41](https://github.com/patternfly/patternfly-elements/releases/tag/v1.0.0-prerelease.41)

- [](https://github.com/patternfly/patternfly-elements/commit/) feat: Add events to the generator
- [](https://github.com/patternfly/patternfly-elements/commit/) feat: pfe-health-index size="mini" version #789

## Prerelease 40 ( 2020-03-10 )

Tag: [v1.0.0-prerelease.40](https://github.com/patternfly/patternfly-elements/releases/tag/v1.0.0-prerelease.40)

- [d0c2a45](https://github.com/patternfly/patternfly-elements/commit/d0c2a4526ec3fc15339bd4ec393364486a260c84) fix: pfe-navigation cta overlap bug in IE11 (#766)
- [eb4a9f6](https://github.com/patternfly/patternfly-elements/commit/eb4a9f63514ad9635d1b195e89d596c3feaf2201) chore: Prettier updates (#770)
- [eb4a9f6](https://github.com/patternfly/patternfly-elements/commit/eb4a9f63514ad9635d1b195e89d596c3feaf2201) chore: Prettier updates (#770)
- [7deb9bb](https://github.com/patternfly/patternfly-elements/commit/7deb9bb6227c0560b60a665ecd43b450db0f90e1) fix: Prevent default pfe-cta arrow from wrapping to a new line by itself #679 (#765)
- [ba9d8b2](https://github.com/patternfly/patternfly-elements/commit/ba9d8b2cfed50580671041778d3d00cb5d5741d1) chore: Fixed invalid Markdown, was missing a back tic (#762)

Expand Down
2 changes: 1 addition & 1 deletion elements/pfe-health-index/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Sets the value for the health index in the UI.

Changes the size.

Possible values: `lg`
Possible values: `mini`, `lg`

## Test

Expand Down
107 changes: 68 additions & 39 deletions elements/pfe-health-index/demo/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.3.1/css/bootstrap-reboot.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/typebase.css/0.5.0/typebase.css">
-->

<link rel="stylesheet" href="../../pfe-styles/dist/pfe-base.css" />
<link rel="stylesheet" href="../../pfe-styles/dist/pfe-context.css" />
<link rel="stylesheet" href="../../pfe-styles/dist/pfe-layouts.css" />
Expand All @@ -32,52 +32,81 @@
line-height: 1.5rem;
font-weight: 400;
}
section {
padding: 16px;
}
div {
margin-bottom: 8px;
}
</style>

</head>
<body unresolved>
<section>
<h1>&lt;pfe-health-index&gt;</h1>
<h2>Default</h2>
<div>
<pfe-health-index health-index="A">A</pfe-health-index>
</div>
<div>
<pfe-health-index health-index="B">B</pfe-health-index>
</div>
<div>
<pfe-health-index health-index="C">C</pfe-health-index>
</div>
<div>
<pfe-health-index health-index="D">D</pfe-health-index>
</div>
<div>
<pfe-health-index health-index="E">E</pfe-health-index>
</div>
<div>
<pfe-health-index health-index="F">F</pfe-health-index>
</div>
<h2>Default</h2>
<div>
<pfe-health-index health-index="A">A</pfe-health-index>
</div>
<div>
<pfe-health-index health-index="B">B</pfe-health-index>
</div>
<div>
<pfe-health-index health-index="C">C</pfe-health-index>
</div>
<div>
<pfe-health-index health-index="D">D</pfe-health-index>
</div>
<div>
<pfe-health-index health-index="E">E</pfe-health-index>
</div>
<div>
<pfe-health-index health-index="F">F</pfe-health-index>
</div>
</section>

<section>
<h2>Mini</h2>
<div>
<pfe-health-index health-index="A" size="mini">A</pfe-health-index>
</div>
<div>
<pfe-health-index health-index="B" size="mini">B</pfe-health-index>
</div>
<div>
<pfe-health-index health-index="C" size="mini">C</pfe-health-index>
</div>
<div>
<pfe-health-index health-index="D" size="mini">D</pfe-health-index>
</div>
<div>
<pfe-health-index health-index="E" size="mini">E</pfe-health-index>
</div>
<div>
<pfe-health-index health-index="F" size="mini">F</pfe-health-index>
</div>
</section>

<h2>Large</h2>
<div>
<pfe-health-index health-index="A" size="lg">A</pfe-health-index>
</div>
<div>
<pfe-health-index health-index="B" size="lg">B</pfe-health-index>
</div>
<div>
<pfe-health-index health-index="C" size="lg">C</pfe-health-index>
</div>
<div>
<pfe-health-index health-index="D" size="lg">D</pfe-health-index>
</div>
<div>
<pfe-health-index health-index="E" size="lg">E</pfe-health-index>
</div>
<div>
<pfe-health-index health-index="F" size="lg">F</pfe-health-index>
</div>
<section>
<h2>Large</h2>
<div>
<pfe-health-index health-index="A" size="lg">A</pfe-health-index>
</div>
<div>
<pfe-health-index health-index="B" size="lg">B</pfe-health-index>
</div>
<div>
<pfe-health-index health-index="C" size="lg">C</pfe-health-index>
</div>
<div>
<pfe-health-index health-index="D" size="lg">D</pfe-health-index>
</div>
<div>
<pfe-health-index health-index="E" size="lg">E</pfe-health-index>
</div>
<div>
<pfe-health-index health-index="F" size="lg">F</pfe-health-index>
</div>
</section>
</body>
</html>
28 changes: 18 additions & 10 deletions elements/pfe-health-index/src/pfe-health-index.html
Original file line number Diff line number Diff line change
@@ -1,13 +1,21 @@
${this.size !== "lg" ? `
<div id="healthIndex"></div>
<div class="box-container">
<div class="box a"></div>
<div class="box b"></div>
<div class="box c"></div>
<div class="box d"></div>
<div class="box e"></div>
<div class="box f"></div>
</div>
${this.props.size.value !== "lg" ? `
${this.props.size.value === "mini" ? `
<div class="box-container">
<div class="box">
<div class="grade" id="healthIndex"></div>
</div>
</div>
` : `
<div id="healthIndex"></div>
<div class="box-container">
<div class="box a"></div>
<div class="box b"></div>
<div class="box c"></div>
<div class="box d"></div>
<div class="box e"></div>
<div class="box f"></div>
</div>
`}
` : `
<div class="box-container">
<div class="box a">
Expand Down
17 changes: 12 additions & 5 deletions elements/pfe-health-index/src/pfe-health-index.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,19 @@ class PfeHealthIndex extends PFElement {

constructor() {
super(PfeHealthIndex, { delayRender: true });
this.size = null;
}

attributeChangedCallback(attr, oldValue, newValue) {
super.attributeChangedCallback(attr, oldValue, newValue);

switch (attr) {
case "size":
this.size = newValue;
this.props.size.value = newValue;
this.render();
this.updateHealthIndex(this.getAttribute("health-index"));
this.updateHealthIndex(this.getAttribute("health-index"), oldValue);
break;
case "health-index":
this.props.size.value = this.getAttribute("size");
this.render();
this.updateHealthIndex(newValue);
break;
Expand All @@ -42,12 +44,17 @@ class PfeHealthIndex extends PFElement {
}
}

updateHealthIndex(grade) {
updateHealthIndex(grade, oldValue) {
const healthIndex = grade.toLowerCase();
const healthIndexUpperCase = grade.toUpperCase();
const boxes = [...this.shadowRoot.querySelectorAll(".box")];
this.innerHTML = healthIndexUpperCase;

if (this.props.size.value === "mini") {
this.shadowRoot.querySelector(".box").classList.remove(oldValue);
this.shadowRoot.querySelector(".box").classList.add(healthIndex);
}

boxes.forEach(box => {
if (box.classList.contains(healthIndex)) {
box.classList.add("active");
Expand All @@ -56,7 +63,7 @@ class PfeHealthIndex extends PFElement {
}
});

if (this.size !== "lg") {
if (this.props.size.value !== "lg") {
this.shadowRoot.querySelector(
"#healthIndex"
).innerText = healthIndexUpperCase;
Expand Down
2 changes: 1 addition & 1 deletion elements/pfe-health-index/src/pfe-health-index.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
"size": {
"title": "Size",
"type": "string",
"enum": ["lg"],
"enum": ["mini", "lg"],
"default": null,
"prefixed": false
}
Expand Down
64 changes: 54 additions & 10 deletions elements/pfe-health-index/src/pfe-health-index.scss
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@

$pfe-health--width: 10px;
$pfe-health--height: $pfe-health--width * 2;
$pfe-health-mini--width: 22px;
$pfe-health-mini--height: $pfe-health-mini--width;

$pfe-health--color-bg: #fff;

Expand All @@ -30,44 +32,44 @@ $pfe-health--color-f: #a30000;
display: none;
}

:host(:not([size="lg"])) {
:host(:not([size="lg"]):not([size="mini"])) {
.box-container {
display: flex;
border: 1px solid #{pfe-color(surface--border)};
margin-left: calc(#{pfe-var(container-spacer)} * 0.5);

.box {
background: $pfe-health--color-bg;
width: $pfe-health--width;
height: $pfe-health--height;
border-right: 1px solid #{pfe-color(surface--border)};

&:last-child {
border-right: 0;
}

&.active {

&.a {
background-color: $pfe-health--color-a;
}

&.b {
background-color: $pfe-health--color-b;
}

&.c {
background-color: $pfe-health--color-c;
}

&.d {
background-color: $pfe-health--color-d;
}

&.e {
background-color: $pfe-health--color-e;
}

&.f {
background-color: $pfe-health--color-f;
}
Expand All @@ -76,6 +78,48 @@ $pfe-health--color-f: #a30000;
}
}

:host([size="mini"]) {
.box-container {
margin: 0;
border: none;

.box {
display: flex;
width: $pfe-health-mini--width;
height: $pfe-health-mini--height;
justify-content: center;
align-items: center;
color: white;
font-size: 16px;
border-radius: 1px;

&.a {
background-color: $pfe-health--color-a;
}

&.b {
background-color: $pfe-health--color-b;
}

&.c {
background-color: $pfe-health--color-c;
}

&.d {
background-color: $pfe-health--color-d;
}

&.e {
background-color: $pfe-health--color-e;
}

&.f {
background-color: $pfe-health--color-f;
}
}
}
}

:host([size="lg"]) {
.box-container {
display: flex;
Expand Down Expand Up @@ -145,4 +189,4 @@ $pfe-health--color-f: #a30000;
background-color: $pfe-health--color-f;
}
}
}
}
9 changes: 8 additions & 1 deletion elements/pfe-health-index/test/pfe-health-index_test.html
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
<pfe-health-index id="E" health-index="E">E</pfe-health-index>
<pfe-health-index id="F" health-index="F">F</pfe-health-index>
<pfe-health-index id="largeSize" health-index="A">A</pfe-health-index>
<pfe-health-index id="miniSize" health-index="A" size="mini">A></pfe-health-index>

<script>
suite('<pfe-health-index>', () => {
Expand Down Expand Up @@ -163,10 +164,16 @@

healthIndex.setAttribute("size", "lg");
activeBox = healthIndex.shadowRoot.querySelector(".box.active");

assert.isTrue(defaultWidth < activeBox.offsetWidth);
assert.isTrue(defaultHeight < activeBox.offsetHeight);
});

test("it should only show a single box if the size attribute is set to mini", () => {
const healthIndex = document.querySelector("#miniSize");
const boxes = healthIndex.shadowRoot.querySelectorAll(".box");
assert.equal(boxes.length, 1);
});
});
</script>
</body>
Expand Down