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

feat(file-input): new module #2435

Merged
merged 38 commits into from
Sep 27, 2024

Conversation

kentokage
Copy link
Contributor

@kentokage kentokage commented Sep 3, 2024

Fixes # #2428

  • This PR contains CSS changes
  • This PR does not contain CSS changes

Description

This is the first iteration (alpha) of file-upload. Two building block components created file-preview-card and file-preview-card-group to support the display of uploaded assets in card form (list will be done later). This PR focuses on structure, a11y, and css.

Notes

Screenshots

file-upload

// base

image

// rtl

image

file-preview-card

// uploading

image

// images

image image image

// video
image
image

// docs
image
image
image

// overflow

image image

file-preview-card-group

// base

image

// Mixed types with details (details artificially inserted and is not part of the file-preview-card)
image

// RTL
image

// 512 container

image

// 768 container

image

See skin app and storybook for more responsive breakpoints

Checklist

  • I verify the build is in a non-broken state
  • I verify all changes are within scope of the linked issue
  • I regenerated all CSS files under dist folder
  • I tested the UI in all supported browsers
  • I did a visual regression check of the components impacted by doing a Percy build and approved the build
  • I tested the UI in dark mode and RTL mode
  • I added/updated/removed Storybook coverage as appropriate

fix(file-upload): update css

feat(file-upload): fix css

feat(file-upload): add modules

feat(file-upload): fix module grammar
Copy link

changeset-bot bot commented Sep 3, 2024

🦋 Changeset detected

Latest commit: 9add60c

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@ebay/skin Minor

Not sure what this means? Click here to learn what changesets are.

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

@kentokage kentokage marked this pull request as ready for review September 3, 2024 21:41
Copy link
Member

@LuLaValva LuLaValva left a comment

Choose a reason for hiding this comment

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

Thanks for the quick work @kentokage! I started with a few comments, but before I go further with the nitpicks I have a few high-level questions:

  1. Is the --large modifier necessary, or should it be based on a media query? In the designs it looks like cards are supposed to be large on small screens.
  2. Width of cards in the spec is labeled as max width and not width in general. My interpretation is that for small width screens, width should be adjusted so that two cards always fit cleanly in each row (even when that means decreasing card size):
    image
  3. Should cards be flush with the right side of the container, instead of moving to a newline whenever they don't fit? It's a little frustrating since all designs have "perfect" screen sizes, but I think it may make more sense to use space-between instead of forcing gap to be 32px as labeled in the design.
    image

@kentokage
Copy link
Contributor Author

Thanks for the quick work @kentokage! I started with a few comments, but before I go further with the nitpicks I have a few high-level questions:

  1. Is the --large modifier necessary, or should it be based on a media query? In the designs it looks like cards are supposed to be large on small screens.
  2. Width of cards in the spec is labeled as max width and not width in general. My interpretation is that for small width screens, width should be adjusted so that two cards always fit cleanly in each row (even when that means decreasing card size):
    image
  3. Should cards be flush with the right side of the container, instead of moving to a newline whenever they don't fit? It's a little frustrating since all designs have "perfect" screen sizes, but I think it may make more sense to use space-between instead of forcing gap to be 32px as labeled in the design.
    image
  1. Hmm good point, I suppose I can apply this to both the card and file-upload components and this would also eliminate the extra stories for large and compact. I see $_screen-size-MD is 768px, can we use this breaking point for small screen?
  2. I see. This ties in with 1 and 3, if we can have set it to max-width that can dynamic adjust the card sizes while maintaining the gap and flushing to the right, that would be ideal.
  3. Great question! I initially thought we could flush it to the right with auto-fit but yes it doesn't honor the gap specified in the design. We could bring this up with our designer.

Definitely will do 1, and play around to make 2 work, which should also solve 3

Copy link
Contributor

@agliga agliga left a comment

Choose a reason for hiding this comment

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

Couple of comments

First off, please target 18.3.0 branch
Second off, did you run npm run build? I see a lot of linting issues in the code. We did change that recently, so I want to make sure our linter is running correctly.

Looks good as a first pass overall.

@@ -0,0 +1,378 @@
<div id="card">
Copy link
Contributor

