-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Add preferences modal to site editor #39485
Conversation
Size Change: +1.71 kB (0%) Total Size: 1.16 MB
ℹ️ View Unchanged
|
export default function EnableFeature( props ) { | ||
const { featureName, ...remainingProps } = props; | ||
const isChecked = useSelect( ( select ) => | ||
select( preferencesStore ).get( 'core/edit-site', featureName ) |
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.
select( preferencesStore ).get( 'core/edit-site', featureName ) | |
( select ) => | |
select( preferencesStore ).get( 'core/edit-site', featureName ), | |
[ featureName ] |
Missing dependency.
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, everything works.
I left one minor code and one minor design-related comment. It's up to you which way you take it.
export default function EnableFeature( props ) { | ||
const { featureName, ...remainingProps } = props; | ||
const isChecked = useSelect( ( select ) => | ||
select( preferencesStore ).get( 'core/edit-site', featureName ) |
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 maybe just coerce this into a bool to be on the safe side 😄
select( preferencesStore ).get( 'core/edit-site', featureName ) | |
!! select( preferencesStore ).get( 'core/edit-site', featureName ) |
} | ||
return ( | ||
<PreferencesModal closeModal={ toggleModal }> | ||
<PreferencesModalTabs sections={ sections } /> |
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 does still feel a bit empty with one setting per tab. I wonder if right now an option could be to not add the tabs until there are more settings later on, and instead render the two PreferenceModalSection
s directly in the modal.
I don't know if the styles will work out of the box, but it might be possible to make some quick fixes there.
Could be good to get some design feedback on it 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.
I think tabs will fill up faster now that we've modal.
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.
Should be pretty easy to get the block manager in there as well now.
I think the component needs to be moved out of edit-post
, but the rest of the implementation shouldn't be too difficult.
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.
Yeah, I added the second tab mainly thinking about the block manager which takes up a huge chunk of space 😄
Plus with #38317 there'll be at least one more item under Appearance 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.
This looks and works great. Thanks, @tellthemachines.
As you mentioned, we can progressively add new preferences and sections.
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.
Looks good and works as expected when compared to the post editor.
@jasmussen Seeing this made me wonder if modals like this should contract to a smaller height if there's not enough content to fill it up? I guess the issue there would be changing tabs and the height of the modal changing?
Oh yeah absolutely, a whole iteration could be spent making modals have the right size, both intrinsicaly and across the board. Right now there are a bunch of conflicting and messy media queries and we could definitely be smarter there. I do think that without an explicit width attached, it'll collapse to the content, so yes that means it would shift between tabs as well. We encountered that with a recent Patterns explorere view where the window would flicker as the patterns loaded. It'd be nice if there was a smart way we could handle that, without a bunch of different min-heights. |
* Add preferences modal to site editor * Add spotlight feature * Add caret inside block setting * Improvements to enable feature selector.
What?
This PR adds the Preferences modal to the site editor, with the aim of later filling in all the preferences we might find useful.
Why?
Split off from this comment. Tl,dr: in order to add more user preferences common to all editors, it's best to show them in a common UI.
Related: #31965
How?
Adds the recently abstracted reusable PreferencesModal from the interface package. For now, this adds only the "Spotlight mode" preference umder "General" and the "Contain text cursor inside block" preference under "Blocks". The plan is to progressively add all the other settings that make sense in the site editor, such as "Display button labels" (in progress: #38317) and the "Visible blocks" section. Suggestions welcome as to which other options we might add 🙂
Testing Instructions
Screenshots