Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(card): promo variant #1569

Merged
merged 85 commits into from
Aug 6, 2024
Merged
Show file tree
Hide file tree
Changes from 10 commits
Commits
Show all changes
85 commits
Select commit Hold shift + click to select a range
63c4376
fix(card): make `.empty` work
adamjohnson May 14, 2024
e873ee8
fix(card): even `#body` spacing when footer is `.empty`
adamjohnson May 14, 2024
814e034
feat(card): add inline promo demo
adamjohnson May 15, 2024
906c2ce
chore(card): add changeset for inline promo
adamjohnson May 15, 2024
3cf3939
Merge branch 'staging/charmander' into feat/card/inline-promo-variant
adamjohnson May 15, 2024
387a672
Merge branch 'staging/charmander' into feat/card/inline-promo-variant
adamjohnson May 16, 2024
19e525b
Merge branch 'staging/charmander' into feat/card/inline-promo-variant
adamjohnson May 22, 2024
7dcf377
docs(card): rename variants demo to patterns
adamjohnson May 22, 2024
2ff0a62
fix(card): hide empty slots when there's no content
adamjohnson May 22, 2024
089d9ac
feat(card): make inline promo a WC variant
adamjohnson May 28, 2024
57e96f7
fix(card): remove inline promo comment
adamjohnson May 29, 2024
2f1a35c
fix(card): svg title text
adamjohnson May 29, 2024
f603b8e
docs(card): update changeset
adamjohnson May 29, 2024
4331e06
docs(card): change `patterns.html` back to `variants.html`
adamjohnson May 29, 2024
ab48223
fix(card): move inline-promo margin to demo styles
adamjohnson Jun 4, 2024
ad21ced
fix(card): remove inline promo full width padding
adamjohnson Jun 4, 2024
75da1c7
fix(card): rename slot `inline-promo` to `image`
adamjohnson Jun 4, 2024
837b09c
fix(card): remove `one-col` and `reverse` attrs
adamjohnson Jun 6, 2024
0309f97
fix(card): remove `full-width` attr, convert to class + `part` selector
adamjohnson Jun 7, 2024
decbb9b
fix(card): move `standard` styles to demo
adamjohnson Jun 7, 2024
7c3b1f2
docs(card): change attr docs to reference `class`
adamjohnson Jun 7, 2024
ceb57c3
docs(card): inline promo inline docs layout tweaks
adamjohnson Jun 7, 2024
f942a05
fix(card): update inline promo CSS attr selector
adamjohnson Jun 7, 2024
0131c42
fix(card): nix outdated `full-width` prop and var docs
adamjohnson Jun 7, 2024
cef0ff3
docs(card): update changeset
adamjohnson Jun 14, 2024
325c8e0
fix(card): style header when image is present
bennypowers Jun 5, 2024
74540b8
docs(card): implement asset and image patterns
bennypowers Jun 5, 2024
0ad4f98
docs(card): logo pattern
bennypowers Jun 6, 2024
359d61f
docs(card): quote pattern
bennypowers Jun 6, 2024
bb3b7ad
docs(card): image pattern
bennypowers Jun 6, 2024
f8a6fe6
docs(card): icon pattern
bennypowers Jun 6, 2024
d7f067a
docs(card): asset pattern
bennypowers Jun 6, 2024
da98ff7
docs: remove unused images
bennypowers Jun 6, 2024
8d33003
docs: rename inline promo pattern file
bennypowers Jun 6, 2024
018d658
docs(card): sticky pattern
bennypowers Jun 6, 2024
4d5a372
docs(card): title pattern
bennypowers Jun 6, 2024
afb2589
docs(card): video pattern
bennypowers Jun 6, 2024
4635bbc
fix(card): merge updates from base
bennypowers Jun 13, 2024
4ec043d
Merge branch 'staging/charmander' into feat/card/inline-promo-variant
bennypowers Jun 16, 2024
577857e
Merge branch 'staging/charmander' into feat/card/inline-promo-variant
bennypowers Jun 16, 2024
9f649a7
docs(card): pattern fixes
bennypowers Jun 16, 2024
a5855d4
fix(card): has-body shadow class, header margin
bennypowers Jun 17, 2024
7cd974a
Merge branch 'staging/charmander' into feat/card/inline-promo-variant
adamjohnson Jun 18, 2024
8a24c97
fix(card): remove `isServer`, it's not in use
adamjohnson Jun 20, 2024
7e5f6ed
fix(card): inline promo heading and paragraph spacing
adamjohnson Jun 20, 2024
11facbd
fix(card): inline promo tweaks
bennypowers Jun 24, 2024
7ad749f
fix(card): promo tweaks
bennypowers Jun 24, 2024
93d9a09
fix(card): promo tweaks
bennypowers Jun 24, 2024
d307505
refactor(card): class names
bennypowers Jun 24, 2024
fe7549f
fix(card): private vars
bennypowers Jun 24, 2024
2975038
fix(card): remove unused private var
bennypowers Jun 24, 2024
410b4a2
docs(card): inline-promo
bennypowers Jun 24, 2024
16ce8ca
fix(card): rename inline promo to promo
bennypowers Jun 24, 2024
c1c2a13
fix(card): imageless promo layout
bennypowers Jun 24, 2024
1aed49d
Merge branch 'staging/charmander' into feat/card/inline-promo-variant
bennypowers Jun 24, 2024
18da2b3
Merge branch 'staging/charmander' into feat/card/inline-promo-variant
zeroedin Jun 25, 2024
2d3cf8c
docs(card): align image when reversed
bennypowers Jun 30, 2024
e30d737
Merge branch 'staging/charmander' into feat/card/inline-promo-variant
bennypowers Jun 30, 2024
7d10572
Merge branch 'staging/charmander' into feat/card/inline-promo-variant
adamjohnson Jul 11, 2024
67a3643
fix(card): remove 1px spacing around promo image
adamjohnson Jul 12, 2024
7d03104
fix(card): unify promo demo sample SVG attr values
adamjohnson Jul 12, 2024
50391d4
refactor(card): alphabetize promo container css
adamjohnson Jul 12, 2024
33eb9eb
fix(card): touch up promo spacing
adamjohnson Jul 12, 2024
9953acd
fix(card): add appropriate promo standard typography
adamjohnson Jul 12, 2024
4441bb3
fix(card): increase promo standard desktop padding
adamjohnson Jul 12, 2024
49e7fb1
fix(card): fix spacing with standard promo
adamjohnson Jul 12, 2024
ccce836
Merge branch 'staging/charmander' into feat/card/inline-promo-variant
adamjohnson Jul 12, 2024
ff895e2
fix(card): promo layouts
bennypowers Jul 14, 2024
2bc8483
docs(card): promo demos
bennypowers Jul 14, 2024
6ff63e9
Merge branch 'staging/charmander' into feat/card/inline-promo-variant
adamjohnson Jul 18, 2024
daba725
fix(card): improve standard promo spacing
adamjohnson Jul 18, 2024
11812d4
docs(card): add promo standard demo gutters
adamjohnson Jul 18, 2024
12c8dac
fix(card): role `img`
adamjohnson Jul 23, 2024
431d819
feat(card): add `full-width` attribute to promo
adamjohnson Jul 23, 2024
78d2cb1
docs(card): layout tweaks for promo demo
adamjohnson Jul 23, 2024
eaf7f4c
docs(card): change one promo narrow card
adamjohnson Jul 23, 2024
c607e4d
feat(card): make public vars work with promo variant
adamjohnson Jul 23, 2024
e8fb10b
docs(card): improve wording around promo changes
adamjohnson Jul 23, 2024
2e41872
fix(card): match promo border mockup to code
adamjohnson Jul 26, 2024
34ea428
fix(card): update promo standard bkg color
adamjohnson Jul 26, 2024
bbf4523
docs(card): add dark examples to promo + full width demos
adamjohnson Jul 26, 2024
646036a
fix(card): style `.reverse` on container grid, not image/body
adamjohnson Jul 26, 2024
5de06b0
fix(card): increase promo image width
adamjohnson Jul 26, 2024
3562561
Merge branch 'staging/charmander' into feat/card/inline-promo-variant
adamjohnson Jul 30, 2024
a3c6f81
Merge branch 'staging/charmander' into feat/card/inline-promo-variant
adamjohnson Aug 5, 2024
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
5 changes: 5 additions & 0 deletions .changeset/fair-buttons-punch.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@rhds/elements": minor
---

