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

Conversation

brianferry
Copy link
Collaborator

@brianferry brianferry commented Aug 15, 2023

Issue

#1198

What I did

  1. Added --rh-card-background-color as a css variable to rh-card for docs(card): explain element vs pattern #1188

@changeset-bot
Copy link

changeset-bot bot commented Aug 15, 2023

⚠️ No Changeset found

Latest commit: 8c958d6

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@netlify
Copy link

netlify bot commented Aug 15, 2023

Deploy Preview for red-hat-design-system ready!

Name Link
🔨 Latest commit 8c958d6
🔍 Latest deploy log https://app.netlify.com/sites/red-hat-design-system/deploys/64f8859584a47600086cae2c
😎 Deploy Preview https://deploy-preview-1200--red-hat-design-system.netlify.app/patterns/card
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@github-actions
Copy link
Contributor

github-actions bot commented Aug 15, 2023

Size Change: -2 B (0%)

Total Size: 188 kB

Filename Size Change
./elements/rh-card/rh-card.js 1.89 kB -2 B (0%)
ℹ️ View Unchanged
Filename Size
./elements/rh-accordion/rh-accordion-header.js 1.98 kB
./elements/rh-accordion/rh-accordion-panel.js 1.24 kB
./elements/rh-accordion/rh-accordion.js 1.17 kB
./elements/rh-alert/rh-alert.js 4.24 kB
./elements/rh-audio-player/rh-audio-player-about.js 1.85 kB
./elements/rh-audio-player/rh-audio-player-scrolling-text-overflow.js 1.51 kB
./elements/rh-audio-player/rh-audio-player-subscribe.js 1.43 kB
./elements/rh-audio-player/rh-audio-player.js 14.2 kB
./elements/rh-audio-player/rh-cue.js 2 kB
./elements/rh-audio-player/rh-transcript.js 2.94 kB
./elements/rh-avatar/random-pattern-controller.js 2.72 kB
./elements/rh-avatar/rh-avatar.js 2.88 kB
./elements/rh-badge/rh-badge.js 862 B
./elements/rh-blockquote/rh-blockquote.js 1.96 kB
./elements/rh-button/rh-button.js 3.77 kB
./elements/rh-code-block/rh-code-block.js 1.18 kB
./elements/rh-context-provider/rh-context-provider.js 185 B
./elements/rh-cta/rh-cta.js 4.04 kB
./elements/rh-dialog/rh-dialog.js 1.6 kB
./elements/rh-dialog/yt-api.js 614 B
./elements/rh-footer/rh-footer-block.js 765 B
./elements/rh-footer/rh-footer-copyright.js 362 B
./elements/rh-footer/rh-footer-links.js 1.06 kB
./elements/rh-footer/rh-footer-social-link.js 960 B
./elements/rh-footer/rh-footer-universal.js 4.07 kB
./elements/rh-footer/rh-footer.js 5.07 kB
./elements/rh-footer/rh-global-footer.js 250 B
./elements/rh-menu/rh-menu.js 1.02 kB
./elements/rh-navigation-secondary/rh-navigation-secondary-dropdown.js 2.31 kB
./elements/rh-navigation-secondary/rh-navigation-secondary-menu-section.js 1.46 kB
./elements/rh-navigation-secondary/rh-navigation-secondary-menu.js 1.9 kB
./elements/rh-navigation-secondary/rh-navigation-secondary-overlay.js 571 B
./elements/rh-navigation-secondary/rh-navigation-secondary.js 4.75 kB
./elements/rh-navigation-secondary/test/fixtures.js 851 B
./elements/rh-pagination/rh-pagination.js 4.45 kB
./elements/rh-spinner/rh-spinner.js 1.51 kB
./elements/rh-stat/rh-stat.js 2.24 kB
./elements/rh-subnav/rh-subnav.js 2.84 kB
./elements/rh-tabs/rh-tab-panel.js 789 B
./elements/rh-tabs/rh-tab.js 1.81 kB
./elements/rh-tabs/rh-tabs.js 1.86 kB
./elements/rh-tag/rh-tag.js 1.73 kB
./elements/rh-tooltip/rh-tooltip.js 1.07 kB
./lib/context/color/consumer.js 1.15 kB
./lib/context/color/controller.js 1.11 kB
./lib/context/color/provider.js 1.99 kB
./lib/context/event.js 598 B
./lib/context/headings/consumer.js 711 B
./lib/context/headings/controller.js 1.14 kB
./lib/context/headings/provider.js 1.23 kB
./lib/DirController.js 569 B
./lib/elements/rh-context-picker/rh-context-picker.js 1.16 kB
./lib/elements/rh-context-provider/rh-context-provider.js 746 B
./lib/functions.js 175 B
./lib/I18nController.js 1.38 kB
./lib/ScreenSizeController.js 856 B
./rhds.min.js 76.8 kB

compressed-size-action

@brianferry brianferry enabled auto-merge (squash) August 15, 2023 14:31
Copy link
Member

@bennypowers bennypowers left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you add a demo, please?

.changeset/wild-apes-talk.md Outdated Show resolved Hide resolved
@bennypowers
Copy link
Member

Before we merge this, it's worth considering weather it would be wiser to advise users to change the surface color tokens for a given card or class of cards, rather than providing an overriding background variable.

My reasoning is as follows: if we expose the background color variable to users, then users who wish to implement for example a dark background will skip the use of our color context system all together. That is likely to lead to maintenance difficulties, feature creep, and design and accessibility violations.

