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

refactor(card): clarify component's slot API #4938

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

mizgaionutalexandru
Copy link
Contributor

@mizgaionutalexandru mizgaionutalexandru commented Nov 18, 2024

Description

This PR addresses APIs misunderstandings regarding the sp-card component's slots. Previously used slots preview and cover-photo are now merged into a single one named image. The styles are applied exactly as before, based on the variant and horizontal properties, through using the according id that maps to spectrum CSS styles.
Also, now the quiet variant is included in the style overrides, and a new --mod-* CSS variable was added to allow consumers to reliably obtain the desired behaviour (the added story reflects the usage of this token).
Some CSS was also changed to remove deprecated overrides and improve readability.

Related issue(s)

  • N/A

Motivation and context

  1. The component public API states that the cover-photo slot should be used with the quiet variant. The consumer should not need to determine which slot to use with each variant.
  2. Spectrum-CSS uses preview with the quiet variant
  3. SWC's code examples use preview with the quiet variant
  4. The component, while placing the user in a position to make the correct decision about what slot to use with a specific variant, allows for both slots to be used at the same time but doesn't display the cover-photo anyway
  5. Looks like the quiet variant was included in the width: 100% at a previous point in time but the change to not include it anymore wasn't documented too much. There is a need to come back to the previous behaviour (to include the quiet variant in the full width CSS). It seems like a --mod-* is the best common ground to allow consumers all behaviours related to using an image and how to position it inside the asset, be that cover, contain, scale-down etc. (discussion context)

How has this been tested?

No functional changes were added. All the slots usage in the project have been updated. This being said, all unit tests should pass and VRTs should show changes only for the quiet variant's initial width. A new story was added to reflect the usage of the newly added token.

Screenshots (if appropriate)

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Chore (minor updates related to the tooling or maintenance of the repository, does not impact compiled assets)

Checklist

  • I have signed the Adobe Open Source CLA.
  • My code follows the code style of this project.
  • If my change required a change to the documentation, I have updated the documentation in this pull request.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes.
  • All new and existing tests passed.
  • I have reviewed at the Accessibility Practices for this feature, see: Aria Practices

Best practices

This repository uses conventional commit syntax for each commit message; note that the GitHub UI does not use this by default so be cautious when accepting suggested changes. Avoid the "Update branch" button on the pull request and opt instead for rebasing your branch against main.

Copy link

Branch preview

Review the following VRT differences

When a visual regression test fails (or has previously failed while working on this branch), its results can be found in the following URLs:

If the changes are expected, update the current_golden_images_cache hash in the circleci config to accept the new images. Instructions are included in that file.
If the changes are unexpected, you can investigate the cause of the differences and update the code accordingly.

Copy link

github-actions bot commented Nov 18, 2024

Lighthouse scores

Category Latest (report) Main (report) Branch (report)
Performance 0.98 0.99 0.99
Accessibility 1 1 1
Best Practices 1 1 1
SEO 1 0.92 0.92
PWA 1 1 1
What is this?

Lighthouse scores comparing the documentation site built from the PR ("Branch") to that of the production documentation site ("Latest") and the build currently on main ("Main"). Higher scores are better, but note that the SEO scores on Netlify URLs are artifically constrained to 0.92.

Transfer Size

Category Latest Main Branch
Total 251.262 kB 236.917 kB 236.66 kB 🏆
Scripts 60.986 kB 54.222 kB 54.184 kB 🏆
Stylesheet 53.978 kB 48.207 kB 48.029 kB 🏆
Document 6.224 kB 5.461 kB 🏆 5.464 kB
Font 127.113 kB 126.678 kB 126.633 kB 🏆

Request Count

Category Latest Main Branch
Total 52 52 52
Scripts 41 41 41
Stylesheet 5 5 5
Document 1 1 1
Font 2 2 2

@coveralls
Copy link
Collaborator

coveralls commented Nov 18, 2024

Pull Request Test Coverage Report for Build 11984367845

Details

  • 39 of 39 (100.0%) changed or added relevant lines in 1 file are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.004%) to 98.195%

Totals Coverage Status
Change from base Build 11980793562: 0.004%
Covered Lines: 32378
Relevant Lines: 32796

💛 - Coveralls

Copy link

github-actions bot commented Nov 18, 2024

Tachometer results

Chrome

card permalink

test-basic

Version Bytes Avg Time vs remote vs branch
npm latest 781 kB 36.84ms - 37.69ms - faster ✔
5% - 8%
2.03ms - 3.15ms
branch 756 kB 39.49ms - 40.23ms slower ❌
5% - 9%
2.03ms - 3.15ms
-

grid permalink

basic-test

Version Bytes Avg Time vs remote vs branch
npm latest 716 kB 44.04ms - 44.76ms - unsure 🔍
-0% - +3%
-0.20ms - +1.12ms
branch 672 kB 43.39ms - 44.49ms unsure 🔍
-3% - +0%
-1.12ms - +0.20ms
-
Firefox

card permalink

test-basic

Version Bytes Avg Time vs remote vs branch
npm latest 781 kB 76.71ms - 85.05ms - unsure 🔍
-11% - +2%
-9.11ms - +1.43ms
branch 756 kB 81.49ms - 87.95ms unsure 🔍
-2% - +11%
-1.43ms - +9.11ms
-

grid permalink

basic-test

Version Bytes Avg Time vs remote vs branch
npm latest 716 kB 90.39ms - 98.29ms - unsure 🔍
-4% - +8%
-3.34ms - +7.30ms
branch 672 kB 88.79ms - 95.93ms unsure 🔍
-8% - +3%
-7.30ms - +3.34ms
-

:host(:not([variant='quiet'])) #preview ::slotted(*) {
width: 100%;
#preview ::slotted(*) {
inline-size: 100%;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Should include the quiet variant as per spectrum-css.

@mizgaionutalexandru mizgaionutalexandru changed the title [DRAFT] Imizga/sp card img refactor(card): clarify component's slot API Nov 19, 2024
@mizgaionutalexandru mizgaionutalexandru marked this pull request as ready for review November 20, 2024 11:24
@mizgaionutalexandru mizgaionutalexandru requested a review from a team as a code owner November 20, 2024 11:24
@Rajdeepc
Copy link
Contributor

This will become a breaking change! Will bring this up in our office hours!

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