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

Dynamic CSS for custom block #9959

Closed
prajaktagadhave opened this issue Sep 17, 2018 · 3 comments
Closed

Dynamic CSS for custom block #9959

prajaktagadhave opened this issue Sep 17, 2018 · 3 comments
Labels
[Type] Help Request Help with setup, implementation, or "How do I?" questions.

Comments

@prajaktagadhave
Copy link

How to add CSS for before after pseudo element in Gutenberg block?

As no unique id generated on the frontend, is there another way to write CSS for pseudo-element?

@Soean Soean added the [Type] Help Request Help with setup, implementation, or "How do I?" questions. label Sep 17, 2018
@aduth
Copy link
Member

aduth commented Sep 17, 2018

Can you expand on your use-case? Is it possible that CSS variations could be applied either through a customClassName (the "Advanced" > "Additional CSS Class" inspector field) or by saving an attribute for your dynamic block which, on the server, is applied to the generated markup as a class?

Preemptively closing, but let's reopen if the question remains unsettled.

@prajaktagadhave
Copy link
Author

We have a custom block where we used some arrow with pseudo-elements. We want to change the color of this arrow as per color selection blockwise.

For eg. For block 1 arrow color should be red. And if I duplicate the block 1 then second block color should be changed to 'green'.

Reference screenshot - https://goo.gl/hZ9YP6

@aduth
Copy link
Member

aduth commented Sep 17, 2018

From what I understand then, the color would be user-selected? In which case, I might suggest storing this value as an attribute of the block, which can then be accessed in the server-side implementation of your block.

The components are here, though not documented at the moment (cc @jorgefilipecosta in case I'm missing some):

https://github.com/WordPress/gutenberg/tree/master/packages/editor/src/components/colors

I expect it would work very similarly to the color options for both the Paragraph and Button blocks, in case you want to reference those in the meantime:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Type] Help Request Help with setup, implementation, or "How do I?" questions.
Projects
None yet
Development

No branches or pull requests

3 participants