Skip to content
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

Incorporate outside styles sooner rather than later #422

Closed
joyously opened this issue Apr 13, 2017 · 11 comments
Closed

Incorporate outside styles sooner rather than later #422

joyously opened this issue Apr 13, 2017 · 11 comments
Labels
Framework Issues related to broader framework topics, especially as it relates to javascript [Type] Task Issues or PRs that have been broken down into an individual action to take

Comments

@joyously
Copy link

In the discussion for what to include on #356 (Allow editing actual posts and pages), it seems that only half of the editing experience is being addressed. The actual post content is needed to have something to edit, but the context of presentation of that content is missing.

The current WP editor allows the presentation of the Visual mode to be adjusted using additional stylesheets. Themes can add this using add_editor_style(), which by default is named editor-style.css.

I expect that capability still needs to exist in the new editor, and allowing for it at the beginning will keep clear what styling belongs in the editor and what is left to the theme, and how they might interact.

I suggest that the minimum of styling would be a content font and background color so transitions between blocks are easy to spot. Then the WordPress standard classes similar to as defined on https://codex.wordpress.org/CSS would show how the edits are applied as classes. I know it's early to expect that whole flow to work, but I think it's important to start with it in order to keep the goal in mind. You also won't be able to control what styles are fed in, so if a theme uses a generic selector like div, will that break your look?

@nylen nylen added [Type] Task Issues or PRs that have been broken down into an individual action to take Framework Issues related to broader framework topics, especially as it relates to javascript Good First Issue An issue that's suitable for someone looking to contribute for the first time labels Apr 17, 2017
@nylen
Copy link
Member

nylen commented Apr 17, 2017

It would probably be good to do this as a separate stylesheet (gutenberg-style.css), at least at first so that we can learn more about the necessary differences between classic editor-style.css and the equivalent for the new editor.

Further reference:

@BE-Webdesign BE-Webdesign self-assigned this Apr 26, 2017
BE-Webdesign added a commit that referenced this issue Apr 26, 2017
Fixes #422.  Added an action so that someone could hook into where
gutenberg styles are loaded and bring in an editor style of their own.
I took this approach, as there is not a super clean way to mimic
`add_editor_style()` without adding another global variable to
WordPress, without PHP 5.3+, that I could find.
@ellatrix
Copy link
Member

ellatrix commented Apr 26, 2017

I'm still not sure if adding editor styles to WP core was a good idea. @azaozz may have thoughts on this too.

@BE-Webdesign
Copy link
Contributor

That is a great point. I have made lots of use of editor styles in my themes, but with where Gutenberg is going, it is pretty easy to render the editor in the front end of the theme and just use it that way. So potentially editor styles won't really be necessary.

@joyously
Copy link
Author

it is pretty easy to render the editor in the front end of the theme and just use it that way.

This makes no sense to me. Isn't the editor a page in the admin, regardless of the theme perhaps rendering it somewhere else? And the goal is to make the Visual mode look like the front end will look? If this will just be an iframe like the Preview is now, I understand that the theme is doing all the styling. But if not, isn't the theme going to need to put dynamic styling in so the Visual mode looks like it will on the front end?

@BE-Webdesign
Copy link
Contributor

Isn't the editor a page in the admin, regardless of the theme perhaps rendering it somewhere else?

To me the editor is wp.editor. It is currently rendered in an admin page for this plugin.

And the goal is to make the Visual mode look like the front end will look?

Maybe, I think the goal is to provide an easier way to edit for those who do not know HTML. I do agree that editor styles currently are very useful, but maybe there is room here to make maintenance of the WordPress project easier by not introducing them for the new editor, and instead provide an even better experience by having live editing in the theme, which could be introduced in a separate plugin.

But if not, isn't the theme going to need to put dynamic styling in so the Visual mode looks like it will on the front end?

It's currently possible to do this right now, if you really wanted to. I don't think the main goal of Visual mode is to match the front end, it simply provides an easy to use editor instead of working with HTML directly. Rather than rushing to adding editor-styles 2.0 we could explore better alternative solutions.

@jasmussen
Copy link
Contributor

One "problem" with editor styles, which we probably don't want to tackle with this focus, is that it's a separate stylesheet for theme authors to create and maintain. Just philosophically it would be nice if a theme author did not have to create a separate style, but that the editor could infer the styles from the main style.css file automatically.

@joyously
Copy link
Author

joyously commented Apr 27, 2017

With the theme supplying styles for the Customizer, the theme usually has a function that emits the dynamic styles, so at least that part could be "registered" with the editor. However, the selectors might not be quite right, which is why the editor-style is separate in the first place.
And again, I think the theme has more to consider in terms of layout and screen size than the editor should be concerned with.

@nylen
Copy link
Member

nylen commented May 15, 2017

Quoting from a Slack conversation with @aduth

there’s been some chatter about how themes could define support for blocks or block controls (like image full bleed). maybe something with that and add_theme_supports ?

seems we might need to allow a base stylesheet for a block, plus editor and/or front-end specific extras

So, this likely means that more blocks will need to register themselves on the server side, and we'll need to allow the register_block function to accept values for these stylesheets.

Edit: also worth considering: themes themselves will probably want to add styles for individual blocks.

@nylen nylen removed the Good First Issue An issue that's suitable for someone looking to contribute for the first time label May 15, 2017
@BE-Webdesign BE-Webdesign removed their assignment May 26, 2017
@mtias
Copy link
Member

mtias commented Jun 22, 2017

Closing in favor of #963.

@mtias mtias closed this as completed Jun 22, 2017
@jdevalk
Copy link
Contributor

jdevalk commented Jun 22, 2017

You're closing in favor of itself? :)

@mathetos
Copy link

@mtias This is a very different conversation from #963 -- 963 is about front-end Gutenberg styles (I blelieve primarily layout oriented), while this convo is primarily about backend styles that the Theme could enqueue to allow Gutenberg to look more like the theme content styles.

Wouldn't you say this is still worth discussing over here separate from 963?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Framework Issues related to broader framework topics, especially as it relates to javascript [Type] Task Issues or PRs that have been broken down into an individual action to take
Projects
None yet
Development

No branches or pull requests

8 participants