-
Notifications
You must be signed in to change notification settings - Fork 4.7k
Global styles: add custom CSS panel to site editor #46141
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
Merged
Merged
Changes from 1 commit
Commits
Show all changes
39 commits
Select commit
Hold shift + click to select a range
9c926f3
Try adding a custom CSS panel to global styles
glendaviesnz 64d22a9
Update screen-css.js
carolinan 28b5fb6
Update
carolinan c0bfa6b
Fix fatal error and update compat directory
Mamaduka 0678fa8
No need to enable REST API support for custom_css post type
Mamaduka d9cced1
Fix PHPLint errors
Mamaduka a5b66c2
Switch to using core data store instead of direct fetches to API
glendaviesnz 6473e7d
Render the custom css into the site editor
glendaviesnz 144cee4
Switch to the useEntityRecord hook
glendaviesnz 49ede18
remove use of custom_css post type as switching to use global styles
glendaviesnz 31919b3
Switch to using global styles to store the custom css
glendaviesnz f13667c
Fix useMemo dependencies
Mamaduka 23792ef
The 'css' value should be string
Mamaduka 28fc3b0
Add custom css to editor settings
glendaviesnz 607b48e
Refactor globals css in site editor now custom css in editor settings
glendaviesnz 2304cd3
Add test for customCSS in get_stylesheet
glendaviesnz f562190
update rest endpoints
glendaviesnz 76e3a78
Fix linting issues
glendaviesnz 08846c0
Fix file naming issue
glendaviesnz 4cc2a0e
Fix issue with not being able to remove existing custom css
glendaviesnz c5f05d7
Fix casing of php function param
glendaviesnz a6a67ad
make input font monospace
glendaviesnz 035ce94
Move the custom css to its own stylesheet so invalid styles don't bre…
glendaviesnz 472b828
Add custom css to its own stylesheet instead of combining with other …
glendaviesnz e8a5bf9
Update the option wording
glendaviesnz 83244a5
use the merged config for custom css so theme.json settings picked up
glendaviesnz 3041744
Use sass var for mono font
glendaviesnz 4794a7c
remove some irrelevant nesting
glendaviesnz 01a7bb4
Update label wording
glendaviesnz feeea4f
Always return settings
Mamaduka c933a60
Remove mobile block as probably not needed
glendaviesnz a1004ba
Port the prepare_items_for_response method in order to pick up new th…
glendaviesnz 414c928
make prepare_item_for_response same as core to make backporting easier
glendaviesnz abdf4a9
Make sure the get_user_data call is always called at least once by th…
glendaviesnz 43b29dd
Fix test and linting issues
glendaviesnz d716585
Use instanceof instead of is_a
glendaviesnz 1df72bf
Add theme.json custom css to input box
glendaviesnz 47a6d91
Add explanatory comments
glendaviesnz b55429d
Changes from code review
glendaviesnz File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Add explanatory comments
- Loading branch information
commit 47a6d915f8553a45d9d2702e0d372e883ac3151e
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Hi there! I was trying to refactor this control to be like all the other "style" UI components and stumbled upon this specific behavior for custom CSS, where it seems that we need to be aware of "base" styles and have some custom behavior tied to it. Can you explain it a bit further and also why it has to be this way, why don't we treat the "css" theme.json property like any other property?
Uh oh!
There was an error while loading. Please reload this page.
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.
Some initial testing showed that it was confusing that any theme.json custom CSS was overridden completely by any custom CSS added as initially it took the same approach as other global styles in that user styles override the theme.json settings. For example, the theme.json CSS might set a heading font color, and the user may add a paragraph font family which will wipe the heading font color.
So a decision was made to include the theme.json CSS in the global styles input box to allow the user to make a conscious choice about which ones to keep.
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.
For me this is only confusing, if the CSS is not shown initially in the box.
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.
Re-reading this, it seems like you're saying that we're already showing the theme.json CSS in the box, which is what I would expect as well, but I guess the different maybe when we edit that CSS.
For me, after editing, we should only show the edited CSS (which may or may not contain some parts of the original theme.json CSS).
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.
Sorry for the confusion. This is correct, this is what happens, after editing only the edited CSS shows in the input, and the original CSS from the theme.json shows above the input in case the user wants to reinstate it:
custom-css.mp4