-
Notifications
You must be signed in to change notification settings - Fork 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
SPT: Isolate TemplateSelectorControl component #38445
Conversation
3cbbe53
to
e06b61a
Compare
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 left a few questions about SASS variables.
// Preview positioning | ||
$preview-max-width: 960px; | ||
$preview-right-margin: 24px; | ||
$preview-left-sidebar-reduced: calc( 30% + #{$wp-org-sidebar-reduced} ); | ||
$preview-left-sidebar-full: calc( 30% + #{$wp-org-sidebar-full} ); | ||
|
||
$template-large-preview-title-height: 120px; |
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 believe these will become global, there's no module-scoping of variables in SASS.
It would be good to make sure "local" variables have namespace style prefixes.
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 copied all of this from existing SPT styling 😅 Think there's potential for regression?
$wp-org-sidebar-reduced: 36px; | ||
$wp-org-sidebar-full: 160px; |
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 meant to replace some existing variables? This seems dangerous, see my other comment about global variables and namespaces.
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 they're just used by SPT for some calculations.
We could use these upstream vars though: https://github.com/WordPress/gutenberg/blob/fdd69535ecbec018bfabad783c890de3d72b7e07/packages/base-styles/_variables.scss#L30-L32
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.
$template-selector-modal-offset-right: 32px; | ||
$template-selector-blank-template-mobile-height: 70px; | ||
|
||
@mixin screen-reader-text() { |
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.
Isn't this mixin either in Calypso or Gutenberg base styles already? Could we import it from there?
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 couldn't find it in Calypso upon a quick search. It appears to be in Gutenberg, https://github.com/WordPress/gutenberg/blob/bfd1117846c7802d62dbba046c27968d961781e7/packages/block-editor/src/components/responsive-block-control/style.scss#L1-L12, so we might be able to use that -- unless there's more implicit dependencies (like this: WordPress/gutenberg#19159).
Overall, this PR is just moving around pre-existing styling; I'd like to limit changes that go beyond that in order to unblock it soon 😬
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 might actually want to use that entire component rather than just its styling.)
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 moving things around in this PR makes sense. 👍
$template-selector-border-color-selected: #555d66; | ||
$template-selector-border-color-active: #00a0d2; | ||
$template-selector-border-color-hover: #c9c9ca; | ||
$template-selector-empty-background: #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.
While it's ok to have them here, should these variables be pulled in from Gutenberg base styles or color studio? I.e.:
$template-selector-empty-background: $white;
|
||
// Template Selector Preview | ||
.template-selector-preview { | ||
@media screen and ( max-width: 659px ) { |
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 have mixins or variables available in Gutenberg for these screen sizes?
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.
Couldn't find any (tried grepping 660px
and 659px
).
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.
Gotcha — I guess in some follow up some day we could re-use breakpoints from ~@wordpress/base-styles/breakpoints
$preview-max-width: 960px; | ||
$preview-right-margin: 24px; | ||
$preview-left-sidebar-reduced: calc( 30% + #{$admin-sidebar-width-collapsed} ); | ||
$preview-left-sidebar-full: calc( 30% + #{$admin-sidebar-width} ); |
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.
Will $admin-sidebar-width
work both in wp-admin when WP sidebar is visible and when Gutenberg is iframed in Calypso and the sidebar is hidden?
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.
idk 😅 -- But all I did in f4adda3 is remove two SASS var definitions with two other ones that I'm importing from @wordpress/base-styles
. That shouldn't change any behavior, should it?
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.
That shouldn't change any behavior, should it?
It shouldn't indeed and sounds fair! :-) Just good to test both scenarios anyway always when CSS is touched for anything FSE plugin related.
Left a few scss variables questions as well — I haven't tested so I'm little ignorant about how things actually work, hence some questions might not make sense. 😁 Hope this helps anyway! |
@@ -0,0 +1,189 @@ | |||
@import '~@wordpress/base-styles/variables'; |
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 WordPress/gutenberg#19159 is an issue at the moment, you could also import the whole set via this file:
@import '~@wordpress/base-styles/z-index'; | |
@import '~@wordpress/base-styles/colors'; | |
@import '~@wordpress/base-styles/variables'; | |
@import '~@wordpress/base-styles/breakpoints'; | |
@import '~@wordpress/base-styles/mixins'; | |
@import '~@wordpress/base-styles/animations'; |
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 pushed be80333 which seems to be enough.
Ehm... this PR says hi: #38065 😅 |
Closing; obsolete as of #38456. |
Here is how your PR affects size of JS and CSS bundles shipped to the user's browser: App Entrypoints (~30 bytes added 📈 [gzipped])
Common code that is always downloaded and parsed every time the app is loaded, no matter which route is used. Legend What is parsed and gzip size?Parsed Size: Uncompressed size of the JS and CSS files. This much code needs to be parsed and stored in memory. Generated by performance advisor bot at iscalypsofastyet.com. |
Changes proposed in this Pull Request
Isolate
TemplateSelectorControl
component, and rename toTemplateSelector
.While working on #38403, I discovered that
TemplateSelectorControl
's styling is a bit weird, and doesn't lend itself easily to removing the white bar at the bottom of each item that contains the template name.This is due to some
padding-top: 100%
, absolute positioning, translating, etc. I think that we can achieve the same styling in a more semantic way, that will also allow us to conditionally remove the label.To that end, I'd like to isolate the
TemplateSelectorControl
component and styling, so it becomes easier to modify them, since currently, there's just one big style file in FSE.This PR renames
TemplateSelectorControl
toTemplateSelector
, and moves it (and its dependencies, and styling) to a separate folder.Testing instructions
apps/full-site-editing/full-site-editing-plugin/starter-page-templates/page-template-modal/components/template-selector/test/
:cd apps/full-site-editing/ && npm ci && npm run test:unit