`<rh-card>`: Add Inline Promo demo + styles
adamjohnson marked this conversation as resolved.
Show resolved Hide resolved
85 changes: 85 additions & 0 deletions elements/rh-card/demo/inline-promo.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
<rh-card variant="inline-promo">
<svg slot="inline-promo" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 320 190">
adamjohnson marked this conversation as resolved.
Show resolved Hide resolved
<title>A placeholder image in a card header slot</title>
<rect x="0" y="0" width="320" height="190" fill="#e7f0f9"/>
<line x1="0" y1="0" x2="320" y2="190" stroke="#d6e7f5"/>
<line x1="320" y1="0" x2="0" y2="190" stroke="#d6e7f5"/>
</svg>

<h2>Featured: left aligned with image</h2>
<p>You can customize the <code>#body</code> by using the <code>::part</code> selector. Using this technique, you can have padding on the top, bottom, left, right, or none at all.</p>
<rh-cta>
bennypowers marked this conversation as resolved.
Show resolved Hide resolved
<a href="#">Call to action</a>
</rh-cta>
</rh-card>

<rh-card variant="inline-promo" reverse>
bennypowers marked this conversation as resolved.
Show resolved Hide resolved
<svg slot="inline-promo" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 320 190">
<title>A placeholder image in a card header slot</title>
<rect x="0" y="0" width="320" height="190" fill="#e7f0f9"/>
<line x1="0" y1="0" x2="320" y2="190" stroke="#d6e7f5"/>
<line x1="320" y1="0" x2="0" y2="190" stroke="#d6e7f5"/>
</svg>
<h2>Featured: right aligned with image</h2>
<p>This variant uses the same markup in the same order with one additional attribute/property on the custom element: <code>reverse</code>.</p>
<rh-cta>
<a href="#">Call to action</a>
</rh-cta>
</rh-card>

<rh-card variant="inline-promo" one-col>
<h2>Featured: no image is okay too</h2>
<p>Sometimes, you may not have an image to go with your card. Add the <code>one-col</code> attribute/property on the custom element.</p>
<rh-cta>
<a href="#">Call to action</a>
</rh-cta>
</rh-card>

<div class="bg-off-white">
<rh-card variant="inline-promo" full-width>
<svg slot="inline-promo" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 320 190">
<title>A placeholder image in a card header slot</title>
<rect x="0" y="0" width="320" height="190" fill="#e7f0f9"/>
<line x1="0" y1="0" x2="320" y2="190" stroke="#d6e7f5"/>
<line x1="320" y1="0" x2="0" y2="190" stroke="#d6e7f5"/>
</svg>
<h2>Full Width Inline Promo</h2>
<p>This version doesn't have a border or padding on the sides on large viewports and will expand to the width of the container you put it in. Like the previous two examples, you can add the <code>reverse</code> or <code>one-col</code> attributes to change the look of this variant.</p>
<rh-cta>
<a href="#">Call to action</a>
</rh-cta>
</rh-card>
</div>

<div class="bg-off-white">
<rh-card variant="inline-promo" full-width>
<h2>Full Width Inline Promo - No Image</h2>
<p>Just like the last version, except this version doesn't have an image.</p>
<rh-cta>
<a href="#">Call to action</a>
</rh-cta>
</rh-card>
</div>

<rh-card variant="inline-promo" standard>
<rh-cta slot="inline-promo">
<a href="#">Call to action</a>
</rh-cta>
<p>This is the "standard" inline promo. It has a paragraph and a call to action.</p>
</rh-card>

<script type="module">
import '@rhds/elements/rh-cta/rh-cta.js';
import '@rhds/elements/rh-card/rh-card.js';
</script>

