-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Font Library: fix modal width on mobile viewport #54518
Conversation
isFullScreen={ true } | ||
isFullScreen |
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 improvement
Size Change: +14 B (0%) Total Size: 1.62 MB
ℹ️ View Unchanged
|
Flaky tests detected in b12c27f. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/6276313002
|
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.
Nice! I left a small question, but this is a good catch, thank you!
&.is-full-screen { | ||
|
||
@include break-medium() { | ||
width: 65vw; |
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.
Can we build this into the modal component itself? Mainly, I'd love to avoid as much local software as possible.
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 review!
Can we build this into the modal component itself?
Does this mean that the width is controlled by JavaScript rather than a stylesheet? If so, I can change the approach to something like this, for example:
function FontLibraryModal() {
const isLargeViewport = useViewportMatch( 'medium' );
return (
<Modal
style={ { width: isLargeViewport ? '65vw' : undefined } }
></Modal>
);
}
Or do you mean adding width constraints to the base modal component itself?
.components-modal__frame {
&.is-full-screen {
@include break-medium() {
width: 65vw;
}
}
}
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 meant the latter, that ideally we have an excellent default behavior for the modal component, and we provide overrides on a per-component basis only as an exception.
I've heard someone mention an idea to build in "small", "medium", and "large" props into the modal, so that there's some variety in responsive behaviors. But all that boils down to is to have fewer local overrides, ideally. What do you think?
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.
Well, that might make sense. Currently, there are only two width variations for the modal component: the default auto-width or the full-width with the isFullScreen
prop opted in.
However, the Font Manager has only recently been implemented, so as the UI and UX improve, the width may change, or this override style itself may become unnecessary, or may be displayed in full screen.
Considering this, I think there is no problem in fixing the bugs and pushing forward with PR for now.
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.
Hey all, we've been starting work on this very feature last week — a PR is up, although I haven't had the time to take a look at it just yet.
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 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 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.
Just temporarily blocking the merge of this PR based on #54518 (comment)
@matiasbenedetto what's the deadline for #54471 to be merged? |
Font Library is going live in Gutenberg 16.7 so next Monday is the deadline I guess. |
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.
In that case, let's go with the plan proposed by @matiasbenedetto — let's merge this PR as a quick fix and refactor it once #54471 gets merged (cc @chad1008 for visibility)
@@ -1,4 +1,11 @@ | |||
.font-library-modal { | |||
&.is-full-screen { |
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 there a way we can avoid using is-full-screen
? It is an internal classname used by the component and therefore it shouldn't be used by its consumers.
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 selector is required for increased CSS specificity. However, as I mentioned in this comment, we can remove this CSS by using the useViewportMatch
hook instead. What do you think about the hook approach?
Or, I think it can be solved by duplicating the component selectors:
.font-library-modal {
&.font-library-modal {
@include break-medium() {
width: 65vw;
}
}
}
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'd be ok with any of the two approaches
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.
OK, I used the approach of nesting .font-library-modal
selectors. At the same time, I added the TODO comment to remind us to refactor 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.
Thank you! I guess you can go ahead and merge this PR, given that folks were already OK with the styles applied.
Thank you! I would like to merge this PR since I'm getting the expected results with the updated selector ( |
* Font Library: fix modal width on mobile viewport * Don't use internal selector * Fix typo
I just cherry-picked this PR to the release/16.7 branch to get it included in the next release: 065bccb |
What?
Why?
I think the modal should always be displayed full width in mobile viewports.
How?
I applied the width style via the media query when the viewport width is medium or higher.