Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
be6724e
fix: initial commit for pfv4 card
brianferry Oct 7, 2022
57aa9b6
Merge branch 'main' of https://github.com/patternfly/patternfly-eleme…
brianferry Oct 12, 2022
8242cdd
fix: adding BaseCard.ts / scss and reformatting stylings
brianferry Oct 12, 2022
ec577c6
Merge branch 'main' of https://github.com/patternfly/patternfly-eleme…
brianferry Oct 13, 2022
a787353
fix: updating the --pf-c-card css
brianferry Oct 13, 2022
85e4211
fix: updating the --pf-c-card css
brianferry Oct 13, 2022
28d11cc
Merge branch 'main' of https://github.com/patternfly/patternfly-eleme…
brianferry Oct 14, 2022
b23e668
Merge branch 'feat/pfe-card-pfv4' of https://github.com/patternfly/pa…
brianferry Oct 14, 2022
be22169
fix: export basecard.js
brianferry Oct 14, 2022
1c6bb61
fix: updating the base styles to match new format
brianferry Oct 21, 2022
ff21901
Merge branch 'main' of https://github.com/patternfly/patternfly-eleme…
brianferry Oct 21, 2022
44de05d
fix: removing attributes from basecard
brianferry Oct 21, 2022
94443b5
Merge branch 'main' of https://github.com/patternfly/patternfly-eleme…
brianferry Nov 2, 2022
a87ac71
chore: updating the pfe-card styles and the styledocs
brianferry Nov 3, 2022
2ac9277
Merge branch 'main' of https://github.com/patternfly/patternfly-eleme…
brianferry Nov 3, 2022
f3c9bb4
fix: updating font-size to not be private variable for user data
brianferry Nov 8, 2022
8813c0f
fix: removing old styles for demos, adding newlines back for css
brianferry Nov 8, 2022
3c15dba
fix: adding stylings back to the pfe-card demo and adding spacing for…
brianferry Nov 8, 2022
1ad246e
chore: merging from main
brianferry Nov 15, 2022
79c0d57
fix: updating demo to show fullHeight and border more easily. adding…
brianferry Nov 15, 2022
e7ab645
chore: updating to main
brianferry Nov 17, 2022
8daa07b
test(card): :white_check_mark: updating tests for pfe-card 1:1
brianferry Nov 17, 2022
fc42425
Merge branch 'main' of https://github.com/patternfly/patternfly-eleme…
brianferry Nov 18, 2022
9a1b996
fix: removing pfe specific class names from basecard
brianferry Nov 22, 2022
782b569
docs: updating docs to use pfe-switch instead of checkbox inputs
brianferry Nov 29, 2022
7fb7b0d
fix(card): updating fullHeight to full-height attribute
brianferry Nov 29, 2022
fa561b4
Merge branch 'main' into feat/pfe-card-pfv4
brianferry Dec 7, 2022
cb48f4d
fix(card): fixing broken unit test, adding accessibility tests, artic…
brianferry Dec 7, 2022
476dc90
feat(card): adding a11ysnapshot plugin, test to card spec
brianferry Dec 8, 2022
52bda97
Merge branch 'main' into feat/pfe-card-pfv4
brianferry Dec 8, 2022
dc009ca
Merge branch 'main' into feat/pfe-card-pfv4
bennypowers Dec 8, 2022
f8ded8f
Merge remote-tracking branch 'origin/main' into feat/pfe-card-pfv4
Nouveau Dec 12, 2022
24df42d
Merge branch 'main' into feat/pfe-card-pfv4
brianferry Dec 12, 2022
e91a4a1
fix(card): clean up in demo and tests
Nouveau Dec 12, 2022
329d131
Merge branch 'feat/pfe-card-pfv4' of github.com:patternfly/patternfly…
brianferry Dec 15, 2022
fa3b61b
Merge branch 'main' into feat/pfe-card-pfv4
brianferry Dec 15, 2022
d356003
Merge branch 'main' into feat/pfe-card-pfv4
brianferry Dec 15, 2022
01fbef3
Merge branch 'main' into feat/pfe-card-pfv4
bennypowers Dec 19, 2022
8c4e691
fix(card): hide empty regions
bennypowers Dec 20, 2022
4ae5e9d
docs(card): update demo
bennypowers Dec 20, 2022
350f7af
test(card): update tests
bennypowers Dec 20, 2022
98e3a58
Merge branch 'main' into feat/pfe-card-pfv4
bennypowers Dec 20, 2022
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
27 changes: 27 additions & 0 deletions .changeset/many-frogs-film.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
---
"@patternfly/pfe-card": major
---

