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

Block style variant preview styles #7769

Closed
samikeijonen opened this issue Jul 7, 2018 · 10 comments
Closed

Block style variant preview styles #7769

samikeijonen opened this issue Jul 7, 2018 · 10 comments
Labels
[Feature] Theme Style Variations Related to style variations provided by block themes [Status] Needs More Info Follow-up required in order to be actionable. [Type] Enhancement A suggestion for improvement.

Comments

@samikeijonen
Copy link
Contributor

For example Button block have 3 style variants. In the editor I can bring my own styles for these variants.

For example default button style:

button default style

However in the preview styles seems to come from default Core styles:

button default style preview

I'd except my styles to work on preview automatically. This was kind of hard to debug since the preview was populated dynamically on hover.

For the button block itself I have .edit-post-visual-editor .wp-block-button__link {}.

@karmatosed
Copy link
Member

I agree the preview should be 'what you'd expect in theme using'. I am not sure in saying that the technical implications, but let's find out!

@karmatosed karmatosed added [Feature] Blocks Overall functionality of blocks [Type] Enhancement A suggestion for improvement. labels Jul 11, 2018
@karmatosed karmatosed added this to the Merge Proposal: Editor milestone Jul 11, 2018
@ZebulanStanphill
Copy link
Member

@samikeijonen Just to be clear, do the preview styles look like what the block looks like in the editor, and do the editor styles look like the theme styles?

I guess this kind of comes back to long-term wanting Gutenberg to directly use the main theme CSS to style blocks in the editor. What were the obstacles to having that right now? @karmatosed

@samikeijonen
Copy link
Contributor Author

@SuperGeniusZeb I have screenshots in the first comment what the block looks like in the editor, and what does it look like in the preview.

Note that I dequeue wp-core-blocks and even deregister wp-core-blocks-theme. That's why it's even more weird that I get "Core styles" in the preview from somewhere.

@mtias mtias modified the milestones: Merge: Editor, WordPress 5.0 Oct 12, 2018
@youknowriad
Copy link
Contributor

youknowriad commented Oct 23, 2018

@samikeijonen I think the issue is that you're using .edit-post-visual-editor as a namespace and since popovers are rendered outside of the editor’s namespace it doesn’t work.

Can I suggest to just use .wp-block-button__link {} to style your button and enqueue the style using the editor styles https://wordpress.org/gutenberg/handbook/extensibility/theme-support/#editor-styles ?

@youknowriad
Copy link
Contributor

Noting that I also opened this PR #10956 which make sure we explicitly apply the editor styles (provided following the approach from the link above) to the previews.

@samikeijonen
Copy link
Contributor Author

Thanks @youknowriad. True, I was using .edit-post-visual-editor as a namespace.

I tried the editor styles way but that didn't quite worked for me. At the moment I'm using PostCSS to roll namespace automatically. I'll let you know what I come up with.

@strarsis
Copy link
Contributor

Would hovering a variant selection already show a preview in editor?

@youknowriad
Copy link
Contributor

youknowriad commented Oct 24, 2018

@strarsis It shows a preview on the right of the "popover", not directly in the editor. (like the mockup above)

@mtias mtias removed this from the WordPress 5.0 RC milestone Nov 12, 2018
@mtias mtias added the [Status] Needs More Info Follow-up required in order to be actionable. label Nov 12, 2018
@designsimply designsimply added [Feature] Theme Style Variations Related to style variations provided by block themes and removed [Feature] Blocks Overall functionality of blocks labels Nov 30, 2018
@designsimply
Copy link
Member

@samikeijonen I can help test this but would need really clear instructions. Any chance you can provide a code snippet for your button style variation and help me understand exactly where to add it for testing?

@samikeijonen
Copy link
Contributor Author

@designsimply In my short test button variant styles now works. I'm going to close this for now, I'll re-open if I find something.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] Theme Style Variations Related to style variations provided by block themes [Status] Needs More Info Follow-up required in order to be actionable. [Type] Enhancement A suggestion for improvement.
Projects
None yet
Development

No branches or pull requests

7 participants