Choose a reason for hiding this comment

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

This is good, but might be too generic. I think we do have an actual card module coming up.
We can call it file-upload-card maybe?
If anyone has any suggestions on this, feel free to add

Comment on lines 28 to 29
height: inherit;
width: inherit;
Copy link
Contributor

Choose a reason for hiding this comment

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

Are these styles needed? They seem redundant.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Since I'm using the background-image it's needed since it doesn't take up any space. I could have used an img tag but I was thinking we need to overlay it with other elements, i.e. the progress bar so didn't want to take up block space

Comment on lines 16 to 24
@media screen and (max-width: $_screen-size-MD) {
.card {
width: $card-size-large;

.card__container {
height: $card-size-large;
}
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

We usually put our media queries at the end of the file, so they're easy to be found.

.card__label.icon-btn {
@include bubble-close();

position: absolute;
Copy link
Contributor

Choose a reason for hiding this comment

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

Why do we need position absolute. We should be able to put these inline I assume and style it that way.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hmm I thought that was a simpler approach. I can use css grid and define quadrants where we can place these elements. Wdyt?

.card .card__action {
@include bubble-close();

position: absolute;
Copy link
Contributor

Choose a reason for hiding this comment

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

Why do we need position absolute. We should be able to put these inline I assume and style it that way.

uploadedDocumentWithTitle as uploadedDocumentWithTitleCard,
uploadedDocumentWithTitleAndDescription as uploadedDocumentWithTitleAndDescriptionCard,
uploadedWithOverflow as uploadedWithOverflowCard,
} from "../../card/stories/card.stories";
Copy link
Contributor

Choose a reason for hiding this comment

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

Interesting.
This is possibly a good pattern we can use in the future!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I noticed a lot of repetition so reused the markup from other stories. I tried this with the app but it seems like it there may be some special logic with the highlight-code component that doesn't process the functions

Comment on lines 65 to 66
$card-size-default: 132px;
$card-size-large: 168px;
Copy link
Contributor

Choose a reason for hiding this comment

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

Not sure if this is the right place to put these.
Taking a look at lightbox dialog, we have certain sizes defined in the :root of the file
https://github.com/eBay/skin/blob/18.3.0/src/sass/lightbox-dialog/lightbox-dialog.scss#L5-L8
I would follow that pattern

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I wanted to put it in a place where both the card component and the file-upload component could use the var. Is there another shared location?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Removed these since the sizes will be dynamic and dictated by the parent

Comment on lines 49 to 50
background: none;
background: var(--color-background-on-secondary, #fff);
Copy link
Contributor

Choose a reason for hiding this comment

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

Two backgrounds here

top: var(--spacing-100, 8px);
right: var(--spacing-100, 8px);
margin: 0;
background: var(--color-background-on-secondary, #fff);
Copy link
Contributor

Choose a reason for hiding this comment

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

Use the mixin for the background please.
Make sure the first variable is not defined and relative to the component.
https://github.com/eBay/skin/blob/18.3.0/src/sass/lightbox-dialog/lightbox-dialog.scss#L177
So maybe @include background-color-token(card-action-color, color-background-on-secondary);

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm not following, why would we provide a variable that is not defined in the first arg for the mixin?

Copy link
Contributor

@ArtBlue ArtBlue left a comment

Choose a reason for hiding this comment

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

This is my first pass concentrating only on card and other general structural stuff. We can move on to the other sections of this PR when we've ironed out stuff for this.

Looks mostly good, but some important things that need to be addressed.

@@ -62,3 +62,5 @@ $font-size-large-1: $font-size-20;
$font-size-medium: $font-size-16;
$font-size-regular: $font-size-14;
$font-size-small: $font-size-12;
$card-size-default: 132px;
Copy link
Contributor

Choose a reason for hiding this comment

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

These are probably too specific to be in a global vars file. Since there aren't too many of them, I don't think a separate mixin is necessary. Are these necessary? Ultimately, if these modules are completely independent of one another (ideal), there shouldn't be any intertwined parameter dependencies across one another.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah I see, I had to use the size for the width in the css grid-template-cols style. Since we are changing the grid to allow it to display number of cols based on breakpoint, then this may not be needed anymore

<div class="card">
<div class="card__container">
<div class="card__content">
<progress class="progress-bar" value=60 max=100/>
Copy link
Contributor

Choose a reason for hiding this comment

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

You need double quotes for attributes.

<div class="card">
<div class="card__container">
<div class="card__content">
<progress class="progress-bar" value=60 max=100/>
Copy link
Contributor

Choose a reason for hiding this comment

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

You need double quotes for attributes.

Copy link
Contributor

Choose a reason for hiding this comment

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

I think the naming of this module may be a bit too generic. Since images are a staple of this module, maybe we use image-card? We can brainstorm offline.

</div>

<highlight-code type="html">
<div class="card">
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we need 3 layers here before we get to the content?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The other layer .card is for the card container which displays the thumbnail and the details underneath if provided. The .card-container is for the thumbnail and any overlay elements i.e. menu, label. Then the card content itself

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I refactored it to remove the middle .container layer

@import "../variables/variables";

.card {
display: flex;
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we need flex here? These are standalone cards. I'm not seeing any complex structure inside.

}

.card__container {
position: relative;
Copy link
Contributor

Choose a reason for hiding this comment

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

Why do we need relative positioning here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Andrew had posted a similar comment earlier
#2435 (comment)


.card__container {
position: relative;
height: $card-size-default;
Copy link
Contributor

Choose a reason for hiding this comment

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

Why the height here? I think having a specified height here may be an issue for responsively reducing/enlarging these image cards. They will lose their aspect ratio. There's also the width above this layer. Not sure how they work together, but feels odd to have them in different layers.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Because the card can contain details, that's why the width and height are separate so that the width can be applied to the details as well since the card is the parent of the card container and the card details. Sounds like the size should be adjustable?

height: $card-size-default;
}

@media screen and (max-width: $_screen-size-MD) {
Copy link
Contributor

Choose a reason for hiding this comment

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

We should be using the min-width approach instead. Have the default for the smallest screen and then enlarge as needed.

Copy link
Contributor

Choose a reason for hiding this comment

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

It feels like we need another top-level module - image-card-group - for groups of these image-card items that would handle responsive display rules/views similar to how toggle-button and toggle-button-group work in tandem.

@kentokage kentokage changed the base branch from master to 18.3.0 September 4, 2024 17:08
@kentokage
Copy link
Contributor Author

Couple of comments

First off, please target 18.3.0 branch Second off, did you run npm run build? I see a lot of linting issues in the code. We did change that recently, so I want to make sure our linter is running correctly.

Looks good as a first pass overall.

Whoops, changed it to 18.3.0

Yep I ran npm run build and committed the the output from /dist

@kentokage
Copy link
Contributor Author

kentokage commented Sep 6, 2024

Pending work

  • file-preview-card-group
  • add new modules to app
  • list-card is still there, but will ignore / remove since there is a future component similar to this down the line
  • ignore /dist and /src/modules/ for now

@kentokage
Copy link
Contributor Author

Removed the dashed border for the responsive demo
image

Copy link
Contributor

@ArtBlue ArtBlue left a comment

Choose a reason for hiding this comment

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

Overall, it's looking great!!! A few minor things I found...

Comment on lines 14 to 21
--row-preview-cards-min: 2;
--row-preview-cards-sm: 4;
--row-preview-cards-md: 5;
--row-preview-cards-lg: 7;
--row-preview-cards-xl: 9;
--row-preview-cards-xl2: 10;
--row-preview-cards-xl3: 12;
--row-preview-cards-xl4: 14;
Copy link
Contributor

Choose a reason for hiding this comment

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

Based on a recent decision to start using sass vars for private variables, we should convert these.

@supports not (contain: inline-size) {
@media (min-width: $_screen-size-SM) {
div.file-preview-card-group ul {
gap: var(--spacing-100, 8px);
Copy link
Contributor

Choose a reason for hiding this comment

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

Let's use the spacing vars from evo-core throughout instead of raw pixels for gaps.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I am using it, but I'll remove the fallback value

export const base = () => `
<div class="file-preview-card-group">
<ul>
<li>${squareImage()}</li>
Copy link
Contributor

Choose a reason for hiding this comment

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

This is beautiful!!!

<h3>Base</h3>
<div class="demo">
<div class="demo__inner">
<div class="file-preview-card-group">
Copy link
Contributor

Choose a reason for hiding this comment

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

Weren't we going to do the responsive demos with an overflow container?

border: 1px dashed;
display: flex;
flex-direction: row;
gap: var(--spacing-100, 8px);
Copy link
Contributor

Choose a reason for hiding this comment

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

I would avoid these backups. We'd want this to fail fast so we can correct the missing css prop.


font-size: var(--font-size-14);
font-weight: 700;
height: 40px;
Copy link
Contributor

Choose a reason for hiding this comment

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

Use spacing css props.

</svg>
</span>
<span class="inline-notice__main">
<p>Upload failed</p>
Copy link
Contributor

Choose a reason for hiding this comment

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

Doesn't this individual card need something to indicate an error for screen readers?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is removed

</div>
`;

export const portraitDoc = () => `
Copy link
Contributor

Choose a reason for hiding this comment

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

These PDF examples include an image. Let's make them consistent with how it's coded in Skin - for now these should be "other" with the generic icon.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'll remove these PDF examples since the general one should cover it

</div>
`;

export const landscapeDoc = () => `
Copy link
Contributor

Choose a reason for hiding this comment

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

These PDF examples include an image. Let's make them consistent with how it's coded in Skin - for now these should be "other" with the generic icon.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'll remove these PDF examples since the general one should cover it

</div>
`;

const portraitDocWithTitle = () => `
Copy link
Contributor

Choose a reason for hiding this comment

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

Please change all the PDF stories to match Skin as "other" than image - generic icon.

Copy link
Contributor

@saiponnada saiponnada left a comment

Choose a reason for hiding this comment

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

Minor doc changes, we also need to iron out aria-labels across the docs

Copy link
Contributor

@agliga agliga left a comment

Choose a reason for hiding this comment

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

Approving for now. I have one comment but its a docs issue. To me, this looks great and Im happy with how it turned out.
Docs change, we can always clean up after the fact.

<div class="file-preview-card-group">
<ul>
<li>
<!--refer to file-preview-card-->
Copy link
Contributor

Choose a reason for hiding this comment

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

Generally we like to include the full code, especially how its rendered above.
It might be more verbose but its much better developer experience.
That said, Im fine this being fixed later because its a docs change only.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

One of the ideas suggested was to solve the verbose issue as you already mentioned and also not needing to constantly update the code as changes are being made to the skin css. Yep I can fix it later in a follow up PR

@ianmcburnie
Copy link
Contributor

So one last question before we merge this: should we rename from file-upload-input to just file-input?

@kentokage
Copy link
Contributor Author

So one last question before we merge this: should we rename from file-upload-input to just file-input?

@ianmcburnie My intention with file-upload-input is that this is the selector and there would be a wrapper component on the ebayui-core side (maybe file-upload that would also incorporate all of the components (selector + preview card group). So these components would be part of the same family of components. But I can see file-input makes sense because there is no upload part yet. I'm fine with either way

@kentokage kentokage changed the title feat(file-upload): new module feat(file-input): new module Sep 27, 2024
Copy link
Contributor

@ArtBlue ArtBlue left a comment

Choose a reason for hiding this comment

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

I took one last look. Looks good. Just a couple of last things.

// - pixel values

// Minimal Layout (default)
$_row-preview-cards-min: 2;
Copy link
Contributor

Choose a reason for hiding this comment

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

SASS vars in modules are inherently private to the module. Underlines are not necessary. Let's please just remove them ti simplify.

Copy link
Contributor

@ianmcburnie ianmcburnie left a comment

Choose a reason for hiding this comment

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

Very cool! Great work @kentokage ! Much appreciated.

Copy link
Contributor

@ArtBlue ArtBlue left a comment

Choose a reason for hiding this comment

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

LGTM! Nice work!

@agliga agliga merged commit 102ea39 into eBay:18.3.0 Sep 27, 2024
@github-actions github-actions bot mentioned this pull request Sep 27, 2024
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.

6 participants