-
Notifications
You must be signed in to change notification settings - Fork 69
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
Conversation
fix(file-upload): update css feat(file-upload): fix css feat(file-upload): add modules feat(file-upload): fix module grammar
🦋 Changeset detectedLatest commit: 9add60c The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
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 |
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 quick work @kentokage! I started with a few comments, but before I go further with the nitpicks I have a few high-level questions:
- 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. - 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):
- 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 forcinggap
to be32px
as labeled in the design.
Definitely will do 1, and play around to make 2 work, which should also solve 3 |
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.
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.
src/modules/card.marko
Outdated
@@ -0,0 +1,378 @@ | |||
<div id="card"> |
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 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
src/sass/card/card.scss
Outdated
height: inherit; | ||
width: inherit; |
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.
Are these styles needed? They seem redundant.
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.
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
src/sass/card/card.scss
Outdated
@media screen and (max-width: $_screen-size-MD) { | ||
.card { | ||
width: $card-size-large; | ||
|
||
.card__container { | ||
height: $card-size-large; | ||
} | ||
} | ||
} |
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.
We usually put our media queries at the end of the file, so they're easy to be found.
src/sass/card/card.scss
Outdated
.card__label.icon-btn { | ||
@include bubble-close(); | ||
|
||
position: absolute; |
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.
Why do we need position absolute. We should be able to put these inline I assume and style it that way.
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.
Hmm I thought that was a simpler approach. I can use css grid and define quadrants where we can place these elements. Wdyt?
src/sass/card/card.scss
Outdated
.card .card__action { | ||
@include bubble-close(); | ||
|
||
position: absolute; |
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.
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"; |
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.
Interesting.
This is possibly a good pattern we can use in the future!
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 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
src/sass/variables/_variables.scss
Outdated
$card-size-default: 132px; | ||
$card-size-large: 168px; |
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.
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
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 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?
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.
Removed these since the sizes will be dynamic and dictated by the parent
dist/card/card.css
Outdated
background: none; | ||
background: var(--color-background-on-secondary, #fff); |
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.
Two backgrounds here
src/sass/card/card.scss
Outdated
top: var(--spacing-100, 8px); | ||
right: var(--spacing-100, 8px); | ||
margin: 0; | ||
background: var(--color-background-on-secondary, #fff); |
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.
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);
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'm not following, why would we provide a variable that is not defined in the first arg for the mixin?
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 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.
dist/variables/_variables.scss
Outdated
@@ -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; |
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 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.
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.
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
src/modules/card.marko
Outdated
<div class="card"> | ||
<div class="card__container"> | ||
<div class="card__content"> | ||
<progress class="progress-bar" value=60 max=100/> |
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.
You need double quotes for attributes.
src/modules/card.marko
Outdated
<div class="card"> | ||
<div class="card__container"> | ||
<div class="card__content"> | ||
<progress class="progress-bar" value=60 max=100/> |
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.
You need double quotes for attributes.
src/modules/card.marko
Outdated
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 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.
src/modules/card.marko
Outdated
</div> | ||
|
||
<highlight-code type="html"> | ||
<div class="card"> |
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 we need 3 layers here before we get to the content?
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.
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
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 refactored it to remove the middle .container
layer
src/sass/card/card.scss
Outdated
@import "../variables/variables"; | ||
|
||
.card { | ||
display: flex; |
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 we need flex
here? These are standalone cards. I'm not seeing any complex structure inside.
src/sass/card/card.scss
Outdated
} | ||
|
||
.card__container { | ||
position: relative; |
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.
Why do we need relative
positioning 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.
Andrew had posted a similar comment earlier
#2435 (comment)
src/sass/card/card.scss
Outdated
|
||
.card__container { | ||
position: relative; | ||
height: $card-size-default; |
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.
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.
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.
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?
src/sass/card/card.scss
Outdated
height: $card-size-default; | ||
} | ||
|
||
@media screen and (max-width: $_screen-size-MD) { |
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.
We should be using the min-width
approach instead. Have the default for the smallest screen and then enlarge as needed.
src/sass/card/card.scss
Outdated
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.
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.
Whoops, changed it to 18.3.0 Yep I ran |
Pending work
|
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.
Overall, it's looking great!!! A few minor things I found...
--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; |
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.
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); |
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.
Let's use the spacing vars from evo-core
throughout instead of raw pixels for gaps.
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 am using it, but I'll remove the fallback value
export const base = () => ` | ||
<div class="file-preview-card-group"> | ||
<ul> | ||
<li>${squareImage()}</li> |
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 beautiful!!!
<h3>Base</h3> | ||
<div class="demo"> | ||
<div class="demo__inner"> | ||
<div class="file-preview-card-group"> |
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.
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); |
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 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; |
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.
Use spacing css
props.
</svg> | ||
</span> | ||
<span class="inline-notice__main"> | ||
<p>Upload failed</p> |
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.
Doesn't this individual card need something to indicate an error for screen readers?
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 removed
</div> | ||
`; | ||
|
||
export const portraitDoc = () => ` |
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 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.
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'll remove these PDF examples since the general one should cover it
</div> | ||
`; | ||
|
||
export const landscapeDoc = () => ` |
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 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.
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'll remove these PDF examples since the general one should cover it
</div> | ||
`; | ||
|
||
const portraitDocWithTitle = () => ` |
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 change all the PDF stories to match Skin as "other" than image - generic icon.
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.
Minor doc changes, we also need to iron out aria-labels across the docs
src/sass/file-preview-card-group/stories/file-preview-card-group.stories.js
Outdated
Show resolved
Hide resolved
src/sass/file-preview-card/stories/file-preview-card.stories.js
Outdated
Show resolved
Hide resolved
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.
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--> |
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.
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.
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.
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
So one last question before we merge this: should we rename from |
@ianmcburnie My intention with |
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 took one last look. Looks good. Just a couple of last things.
// - pixel values | ||
|
||
// Minimal Layout (default) | ||
$_row-preview-cards-min: 2; |
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.
SASS vars in modules are inherently private to the module. Underlines are not necessary. Let's please just remove them ti simplify.
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.
Very cool! Great work @kentokage ! Much appreciated.
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.
LGTM! Nice work!
Fixes # #2428
Description
This is the first iteration (alpha) of
file-upload
. Two building block components createdfile-preview-card
andfile-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
// rtl
file-preview-card
// uploading
// images
// video


// docs



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

// RTL

// 512 container
// 768 container
See skin app and storybook for more responsive breakpoints
Checklist