Skip to content

Commit 96f0a1b

Browse files
authored
feat: Add pfe-border styles in a separate PR (#856)
1 parent 2c950b0 commit 96f0a1b

File tree

5 files changed

+21
-4
lines changed

5 files changed

+21
-4
lines changed

CHANGELOG-prerelease.md

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

33
- [27fee5f](https://github.com/patternfly/patternfly-elements/commit/27fee5f5c5eb021ac126f3767dd0299f5cda8231) fix: pfe-tabs check for tagName on addedNode mutation before continuing
4-
- [](https://github.com/patternfly/patternfly-elements/commit/) fix: Add clearfix within tab and accordion panels
4+
- [2c950b0](https://github.com/patternfly/patternfly-elements/commit/2c950b08f7638787df50aa5ee6738f1205ea3a9d) fix: Add clearfix within tab and accordion panels
5+
- [](https://github.com/patternfly/patternfly-elements/commit/) feat: Add border to the card component
56

67
## Prerelese 45 ( 2020-04-27 )
78

elements/pfe-card/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ There are several attributes available for customizing the visual treatment of t
5454
- `pfe-img-src`: Optional background image applied to the entire card container. Alignment of this image can be managed using the `--pfe-card--BackgroundPosition` variable which is set to `center center` by default.
5555
- `pfe-size`: Optionally adjusts the padding on the container. Accepts: `small`.
5656
- `pfe-overflow`: Optionally allows an image or element to overflow the padding on the container. This property should be added to the direct child of the slotm such as on an image tag; should be added to the element that you want to overflow the container. Accepts: `top`, `right`, `bottom`, `left`.
57+
- `pfe-border`: Optionally apply a border color and weight to the entire card container. The default color and weight is `#d2d2d2` and `1px`, respectively.
5758

5859
## Variables
5960
There are several powerful variables available to hook into and override default styles.

elements/pfe-card/demo/index.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,9 +87,9 @@
8787
<h1>&lt;pfe-card&gt;</h1>
8888
<div class="demo-cards">
8989

90-
<pfe-card pfe-color="lightest" class="custom-border">
90+
<pfe-card pfe-color="lightest" pfe-border>
9191
<h2 slot="pfe-card--header">Lightest card</h2>
92-
<p>This is the lightest pfe-card and <a href="#">a link</a>.</p>
92+
<p>This is the lightest pfe-card and <a href="#">a link</a> with <code>pfe-border</code>.</p>
9393
<div class="button-series" slot="pfe-card--footer">
9494
<pfe-cta slot="pfe-card--footer" pfe-priority="secondary">
9595
<a href="#">Try</a>

elements/pfe-card/src/pfe-card.scss

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ $variables: (
1818
BorderRadius: pfe-var(surface--border-radius),
1919

2020
//-- Border variable encompasses width, style, and color
21-
Border: #{pfe-local(BorderWeight, 0)} #{pfe-local(BorderStyle, solid)} #{pfe-local(BorderColor, transparent)},
21+
Border: #{pfe-local(BorderWidth, 0)} #{pfe-local(BorderStyle, solid)} #{pfe-local(BorderColor, #{pfe-color(surface--border)})},
2222

2323
//-- Color properties
2424
BackgroundColor: pfe-color(surface--base),
@@ -98,6 +98,10 @@ $variables: (
9898
--pfe-card--PaddingLeft: #{pfe-var(container-spacer)};
9999
}
100100

101+
:host([pfe-border]:not([pfe-border="false"])) {
102+
--pfe-card--BorderWidth: #{map-get($pfe-vars, surface--border-width)};
103+
}
104+
101105
// Targets the wrappers in the shadow DOM
102106
.pfe-card {
103107
&__header,

elements/pfe-card/test/pfe-card_test.html

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,17 @@ <h2 slot="pfe-card--header">Card 4</h2>
204204
test("it should have reduced padding when pfe-size is small", () => {
205205
card[0].setAttribute("pfe-size", "small");
206206
assert.equal(getComputedStyle(card[0], null)["padding"], "16px");
207+
card[0].removeAttribute("pfe-size");
208+
});
209+
210+
test("it should have a standard border when pfe-border is set", done => {
211+
card[0].setAttribute("pfe-border", "");
212+
213+
flush(() => {
214+
assert.deepEqual(getColor(card[0], "border-left-color"), hexToRgb("#d2d2d2"));
215+
assert.equal(getComputedStyle(card[0], null)["border-left-width"], "1px");
216+
done();
217+
});
207218
});
208219

209220
// Iterate over the slots object to test expected results

0 commit comments

Comments
 (0)