Skip to content

experiment: add card base styles and visual tests - #9603

Merged
web-padawan merged 16 commits into
mainfrom
base-card
Jul 4, 2025
Merged

web-padawan merged 16 commits into
mainfrom
base-card

Conversation

@anezthes

@anezthes anezthes commented Jul 1, 2025 •

Copy link
Copy Markdown
Contributor

New Card base style

localhost_8000_dev_card html
localhost_8000_dev_card html (3)
localhost_8000_dev_card html (1)
localhost_8000_dev_card html (4)
localhost_8000_dev_card html (2)

Supported custom properties

Property Description
--vaadin-card-background Background color of the card.
--vaadin-card-border-color Color of the card border.
--vaadin-card-border-width Width of the card border.
--vaadin-card-border-radius Border radius of the card corners.
--vaadin-card-gap Gap between card internal blocks (header, content, footer).
--vaadin-card-padding Padding inside the card container.
--vaadin-card-shadow Box shadow of the card.
--vaadin-card-media-aspect-ratio Aspect ratio for media content (images, videos) in the card.
--vaadin-card-title-font-size Font size of the card’s title.
--vaadin-card-title-font-weight Font weight of the card’s title.
--vaadin-card-title-line-height Line height of the card’s title text.
--vaadin-card-subtitle-color Text color of the card’s subtitle.
--vaadin-card-subtitle-font-size Font size of the card’s subtitle.
--vaadin-card-subtitle-font-weight Font weight of the card’s subtitle.
--vaadin-card-subtitle-line-height Line height of the card’s subtitle text.

Concerns

  1. There is a lot of duplicate code between base and core.
  2. The heading margins cannot be adjusted.
  3. Regarding the background color: by default, it’s darker on light themes and lighter on dark themes. When elevated, it’s light on light themes and less light than the default on dark themes. Should we consider introducing surface colors?

@jouni jouni assigned jouni and unassigned jouni Jul 2, 2025
@jouni
jouni self-requested a review July 2, 2025 07:37
@jouni

jouni commented Jul 3, 2025

Copy link
Copy Markdown
Member

Regarding the background color: by default, it’s darker on light themes and lighter on dark themes. When elevated, it’s light on light themes and less light than the default on dark themes. Should we consider introducing surface colors?

I think this is fine for now. It’s more of a concern for actual themes like Lumo and Aura. But we can consider the base colors in the future, if we want to make it easier for themes to manage surface colors.

@jouni

jouni commented Jul 3, 2025

Copy link
Copy Markdown
Member

There is a lot of duplicate code between base and core.

That’s okay. We’ll take that into account when migrating Lumo, and we’ll likely opt-in to base styles in this component, so we don't need to duplicate them in Lumo.

Comment thread dev/card.html Resolved
@jouni

jouni commented Jul 3, 2025

Copy link
Copy Markdown
Member

The heading margins cannot be adjusted.

You mean for the title and subtitle? I say we force those to 0.

@jouni jouni changed the title Base card styles experiment: add card base styles and visual tests Jul 3, 2025
Comment thread dev/card.html Resolved
@jouni

jouni commented Jul 3, 2025

Copy link
Copy Markdown
Member

I’ll fix the CSS version of Lumo.

@web-padawan web-padawan left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Rebased to resolve conflict in card.css after #9621.

@web-padawan

Copy link
Copy Markdown
Member

@jouni seems like the card shadow is incorrect in the CSS version, should we change to use --lumo-box-shadow-xs?

@anezthes

anezthes commented Jul 3, 2025 •

Copy link
Copy Markdown
Contributor Author

The heading margins cannot be adjusted.

You mean for the title and subtitle? I say we force those to 0.

If you check the 'Header' checkbox, an <h2> element will be added. I'm not sure how to target its margins without using inline styles.

@jouni

jouni commented Jul 3, 2025 •

Copy link
Copy Markdown
Member

If you check the 'Header' checkbox, an <h2> element will be added. I'm not sure how to target its margins without using inline styles.

That content is managed by the app, kinda like custom content, and we don't want to target styles for them. In Lumo, margins are set to zero on h1…h6 elements globally, not by the card styles.

@jouni

jouni commented Jul 4, 2025

Copy link
Copy Markdown
Member

I’m not sure I understand how the CSS injection stuff should work. But it seems like now Lumo CSS isn't getting picked up by the component at all.

@web-padawan

Copy link
Copy Markdown
Member

The custom CSS property name was using older -css-inject, changed to -lumo-inject - now it should work.

web-padawan and others added 3 commits July 4, 2025 11:38
The media element should go under the border element, so that the border colors the media element as well.
@sonarqubecloud

sonarqubecloud Bot commented Jul 4, 2025

Copy link
Copy Markdown

@web-padawan
web-padawan merged commit f93e38b into main Jul 4, 2025
@web-padawan
web-padawan deleted the base-card branch July 4, 2025 11:26
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.

3 participants