<style>
/*****************************************************************************
* FOR DEMO ONLY
*****************************************************************************/
adamjohnson marked this conversation as resolved.
Show resolved Hide resolved
.bg-off-white {
background-color: var(--rh-color-surface-lighter, #f2f2f2);
padding: var(--rh-space-xl, 24px);
margin-block-end: var(--rh-space-xl, 24px);
}
</style>
adamjohnson marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<section id="card-variants">
<section id="card-patterns">
<rh-card>
<h2 slot="header">Default card, slotted content and footer</h2>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit.
Expand Down Expand Up @@ -132,7 +132,7 @@ <h2>Card with slotted image header. Full width image.</h2>
</script>

<style>
#card-variants {
#card-patterns {
padding: 0.5em;
display: grid;
gap: 1em;
Expand Down
180 changes: 179 additions & 1 deletion elements/rh-card/rh-card.css
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@ article {
flex-direction: column;
}

.empty {
#header.empty,
#inline-promo.empty,
#footer.empty,
#body.empty {
display: none;
}

Expand Down Expand Up @@ -72,6 +75,10 @@ article {
margin-block: var(--rh-space-2xl, 32px) var(--rh-space-xl, 24px);
}

#body:has(+ .empty) {
margin-block-end: var(--rh-space-2xl, 32px);
}

#footer {
display: flex;
gap: 0.5em;
Expand Down Expand Up @@ -108,3 +115,174 @@ article {
margin-block-end: var(--rh-space-2xl, 32px);
}
}

/*****************************************************************************
* INLINE PROMO SHARED
*****************************************************************************/
:host([variant^="inline-promo"]) {
container: inline-promo / inline-size;
display: block;
margin-block-end: var(--rh-space-2xl, 32px);
}

::slotted([slot="inline-promo"]:is(img, svg)) {
display: block;
max-width: 100%;
}

:host([variant^="inline-promo"]) #inline-promo {
order: 10;
width: 100%;
}

:host([variant^="inline-promo"]) #body ::slotted(h2) {
margin-block-start: 0;
}

@container inline-promo (min-width: 768px) {
:host([variant^="inline-promo"]) #container {
align-items: center;
display: grid;
grid-template-columns: 1fr 2fr;
min-height: 250px;
}

:host([variant^="inline-promo"]) #inline-promo {
order: 0;
}

:host([variant^="inline-promo"]) #body {
max-width: 75ch;
}

:host([variant^="inline-promo"]) #body ::slotted(h2) {
font-size: var(--rh-font-size-body-text-2xl, 1.5rem);
}

:host([variant^="inline-promo"]) #body ::slotted(p) {
font-size: var(--rh-font-size-body-text-lg, 1.125rem);
}
}

/*****************************************************************************
* INLINE PROMO RIGHT ALIGNED WITH IMAGE (Reverse)
*****************************************************************************/
@container inline-promo (min-width: 768px) {
:host([variant^="inline-promo"][reverse]) #container {
grid-template-columns: 2fr 1fr;
}

:host([reverse]) #inline-promo {
order: 10;
}
}

/*****************************************************************************
* INLINE PROMO NO IMAGE
*****************************************************************************/
@container inline-promo (min-width: 768px) {
:host([variant^="inline-promo"][one-col]) #container {
grid-template-columns: 1fr;
}
}

/*****************************************************************************
* INLINE PROMO STANDARD
*****************************************************************************/
:host([variant^="inline-promo"][standard]) #container {
background-color:
var(
--rh-card-inline-promo-standard-bg-color,
var(--rh-color-surface-lighter, #f2f2f2)
);
padding: var(--rh-space-2xl, 32px);
min-height: auto;
}

:host([variant^="inline-promo"][standard]) #container.dark {
background-color:
var(
--rh-card-inline-promo-standard-bg-color,
var(--rh-color-surface-darker, #1f1f1f)
);
}

:host([variant^="inline-promo"][standard]) #body {
margin-inline: 0;
margin-block-start: 0;
margin-block-end: var(--rh-space-xl, 24px);
}

:host([variant^="inline-promo"][standard]) #body ::slotted(p) {
font-size: var(--rh-font-size-body-text-lg, 1.125rem);
margin-block: 0;
}