## Patternfly Card 1:1 🎉

This release migrates Patternfly Card `pfe-card` to Patternfly 1:1 and matches the style and functionality to PFv4.

This will have several breaking changes from the existing `pfe-card`. Many of the attributes will be moving to `rh-card`.

### NEW: Features and Updates
- Styles now match PFv4 Card.
- Size Attribute: `small` is updated to `compact` and `large` is now an option
- Example: `<pfe-card size='large'></pfe-card>`.
- Rounded Attribute: NEW! Optionally applies a border radius for the drop shadow and/or border of the card.
- Example: `<pfe-card rounded></pfe-card>`
- FullHeight Attribute: NEW! Optionally allow the card to take up the full height of the parent element.
- Example: `<pfe-card fullHeight></pfe-card>`
- Plain Attribute: NEW! Removes the border on the card element.
- Example: `<pfe-card plain></pfe-card>`


### Breaking Changes
- No longer includes an `imgSrc` attribute.
- No longer has a dark mode theme.
- No longer includes a `border` attribute.

28 changes: 28 additions & 0 deletions elements/pfe-card/BaseCard.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
:host {
display: flex;
flex-direction: column;
}

[part=header] {
display: flex;
flex-direction: row;
align-items: center;
}

[part=body] ::slotted(:not([slot]):first-of-type) {
margin-block-start: 0;
}

[part=body] ::slotted(:not([slot]):last-of-type) {
margin-block-end: 0;
}

[part=footer] {
display: flex;
gap: 0.5em;
}

.empty {
display: none;
}

53 changes: 53 additions & 0 deletions elements/pfe-card/BaseCard.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
import { LitElement, html } from 'lit';
import { SlotController } from '@patternfly/pfe-core/controllers/slot-controller.js';

import { classMap } from 'lit/directives/class-map.js';

import style from './BaseCard.scss';

/**
* This element creates a header, body, and footer region in which to place
* content or other components.
*
* @summary Gives a preview of information in a small layout
*
* @slot header
* If this slot is used, we expect a heading level tag (h1, h2, h3, h4, h5, h6).
* An icon, svg, or use of the icon component are also valid in this region.
* @slot - Any content that is not designated for the header or footer slot, will go to this slot.
* @slot footer
* Use this slot for anything that you want to be stuck to the base of the card.
*
* @csspart header - The container for *header* content
* @csspart body - The container for *body* content
* @csspart footer - The container for *footer* content
*/
export abstract class BaseCard extends LitElement {
Comment thread
bennypowers marked this conversation as resolved.
static readonly version = '{{version}}';

static readonly styles = [style];

protected slots = new SlotController(this, 'header', null, 'footer');

render() {
return html`
<article>
<header id="header"
part="header"
class="${classMap({ empty: !this.slots.hasSlotted('header') })}">
<slot name="header"></slot>
</header>
<div id="body"
part="body"
class="${classMap({ empty: !this.querySelector(':not([slot])') })}">
<slot></slot>
</div>
<footer id="footer"
part="footer"
class="${classMap({ empty: !this.slots.hasSlotted('footer') })}">
<slot name="footer"></slot>
</footer>
</article>
`;
}
}
2 changes: 1 addition & 1 deletion elements/pfe-card/custom-elements-manifest.config.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { pfeCustomElementsManifestConfig } from '@patternfly/pfe-tools/custom-elements-manifest.js';