On the other hand, if we advise users who wish to apply a custom background to explicitly change the surface token values for a given card or class of cards, then they will have to explicitly participate in the context system. Because the context surface tokens have the words "on light" and "on dark" in their names, the user will be subtly encouraged to provide values for both theme variants.

This would have the added advantage of inheriting the provided values to the card's context-consuming children e.g. accordions, which in most cases would be desirable, and could be explicitly opted out of with a child selector

@brianferry
Copy link
Collaborator Author

Before we merge this, it's worth considering weather it would be wiser to advise users to change the surface color tokens for a given card or class of cards, rather than providing an overriding background variable.

My reasoning is as follows: if we expose the background color variable to users, then users who wish to implement for example a dark background will skip the use of our color context system all together. That is likely to lead to maintenance difficulties, feature creep, and design and accessibility violations.

On the other hand, if we advise users who wish to apply a custom background to explicitly change the surface token values for a given card or class of cards, then they will have to explicitly participate in the context system. Because the context surface tokens have the words "on light" and "on dark" in their names, the user will be subtly encouraged to provide values for both theme variants.

This would have the added advantage of inheriting the provided values to the card's context-consuming children e.g. accordions, which in most cases would be desirable, and could be explicitly opted out of with a child selector

That's a good point, I was debating whether or not updating the token for the cards was the way to go or if giving them a background variable would be "easier" vs more correct. If we did go with the token route we'd just want to document it as a pattern or in the element docs letting the user know how they could go about updating it for light, dark, or both contexts.

@zeroedin
Copy link
Collaborator

worth considering weather it would be wiser to advise users to change the surface color tokens for a given card or class of cards, rather than providing an overriding background variable

debating whether or not updating the token for the cards was the way to go or if giving them a background variable would be "easier" vs more correct

Sounds like the example in the patterns section where this issue originated is incorrect instead. If we do not want people overriding the background due to color context. https://github.com/RedHat-UX/red-hat-design-system/pull/1188/files#diff-74187edef1126c20210dc56031164bf56de11f133eacd202a89143cca266baf1R133

If i understand correctly @bennypowers you are asking for something like this instead which would be strictly pattern.

rh-card.alt {
  --rh-color-surface-lightest: rebeccapurple;
  --rh-color-surface-lighter: #bada55;
  --rh-color-surface-light: cornsilk;
  --rh-color-surface-darkest: indigo;
  --rh-color-surface-darker: aliceblue;
  --rh-color-surface-dark: #FF91AF;
}

In this example as long as the .alt card isn't in a color context implementation would only have to override the default value for surface lightest (IIRC).

@bennypowers
Copy link
Member

@brianferry @zeroedin I agree, we should update the docs. WDYT if we pivot this PR by reverting the css changes and then updating the docs?

@brianferry
Copy link
Collaborator Author

Makes sense to me, I'll take a look at updating these docs

@brianferry
Copy link
Collaborator Author

@marionnegp @coreyvickery would either of you be able to review the content under "Custom Theming" https://deploy-preview-1200--red-hat-design-system.netlify.app/patterns/card/#custom-theming . I added two examples in there of customizing the background, border color, and the font color.

Copy link
Collaborator

@marionnegp marionnegp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I made some suggestions to update the examples' colors.

The --_context-background-color is showing up next to the examples under the Theme and Custom Theme sections. Can those be removed?
Screenshot 2023-08-30 at 9 43 42 AM

docs/patterns/card/index.md Outdated Show resolved Hide resolved
docs/patterns/card/index.md Outdated Show resolved Hide resolved
@brianferry
Copy link
Collaborator Author

@marionnegp

I added a width: fit-content for the rh-context-provider and that looks like it has fixed the issue with the background taking the full width of the docs.

@marionnegp
Copy link
Collaborator

@coreyvickery, should people be able to add a headline to the header, like in the slotted title card pattern? I think it makes the spacing look off, but I'm not sure if other teams have asked for it.

@coreyvickery
Copy link
Collaborator

@coreyvickery, should people be able to add a headline to the header, like in the slotted title card pattern? I think it makes the spacing look off, but I'm not sure if other teams have asked for it.

This should probably be discussed in another issue, yes? @brianferry What do you think?

@bennypowers
Copy link
Member

@coreyvickery, should people be able to add a headline to the header, like in the slotted title card pattern? I think it makes the spacing look off, but I'm not sure if other teams have asked for it.

This should probably be discussed in another issue, yes? @brianferry What do you think?

yes, please open a new issue for this

Copy link
Member

@bennypowers bennypowers left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The root problem here is that we don't have a docs page that explains what the colour context system is, how it works, and how to use (or abuse) it.

docs/patterns/card/index.md Outdated Show resolved Hide resolved
docs/patterns/card/index.md Outdated Show resolved Hide resolved
@bennypowers bennypowers changed the title fix(card): adding public background color css variable docs(card): customizing theme colors Sep 5, 2023
@bennypowers bennypowers disabled auto-merge September 5, 2023 14:26
@bennypowers
Copy link
Member

leaving this open for @marionnegp to approve before merging

@brianferry
Copy link
Collaborator Author

@marionnegp - Created a bug for the issue you raised #1209

@bennypowers bennypowers enabled auto-merge (squash) September 6, 2023 13:58
@bennypowers bennypowers merged commit 14786d5 into main Sep 6, 2023
@bennypowers bennypowers deleted the fix/rh-card-public-background-css branch September 6, 2023 14:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants