Opened 8 years ago
Last modified 4 years ago
#38707 new enhancement
Customizer: Additional CSS highlight, revisions, selection, per-page, pop-out
Reported by: | folletto | Owned by: | |
---|---|---|---|
Milestone: | Future Release | Priority: | normal |
Severity: | normal | Version: | |
Component: | Customize | Keywords: | needs-patch |
Focuses: | Cc: |
Description
This ticket is to track the next steps of Additonal CSS after 4.7. See #35395 for the discussion so far.
The MVP of the Additional CSS editor in customizer included the basic UI, navigation and backend work.
There are various next steps that area already included in the design above, and can be done either in a single next release or staggered further as needed. From the latest discussed design, the features we already have ready to build are:
- Syntax Highlighting
- Revisions
- Selection of items on the page (CSS selector)
- Per-Page CSS as a complement of the current site-wide CSS for better management
- The ability to pop-out the editor in a separate window for a more comfortable editing experience
Just one special note regarding revisions: we might want to not do CSS revisions, and instead build the more flexible and general revision UI for the customizer as a whole. That's being discussed in #31089.
Attachments (5)
Change History (48)
#1
@
8 years ago
@folletto
What about global options for CSS?
So plugin CSS specific changes would be global and not be active theme dependant.
#2
@
8 years ago
What about global options for CSS?
So plugin CSS specific changes would be global and not be active theme dependant.
I'm not convinced about this: CSS is very very strongly DOM and the rest of theme-CSS dependent.
However, I might be biased here. Can you list potential situations where a CSS would translate well across themes so we can evaluate the extent of this feature?
#3
@
8 years ago
@folletto
Say for example a user is using the Jetpack subscribe widget on their site.
#subscribe-email input { width: 62%; padding: 1px 2px; } .comment-subscription-form .subscribe-label { display: inline !important; }
So that CSS is just related to plugin front-end changes and it not related to a theme.
#4
@
8 years ago
I'm not sure, even these seem risky to preserve on a theme change: what if the theme is overriding input fields with flexbox or different widths or margins? What if the inlining breaks entirely the forms?
I think the kind of user that would make use of this UI — which is surely more experienced than others, but also likely not a fully CSS experienced person — might get confused if they enabled a theme straight off and it looks "broken" due to some old lingering CSS they forgot about. That would trigger support emails to the theme author when it's really not the case.
This ticket was mentioned in Slack in #core-customize by melchoyce. View the logs.
8 years ago
#8
@
8 years ago
This ticket was mentioned in Slack in #core by melchoyce. View the logs.
8 years ago
This ticket was mentioned in Slack in #core-customize by melchoyce. View the logs.
8 years ago
This ticket was mentioned in Slack in #core by westonruter. View the logs.
8 years ago
#12
@
8 years ago
As noted in #12423, there is an inputStyle
for CodeMirror that is better for accessibility. Here is a CSS demo forked from @iseulde and @afercia: http://codepen.io/westonruter/pen/Graepj
Looks like the main thing missing in this pen is CSS autocomplete.
#13
@
8 years ago
customizer-css-revisions-i3.png is an update just including revisions, without any of the other enhancements. I've updated the styles to match my mockups in #21666.
customizer-css-revisions-i4.png is a potential second iteration, which specifically shows the additions and subtractions you made in each revision.
Both iterations would still update the preview on the right when you toggle between revisions.
#14
follow-up:
↓ 15
@
8 years ago
Looks solid, and nicely split into incremental steps :)
One clarification: I'm assuming the text in the i4 (the diff) is going to be "normal" text, not editable which makes things a bit easier. In that case, wouldn't be possible to have the + and the - in the gutter (like line numbers), aligned "outside" the text , instead of being "inside"?
#15
in reply to:
↑ 14
@
8 years ago
Replying to folletto:
One clarification: I'm assuming the text in the i4 (the diff) is going to be "normal" text, not editable which makes things a bit easier.
Yup! Also thinking we could add cursor: not-allowed
to reinforce that.
In that case, wouldn't be possible to have the + and the - in the gutter (like line numbers), aligned "outside" the text , instead of being "inside"?
Good idea. 👍
This ticket was mentioned in Slack in #core-restapi by westonruter. View the logs.
8 years ago
#17
@
8 years ago
For development, I think this will look like:
- Ensure that
custom_css
posts are exposed via the REST API. It may make sense to have a/customize/custom-css
endpoint, along with/customize/custom-css/twentyfifteen
for getting the post resource for the twentyfifteen theme and also/customize/custom-css/twentyfifteen/revisions
to get the list of revisions for that theme's custom CSS. Some discovery will be needed there for what makes the most sense, and whether or not the REST API should allow access tocustom_css
posts for non-active themes. See also #39634 and #38900, and questions on Custom CSS endpoints. - Create a custom customizer section for Custom CSS, instead of re-using the default section type. This custom section would have its UI augmented to show the “See CSS history” link, and when clicked to hide the controls (the textarea) and show the list of revisions (fetched via REST API). This custom section would also override the behavior of the back button to not cause the section to collapse but rather back out of viewing the list of revisions or previewing a revision at a given point. This might warrant also creating a custom control for the
textarea
input as well; see its custom styling and behavior. - When clicking on a revision, it needs to be previewed. This is a bit tricky, but the CSS from the
custom_css
post at that revision needs to be pushed into thecustom_css
setting so that it can be previewed. But a complication here is what if a user then clicks Save & Publish even though they didn't hit the Restore button? In this case, the Restore button would really not be doing anything other than collapsing the revision preview and revision list to then focus back on the textarea; similarly, the Back button would then also have to have the behavior of restoring the previous value for thecustom_css
setting, as clicking Back instead of Restore indicates the user didn't want to apply the setting change. This seems somewhat backwards, but it seems easier to implement than having a “preview preview”, some kind of preview change to a setting to preview without actually causing it to be written into the changeset.
This ticket was mentioned in Slack in #core-restapi by westonruter. View the logs.
8 years ago
This ticket was mentioned in Slack in #core-customize by westonruter. View the logs.
8 years ago
This ticket was mentioned in Slack in #core by jeffpaul. View the logs.
8 years ago
This ticket was mentioned in Slack in #core by jeffpaul. View the logs.
8 years ago
#24
@
7 years ago
👉 Please test the new 0.1.0 release for the “codemirror-wp” feature plugin—being worked on for 4.9. This plugin:
- Extends the Custom HTML widget to add syntax highlighting and checking
- Incorporates CodeMirror to the Additional CSS control in the Customizer
- Adds CodeMirror to the file editors for themes and plugins
See the plugin's GitHub releases page to download a ZIP for easy installation: https://github.com/WordPress/codemirror-wp
Report any issues at https://github.com/WordPress/codemirror-wp/issues
#25
@
7 years ago
@folletto @melchoyce CodeMirror has a full-screen mode which we could leverage for the “pop out” aspect of this ticket.
Demo: https://codemirror.net/demo/fullscreen.html
Plugin issue: https://github.com/WordPress/better-code-editing/issues/70
Since there is no site/page toggle in Custom CSS, then the full-screen icon would need somewhere else to live.
#26
@
7 years ago
CodeMirror has a full-screen mode which we could leverage for the “pop out” aspect of this ticket.
Note that the need "popping out" solves is one of the most requested features which is about the sidebar reducing the visibility/width of the site (triggering smaller responsive views) and space available to type. Going full screen would cover entirely the page, surely giving more space to type, but then making the site completely covered.
Thus, I don't consider it a solution for the problem it's trying to solve.
We might it consider as a partial solution, but... I'm not sure about that kind of intermediate take considering some people might still like it and would get disappointed when we change the implementation to a pop-out window.
Since there is no site/page toggle in Custom CSS, then the full-screen icon would need somewhere else to live.
If we're still working toward that i2 design, I'd still place it where it's going to be in the end. Even if it starts being just that icon I would still place it there. Maybe we can start with a visible label, to avoid the icon to hang alone.
If we're not sure if we're headed in that direction, then a good alternative position would be in the bottom "See CSS History" sticky bar, where the "pointer" feature is in i2 (right aligned).
#27
@
7 years ago
@folletto By “pop-out”, did you mean a separate browser window or a floating window that floats over the preview but is undocked to the left side?
#28
follow-up:
↓ 29
@
7 years ago
Separate browser window, as it allows the maximum flexibility.
See the design i2 at the top of this thread for design reference (the rightmost part). :)
#29
in reply to:
↑ 28
@
7 years ago
Replying to folletto:
Separate browser window, as it allows the maximum flexibility.
Yeah, +1 for what @folletto's said.
#32
in reply to:
↑ 31
@
7 years ago
Replying to mrahmadawais:
@westonruter I have added a patch that makes the info in Add CSS section look better by adding
kbd
elements. It looks like this now.
Please follow #41872 for this as the text may get rewritten into a single paragraph. Note also the overlapping kbd
elements cause an undesirable darker gray line where they overlap. So the padding would need to be reduced in this element.
#33
@
7 years ago
Regarding:
- Per-Page CSS as a complement of the current site-wide CSS for better management
I wrote a quick plugin which extends the Customize Posts plugin to add a “Custom CSS” control for each post/page section added to the Customizer : https://github.com/xwp/wp-customize-posts-css
The plugin is just a proof of concept in terms of per-page custom CSS, but mainly serves as a way to test the proposed new code editor customizer control in #41897.
See screenshots: https://github.com/xwp/wp-customize-posts-css#screenshots
#34
follow-up:
↓ 36
@
7 years ago
The plugin is just a proof of concept in terms of per-page custom CSS, but mainly serves as a way to test the proposed new code editor customizer control in
I'm not sure I understand... does this represent a step forward to later implement the Per-Page CSS, is that correct?
So that will come after #41897?
#35
@
7 years ago
- Priority changed from normal to high
Bumping priority to high for visibility and alignment with 4.9 goals, and given proximity to beta 1 deadline.
#36
in reply to:
↑ 34
@
7 years ago
Replying to folletto:
I'm not sure I understand... does this represent a step forward to later implement the Per-Page CSS, is that correct?
So that will come after #41897?
It's one approach to implementing Per-Page CSS. It's not intended to replace what is designed here, but rather to provide an alternative take on it. In Customize Posts, each post/page gets its own section added dynamically in the Customizer. These sections contain controls for managing each post's title, content, featured image, etc. So it just adds “Custom CSS” as another one of the fields (as a demonstration of the control in #41897). It then ties the CSS to the specific post/page (via meta), and allows those styles to apply on whatever template that post may appear on.
So that actually actually brings up something I've been wondering about in regards to:
Per-Page CSS as a complement of the current site-wide CSS for better management
What is the CSS linked with when you provide per-page CSS? Is it a “Page” page we're talking about or just some URL? Like would it allow a user to provide custom styling to a category archive page? If I supply styling for a category then does it get applied to page 2 and page 3 of the category's posts? In other words, are the customizations tied to the specific _URL_ or the “queried object”? This leads directly into one of the big challenges that @melchoyce and I have been thinking about for the future of the Customizer: how can users be informed when a change is local to the current “page” or global to all areas of the site?
#37
follow-up:
↓ 38
@
7 years ago
So it just adds “Custom CSS” as another one of the fields
Ok, now I understand. I'm not sure of the plan for Customize Posts tho, so I can't at this time evaluate which could be better. From what I understand, if Customize Posts lands, it would make sense to explore that direction in more depth.
What is the CSS linked with when you provide per-page CSS?
These are all good question that need to be sorted out. We need to figure out what's the best pattern to follow.
For example, a "high level" approach that we could use for testing would be to reuse the same set of classes specified by get_body_class()
. This however might get TOO granular and have unintended side effects, yet, it's where I'd probably start prototyping as it already exists.
Another approach could be to define a criteria that seems working well in most of the scenarios, striking a balance between all the various pages above: posts get tied to post ID, while categories apply to any category page.
Another approach would be to limit this strictly to Pages, Posts and Custom Post Types, which will provide a narrow scope that might be more feasible for a v1, and would also avoid any ambiguity.
Do you have a preference here?
This leads directly into one of the big challenges that @melchoyce and I have been thinking about for the future of the Customizer: how can users be informed when a change is local to the current “page” or global to all areas of the site?
Yes, this is a broader question, that I'd still try to avoid in the work done in this component specifically. The reason is that it's an issue at a higher order in the architecture, and should be addressed there instead of a per-feature UI. Once we have a higher-level pattern, we can review all the UIs to follow that pattern.
The reason I'm saying this is that I could imagine that, with Gutenberg in sight, the difference is dealt in the same way at a block level, either by having "global blocks" (instances that are flagged as such) or "templates" (layout schemes that can be reused across multiple screens). Or... maybe not.
It's a very important discussion to have tho. Is there another existing issue where it's better to discuss it?
#38
in reply to:
↑ 37
@
7 years ago
Replying to folletto:
This leads directly into one of the big challenges that @melchoyce and I have been thinking about for the future of the Customizer: how can users be informed when a change is local to the current “page” or global to all areas of the site?
Yes, this is a broader question, that I'd still try to avoid in the work done in this component specifically. The reason is that it's an issue at a higher order in the architecture, and should be addressed there instead of a per-feature UI. Once we have a higher-level pattern, we can review all the UIs to follow that pattern.
The reason I'm saying this is that I could imagine that, with Gutenberg in sight, the difference is dealt in the same way at a block level, either by having "global blocks" (instances that are flagged as such) or "templates" (layout schemes that can be reused across multiple screens). Or... maybe not.
I agree — I think our work informing global vs. local in Gutenberg will help us make a better decision here. Cool exploration, and let's keep it in mind for customization post-Gutenberg.
This ticket was mentioned in Slack in #core-customize by jeffpaul. View the logs.
7 years ago
#41
@
7 years ago
- Milestone changed from 4.9 to Future Release
- Priority changed from high to normal
The syntax highlighting aspect has landed with #12423. Note the “per-post” aspect has been yanked from consideration for the near future, as it depends on solving the local vs. global issue. So the remaining issues to be considered in the near term are: selector discovery, revisions, and popping the editor out into a new window. Let's work on these issues in a feature plugin outside of core and propose in future release.
Customizer CSS design i2