export default pfeCustomElementsManifestConfig({
globs: ['pfe-*.ts'],
globs: ['pfe-*.ts', 'BaseCard.ts'],
});
Binary file removed elements/pfe-card/demo/bg-pattern.png
Binary file not shown.
48 changes: 33 additions & 15 deletions elements/pfe-card/demo/demo.css
Original file line number Diff line number Diff line change
@@ -1,26 +1,44 @@
[data-demo] {
padding: 1em;
display: contents;
}

main {
padding: 2em;
background: #eeeeee;
display: grid;
grid-template-columns: repeat(auto-fill, minmax(200px, calc(25% - 32px)));
grid-auto-rows: max-content;
gap: 32px;
grid-template-columns: 1fr;
grid-template-rows: max-content 1fr;
}

.button-series::part(footer) {
display: flex;
gap: 15px;
@media (min-width: 800px) {
main {
grid-template-columns: 1fr 4fr;
grid-template-rows: 1fr;
}
}

#first-image {
grid-column: 1/2;
form {
display: grid;
grid-template-columns: max-content auto;
grid-auto-rows: max-content;
gap: 1em;
}

h2[slot="header"] {
font-size: 1.1em;
font-weight: bolder;
pfe-card {
max-width: 50%;
margin: 0 auto;
}

.custom-border {
--pfe-card--BorderColor: #eee;
--pfe-card--BorderWeight: 1px;
.resize {
padding: 2em;
resize: vertical;
overflow: auto;
min-height: 40vh;
background: repeating-linear-gradient(
45deg,
#fff,
#fff 10px,
#eee 10px,
#eee 20px
);
}
Binary file removed elements/pfe-card/demo/kitten-200x150.jpeg
Binary file not shown.
Binary file removed elements/pfe-card/demo/kitten-400x250.jpeg
Binary file not shown.
Binary file removed elements/pfe-card/demo/kitten-500x250.jpeg
Binary file not shown.
Binary file removed elements/pfe-card/demo/kitten-500x500.jpeg
Binary file not shown.
Binary file removed elements/pfe-card/demo/kitten-650x250.jpeg
Binary file not shown.
Binary file removed elements/pfe-card/demo/kitten-900x300.jpeg
Binary file not shown.
111 changes: 23 additions & 88 deletions elements/pfe-card/demo/pfe-card.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,98 +4,33 @@
<link rel="stylesheet" href="/core/pfe-styles/pfe-layouts.min.css">
<link rel="stylesheet" href="/core/pfe-styles/pfe.min.css">
<link rel="stylesheet" href="/elements/pfe-card/pfe-card--lightdom.min.css">
<link rel="stylesheet" href="./demo.css">
<link rel="stylesheet" href="/core/pfe-styles/pfe.min.css">
<link rel="stylesheet" href="/elements/pfe-card/demo/demo.css" />
<script type="module" src="./pfe-card.js"></script>

<pfe-card color-palette="lightest" border class="button-series">
<h2 slot="header">Lightest card</h2>
<p>This is the lightest pfe-card and <a href="#">a link</a>, and <a href=".">a visited link</a> with <code>border</code>.</p>
<a class="cta primary" href="#" slot="footer">Try</a>
<a class="cta primary" href="#" slot="footer">Buy</a>
</pfe-card>

<pfe-card class="button-series">
<h2 slot="header">Default card</h2>
Unwrapped item. This is the default pfe-card and <a href=#"">a link</a>, and <a href=".">a visited link</a>.
<a href="#" slot="footer">Try</a>
<a href="#" slot="footer">Buy</a>
</pfe-card>

<pfe-card color-palette="darker" class="button-series">
<h2 slot="header">Darker Card</h2>
<p>This is the darker pfe-card and <a href="#">a link</a>, and <a href=".">a visited link</a>.</p>
<a href="#" slot="footer">Try</a>
<a href="#" slot="footer">Buy</a>
</pfe-card>

<pfe-card color-palette="darkest">
<h2 slot="header">Darkest Card</h2>
<p>This is the darkest pfe-card and <a href="#">a link</a>, and <a href=".">a visited link</a>.</p>
<a href="#" slot="footer">Learn more</a>
</pfe-card>

<pfe-card color-palette="complement">
<h2 slot="header">Complement Card</h2>
<p>This is the complement pfe-card and <a href="#">a link</a>, and <a href=".">a visited link</a>.</p>
<a href="#" slot="footer">Learn more</a>
</pfe-card>

<pfe-card color-palette="accent">
<h2 slot="header">Accent Card</h2>
<p>This is the accent pfe-card and <a href="#">a link</a>, and <a href=".">a visited link</a>.</p>
<a href="#" slot="footer">Learn more</a>
</pfe-card>

<pfe-card color-palette="lightest" id="first-image">
<img overflow="top right left" src="/elements/pfe-card/demo/kitten-900x300.jpeg" alt="A cute kitten"/>
<h2>Imaged card with top & side overflow</h2>
<p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Quaerat porro similique saepe tempora vel! Facilis,
porro?</p>
<a href="#" slot="footer">Learn more</a>
</pfe-card>
<form id="card-settings">
<pfe-switch id="flat" data-attribute="flat"></pfe-switch>
<label for="flat">Flat</label>

<pfe-card color-palette="lightest" class="custom-header-background">
<h2 slot="header">Imaged card with side overflow + header</h2>
<img overflow="top right left" src="/elements/pfe-card/demo/kitten-500x250.jpeg" alt="A cute kitten"/>
<p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Quaerat porro similique saepe tempora vel! Facilis,
porro?</p>
<a href="#" slot="footer">Learn more</a>
</pfe-card>
<pfe-switch id="rounded" data-attribute="rounded"></pfe-switch>
<label for="rounded">Rounded</label>

<pfe-card color-palette="lighter">
<h2>Imaged card with side overflow</h2>
<img overflow="right left" src="/elements/pfe-card/demo/kitten-650x250.jpeg" alt="A cute kitten"/>
<a href="#" slot="footer">Learn more</a>
</pfe-card>
<pfe-switch id="plain" data-attribute="plain"></pfe-switch>
<label for="plain">Plain</label>

<pfe-card color-palette="darker">
<h2>Imaged card with side & bottom overflow</h2>
<p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Soluta rerum tempore natus alias! Cumque illum
provident corrupti voluptates.</p>
<img overflow="right left bottom" src="/elements/pfe-card/demo/kitten-400x250.jpeg" slot="footer" alt="A cute kitten"/>
</pfe-card>
<pfe-switch id="full-height" data-attribute="full-height"></pfe-switch>
<label for="full-height">Full Height</label>

<pfe-card color-palette="darker" img-src="/elements/pfe-card/demo/kitten-500x500.jpeg"
style="--pfe-card__header--BackgroundColor--dark: rgba(45,45,45,.7);">
<h2 slot="header">Background Image on card </h2>
<p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Soluta rerum tempore natus alias! Cumque illum
provident corrupti voluptates.</p>
</pfe-card>
<pfe-switch id="size" data-attribute="size"></pfe-switch>
<label for="size" data-state="on">Compact</label>
<label for="size" data-state="off">Large</label>
</form>

<pfe-card>
<h2 slot="header">Deprecated <code>color</code> attribute</h2>
<p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Soluta rerum tempore natus alias! Cumque illum
provident corrupti voluptates.</p>
<pfe-select id="context-selector" slot="footer">
<select>
<option disabled>Select a palette</option>
<option value="lightest">Lightest</option>
<option value="lighter">Lighter</option>
<option value="base" selected>Default</option>
<option value="darker">Darker</option>
<option value="darkest">Darkest</option>
<option value="accent">Accent</option>
<option value="complement">Complement</option>
</select>
</pfe-select>
</pfe-card>
<div id="card-container" class="resize">
<pfe-card>
<h2 slot="header">Lightest card</h2>
<p>This is the lightest pfe-card and <a href="#">a link</a>, and <a href=".">a visited link</a> with <code>border</code>.</p>
<pfe-button slot="footer">Try</pfe-button>
<pfe-button slot="footer">Buy</pfe-button>
</pfe-card>
</div>
25 changes: 19 additions & 6 deletions elements/pfe-card/demo/pfe-card.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,22 @@
import '@patternfly/pfe-band';
import '@patternfly/pfe-card';
import '@patternfly/pfe-select';
import '@patternfly/pfe-button';
import '@patternfly/pfe-switch';
const form = document.getElementById('card-settings');
const card = document.querySelector('pfe-card');

const root = document.querySelector('[data-demo="pfe-card"]')?.shadowRoot ?? document;

root.querySelector('#context-selector').addEventListener('select', event => {
event.target.closest('pfe-card').setAttribute('color', event.value);
form.addEventListener('change', function(event) {
const { checked } = event.target;
const { attribute } = event.target.dataset;
switch (attribute) {
case 'flat':
case 'rounded':
case 'plain':
case 'full-height':
card.toggleAttribute(attribute, checked);
break;
case 'size':
card.setAttribute('size', form.querySelector('label[for="size"]:not([hidden])').textContent.toLowerCase());
break;
}
});

34 changes: 17 additions & 17 deletions elements/pfe-card/docs/pfe-card.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,43 +2,43 @@

Cards are flexible surfaces used to group information in a small layout. They give small previews of information or provide secondary content in relation to the content it's near. Several cards can be used together to group related information.

<div class="pfe-l-grid pfe-m-gutters pfe-m-all-6-col pfe-m-all-4-col-on-md">
<!-- <div class="pfe-l-grid pfe-m-gutters pfe-m-all-6-col pfe-m-all-4-col-on-md"> -->
<pfe-card>
<h3 slot="header">Default card</h3>
<p>This is the default card</p>
<a slot="footer" href="#">Link in the footer</a>
</pfe-card>

<pfe-card color-palette="lightest" border>
<h3 slot="header">Lightest card</h3>
<p>This is the lightest card with a border</p>
<pfe-card size="compact">
<h3 slot="header">Compact card</h3>
<p>This is the compact card</p>
<a slot="footer" href="#">Link in the footer</a>
</pfe-card>

<pfe-card color-palette="darker">
<h3 slot="header">Darker card</h3>
<p>This is the darker card</p>
<pfe-card rounded>
<h3 slot="header">Rounded card</h3>
<p>This is the rounded card</p>
<a slot="footer" href="#">Link in the footer</a>
</pfe-card>

<pfe-card color-palette="darkest">
<h3 slot="header">Darkest card</h3>
<p>This is the darkest card</p>
<pfe-card size="large">
<h3 slot="header">Large card</h3>
<p>This is the large card</p>
<a slot="footer" href="#">Link in the footer</a>
</pfe-card>

<pfe-card color-palette="complement">
<h3 slot="header">Complement card</h3>
<p>This is the complement card</p>
<pfe-card fullHeight>
<h3 slot="header">Full Height card</h3>
<p>This is the full height card</p>
<a slot="footer" href="#">Link in the footer</a>
</pfe-card>

<pfe-card color-palette="accent">
<h3 slot="header">Accent card</h3>
<p>This is the accent card</p>
<pfe-card plain>
<h3 slot="header">Plain card</h3>
<p>This is the plain card</p>
<a slot="footer" href="#">Link in the footer</a>
</pfe-card>
</div>
<!-- </div> -->
{% endrenderOverview %}

{% band header="Usage" %}
Expand Down
Loading