-
Notifications
You must be signed in to change notification settings - Fork 236
chore: migrate asset #5858
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
base: main
Are you sure you want to change the base?
chore: migrate asset #5858
Conversation
|
📚 Branch Preview🔍 Visual Regression Test ResultsWhen a visual regression test fails (or has previously failed while working on this branch), its results can be found in the following URLs:
Deployed to Azure Blob Storage: If the changes are expected, update the |
8500305 to
e550a7e
Compare
| "start": "yarn start:1st-gen & yarn start:2nd-gen", | ||
| "start:1st-gen": "yarn workspace @spectrum-web-components/1st-gen start", | ||
| "start:2nd-gen": "yarn workspace @adobe/swc start", | ||
| "start:2nd-gen": "yarn workspace @adobe/swc storybook", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is no yarn start command in 2nd gen swc package
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this the start command you were looking for? Or does this do something else?
| "start": "run-p dev:core dev:analyze storybook", |
e550a7e to
58474d7
Compare
Rajdeepc
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good start!
| } | ||
|
|
||
| ::slotted(*) { | ||
| .spectrum-Asset-image { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a breaking change for the existing behaviour if consumers are slotting an <img> without class.
You can keep this class with a migration shim.
::slotted() { /* same rules */ }
.spectrum-Asset-image { /* same rules */ }| } | ||
| .spectrum-Asset-fileOutline { | ||
| fill: var(--spectrum-gray-500); | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this intentional? High-contrast users may get incorrect colors or no contrast adjustments.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was removed in the same PR I mentioned above, where we were removing the mods for asset. Personally, I like this removal after talking with @5t3ph during the app frame side nav WHCM stuff. I don't think this currentcolor is necessary and just adds to the CSS we're shipping for no super strong reason. We can rely on the default handling of high contrast instead of defining this icon background color.
This is with the high contrast variable. I don't think anything is really being added with this query, but I could be wrong.


There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the explanation. Looks fine.
| class=${classMap({ | ||
| ['spectrum-Asset']: true, | ||
| })} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
only one static class is set you could just set class="spectrum-Asset" directly. minor simplification.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i would like to keep the classMap pattern so its easily extensible if it arises... not a deal breaker though
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ideally there is no performance impact here since it just adds a tiny internal Set to render the class list but yea I’m fine either way unless there’s a strong preference to simplify.
| .fileBackground { | ||
| fill: var(--spectrum-asset-file-background); | ||
| .spectrum-Asset-folderBackground { | ||
| fill: var(--spectrum-gray-200); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do these map to the same value? Can you surface up these changes in the PR documentation too for quick reference by reviewers. Its hard to visualize from here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These should be the same values, yes (and they look to be mapped correctly).
Before Cassondra left, she started removing some of the complexity from a chunk of components, asset being one of them. You can see the changes (and remove of the --spectrum-asset- variables) here: https://github.com/adobe/spectrum-css/pull/4257/files#diff-3a87a9f21648ac03bf4532993e3cdf48604b9862efd1c0ea68c3f6c2d44b32b3
In a different PR (that does the same and removes mods and some of the --spectrum prefixed variables for asset list and miller), Cassondra left her reasoning as to why: adobe/spectrum-css#4260 (comment)
Hopefully that's useful! I absolutely agree with @Rajdeepc that we should surface the changes in a changeset. None of these migrations have had a changeset yet. (I asked a similar question in Slack when I was working on status light). Do we have the changeset management situation figured out? I've been out, so it might be and we need a changeset!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please surface up a changeset on this, we will check how the tool is scanning it.
marissahuysentruyt
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think I have any true changes to request! I did leave some additional context in response to a few of Rajdeep's comments, though- hopefully they're helpful!
| * | ||
| * @element swc-asset | ||
| * @slot - content to be displayed in the asset when an acceptable value for `file` is not present | ||
| * @slot - content to be displayed when no `variant` is set (typically an <img>) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right now, these docs are missing the <img> tag in the parentheses) in the description in the control table:
just wrapping it in backticks seems to do the trick.
| * @slot - content to be displayed when no `variant` is set (typically an <img>) | |
| * @slot - The content to be displayed when no `variant` is set (typically an `<img>`) |
| * Use an asset element to visually represent a file, folder, or image. | ||
| * File and folder representations center themselves within the available space. | ||
| * Images are contained to the element’s size and centered. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| public variant: AssetVariant | undefined; | ||
|
|
||
| /** | ||
| * Accessible label for the asset’s SVG variant. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Super nit pick: our variants are technically named them "file" or "folder," and not "SVG." Is it odd or confusing to mention an SVG variant? I'll leave it up to you if you want to change it.
| * Accessible label for the asset’s SVG variant. | |
| * Accessible label for the asset’s file and folder variants. |
| .fileBackground { | ||
| fill: var(--spectrum-asset-file-background); | ||
| .spectrum-Asset-folderBackground { | ||
| fill: var(--spectrum-gray-200); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These should be the same values, yes (and they look to be mapped correctly).
Before Cassondra left, she started removing some of the complexity from a chunk of components, asset being one of them. You can see the changes (and remove of the --spectrum-asset- variables) here: https://github.com/adobe/spectrum-css/pull/4257/files#diff-3a87a9f21648ac03bf4532993e3cdf48604b9862efd1c0ea68c3f6c2d44b32b3
In a different PR (that does the same and removes mods and some of the --spectrum prefixed variables for asset list and miller), Cassondra left her reasoning as to why: adobe/spectrum-css#4260 (comment)
Hopefully that's useful! I absolutely agree with @Rajdeepc that we should surface the changes in a changeset. None of these migrations have had a changeset yet. (I asked a similar question in Slack when I was working on status light). Do we have the changeset management situation figured out? I've been out, so it might be and we need a changeset!
| } | ||
| .spectrum-Asset-fileOutline { | ||
| fill: var(--spectrum-gray-500); | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was removed in the same PR I mentioned above, where we were removing the mods for asset. Personally, I like this removal after talking with @5t3ph during the app frame side nav WHCM stuff. I don't think this currentcolor is necessary and just adds to the CSS we're shipping for no super strong reason. We can rely on the default handling of high contrast instead of defining this icon background color.
This is with the high contrast variable. I don't think anything is really being added with this query, but I could be wrong.


| "start": "yarn start:1st-gen & yarn start:2nd-gen", | ||
| "start:1st-gen": "yarn workspace @spectrum-web-components/1st-gen start", | ||
| "start:2nd-gen": "yarn workspace @adobe/swc start", | ||
| "start:2nd-gen": "yarn workspace @adobe/swc storybook", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this the start command you were looking for? Or does this do something else?
| "start": "run-p dev:core dev:analyze storybook", |

Description
This PR migrates the next-gen Asset component to Spectrum 2 styles and updates Storybook accordingly.
Motivation and context
This PR migrates the Asset component from first-gen to the second-gen architecture, following the established pattern of separating core component logic from Spectrum-specific implementation.
Changes:
What changed
First-gen:
first-gen/packages/asset/src/Asset.ts- Remains unchanged for backward compatibilityCore (Base):
second-gen/packages/core/components/asset/Asset.base.ts- Updates shared functionalitiessecond-gen/packages/core/components/asset/Asset.types.ts- Creates types file for size and static color variantssecond-gen/packages/core/components/asset/index.ts- Imports and exports typesSecond-gen:
second-gen/packages/swc/components/asset/Asset.ts- Updates render method to accommodate classessecond-gen/packages/swc/components/asset/asset.css- Adds CSS fromspectrum-csssecond-gen/packages/swc/components/asset/stories/asset.stories.ts- Adds comprehensive story coverageRelated issue(s)
Screenshots (if appropriate)
Author's checklist
Reviewer's checklist
patch,minor, ormajorfeatures (Note: I did not add a changeset, I wasn't sure that this was set up for barebones and didn't see any for progress circle or badge, but I'm happy to add one if I'm mistaken!)Manual review test cases
Run second-gen Storybook:
Storybook functionality:
Documentation:
First-gen verification (use the PR preview or run locally):
yarn start # or yarn docs:startCode review checklist:
Device review