@container inline-promo (min-width: 768px) {
:host([variant^="inline-promo"][standard]) #container {
grid-template-columns: 3fr 1fr;
padding: var(--rh-space-3xl, 48px);
}

:host([variant^="inline-promo"][standard]) #body {
margin-block-end: 0;
}

:host([variant^="inline-promo"][standard]) #inline-promo {
text-align: end;
order: 10;
}

:host([variant^="inline-promo"][standard][reverse]) #container {
grid-template-columns: 1fr 2fr;
}

:host([variant^="inline-promo"][standard][reverse]) #inline-promo {
text-align: start;
order: 0;
}
}

/*****************************************************************************
* INLINE PROMO FULL WIDTH
*****************************************************************************/
:host([variant^="inline-promo"][full-width]) {
margin-block-end: 0;
}

:host([variant^="inline-promo"][full-width]) #container {
border: 0;
padding-block: var(--rh-space-4xl, 64px);
padding-inline: var(--rh-space-lg, 16px);
}

:host([variant^="inline-promo"][full-width]) #body {
margin: 0;
}

:host([variant^="inline-promo"][full-width]) #inline-promo:not(.empty) ~ #body {
margin-block-end: var(--rh-space-3xl, 48px);
}

@container inline-promo (min-width: 768px) {
:host([variant^="inline-promo"][full-width]) #container {
padding-inline: 0;
}

:host([variant^="inline-promo"][full-width]) #body {
margin-block-end: 0;
padding-inline: var(--rh-space-2xl, 32px);
}

:host([variant^="inline-promo"][full-width]) #inline-promo:not(.empty) ~ #body {
margin-block-end: 0;
}

:host([variant^="inline-promo"][full-width]) #inline-promo.empty ~ #body {
grid-column-start: span 2;
}

:host([variant^="inline-promo"][full-width]) #container:has(#inline-promo.empty) {
min-height: auto;
}
}
22 changes: 21 additions & 1 deletion elements/rh-card/rh-card.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,27 @@ import styles from './rh-card.css';
* @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 inline-promo
* Use this slot for the inline promo variant of the card. Images & CTA's are most often slotted here.
* @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 container
* The container for the card. Contains the header, body, and footer.
* @csspart header
* The header for the card. Contains the header slot.
* @csspart inline-promo
* The inline-promo variation for the card. Contains the inline-promo slot.
* @csspart body
* The body for the card. Contains the default slot.
* @csspart footer
* The footer for the card. Contains the footer slot.
* @cssprop {<length>} --rh-card-header-font-size
* Font size for header on card
* {@default `1.5rem`}
* @cssprop {<color>} --rh-card-inline-promo-standard-bg-color
* Background color for the Standard Inline Promo variant
* {@default `var(--rh-color-surface-lighter, #f2f2f2)`}
*/
@customElement('rh-card')
export class RhCard extends LitElement {
Expand All @@ -51,7 +58,15 @@ export class RhCard extends LitElement {
@property({ reflect: true, attribute: 'color-palette' })
colorPalette?: 'darkest' | 'lightest' | 'lighter';

#slots = new SlotController(this, 'header', null, 'footer');
@property({ reflect: true }) variant?: 'inline-promo';

@property({ reflect: true, type: Boolean }) reverse = false;

@property({ reflect: true, type: Boolean }) 'one-col' = false;

@property({ reflect: true, type: Boolean }) 'full-width' = false;

#slots = new SlotController(this, 'header', 'inline-promo', null, 'footer');

override render() {
const { on = '', colorPalette = '' } = this;
Expand All @@ -64,6 +79,11 @@ export class RhCard extends LitElement {
class="${classMap({ empty: !this.#slots.hasSlotted('header') })}">
<slot name="header"></slot>
</div>
<div id="inline-promo"
part="inline-promo"
class="${classMap({ empty: !this.#slots.hasSlotted('inline-promo') })}">
<slot name="inline-promo"></slot>
</div>
<div id="body"
part="body"
class="${classMap({ empty: !this.querySelector(':not([slot])') })}">
Expand Down
Loading