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

docs(card): customizing theme colors #1200

Merged
merged 10 commits into from
Sep 6, 2023
5 changes: 5 additions & 0 deletions .changeset/wild-apes-talk.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@rhds/elements": patch
---

`rh-card`: adding public css variable for card background color. (#1198)
brianferry marked this conversation as resolved.
Show resolved Hide resolved
51 changes: 51 additions & 0 deletions docs/patterns/card/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,45 @@ A card can be used in light and dark themes.
</rh-card>
</rh-context-provider>

### Custom Theming

To customize a card the design tokens must be altered. These design tokens are different depending on the context for the card (light or dark theme).

Examples include:

<ul>
<li>--rh-color-surface-lightest</li>
<li>--rh-color-border-subtle-on-light</li>
<li>--rh-color-text-primary-on-light</li>
</ul>
brianferry marked this conversation as resolved.
Show resolved Hide resolved

For more information, please see the <a href="/elements/card/code/#css-custom-properties">card css custom properties</a>.
brianferry marked this conversation as resolved.
Show resolved Hide resolved


#### Custom Light Theme

<rh-context-provider color-palette="light">
<rh-card class="custom-light-theme">
<h2 slot="header">Card title</h2>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla vitae elit
libero, a pharetra augue. Nullam id dolor id nibh ultricies vehicula ut id
elit. Donec id elit non mi porta gravida at eget metus.</p>
<rh-cta slot="footer"><a href="#">Footer</a></rh-cta>
</rh-card>
</rh-context-provider>

#### Custom Dark Theme

<rh-context-provider color-palette="dark">
<rh-card class="custom-dark-theme">
<h2 slot="header">Card title</h2>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla vitae elit
libero, a pharetra augue. Nullam id dolor id nibh ultricies vehicula ut id
elit. Donec id elit non mi porta gravida at eget metus.</p>
<rh-cta slot="footer"><a href="#">Footer</a></rh-cta>
</rh-card>
</rh-context-provider>

{% repoStatus %}

{% include 'feedback.html' %}
Expand Down Expand Up @@ -160,5 +199,17 @@ A card can be used in light and dark themes.
padding-inline: 0;
padding-block: 0;
}

rh-card.custom-light-theme {
--rh-color-border-subtle-on-light: #EF6461;
--rh-color-surface-lightest: #0081AF;
brianferry marked this conversation as resolved.
Show resolved Hide resolved
--rh-color-text-primary-on-light: #30292F;
}

rh-card.custom-dark-theme {
--rh-color-border-subtle-on-dark: #988B8E;
--rh-color-surface-darkest: #210B2C;
--rh-color-text-primary-on-dark: #F5FFC6;
brianferry marked this conversation as resolved.
Show resolved Hide resolved
}
</style>

2 changes: 1 addition & 1 deletion elements/rh-card/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,4 +71,4 @@ A card consists of the following slots:
</rh-card>
```

[spec]: https://ux.redhat.com/elements/card
[spec]: https://ux.redhat.com/elements/card
1 change: 0 additions & 1 deletion elements/rh-card/rh-card.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ import styles from './rh-card.css';
* @cssprop {<length>} --rh-card-header-font-size
* Font size for header on card
* {@default `1.5rem`}
*
*/
@customElement('rh-card')
export class RhCard extends LitElement {
Expand Down