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

Advanced CSS selectors plugin for grapesjs #1496

Open
Tracked by #1473
lexoyo opened this issue Mar 11, 2023 · 4 comments
Open
Tracked by #1473

Advanced CSS selectors plugin for grapesjs #1496

lexoyo opened this issue Mar 11, 2023 · 4 comments

Comments

@lexoyo
Copy link
Member

lexoyo commented Mar 11, 2023

Why?

GrapesJS selector manager is used in Silex v3 to manage the CSS classes applied to the selected element(s). And to apply a style to these CSS classes

GrapesJS style manager

Here are use cases where this is not enough

  • In silex v3 users are designing with dynamic data, so sometimes we need to style selectors like .container img because the image is not selectable at edition time
  • When designing lists or cards, one need selectors and pseudo selectors: .list ul.cell::nth-child(odd) > li
  • Also when styling a rich text which comes from a headless CMS you need selectors like .my-text ul li
  • It would be nice to be able to style html tags (h2, nav...) in grapesjs
  • For now in silex v3 what we do is add CSS to the head editor but then these styles are not available in the style manager

Here are the ideas I could come up with in order to create a useful plugin for grapesjs

Solution 1

A UI for grapesjs css

  • UI to list, select, edit, add, delete css selectors present in grapesjs
  • code editor to edit the properties of the selected selectors

Solution 2

Just a code editor to edit all CSS

  • Code editor displaying the site css
  • Plug the code editor with grapesjs style manager so that the edited styles are also editable in the ui (if they are simple classes or ids)

Solution 3

Preview arbitrary selectors in the layers UI and add arbitrary selectors to the style manager

  • Add a text filed on top of the layers list
  • Type arbitrary css selector
  • Highlight the targeted elements or hide the others
  • [No? Or add a button "select targets"?] select elements in the list (+on stage, just use GrapesJS select with component find)
  • A button to "style selection" => adds the css selector to the site and select it in the style editor (firrst ask for its display name in the style manager)
  • Add a button to the style manager to edit the selector (in a dialog? In the layers?)
  • When the user renames the style from the style manager, make sure it works properly

About custom UI for Selector Manager: https://grapesjs.com/docs/modules/Selectors.html#customization

Links

@lexoyo lexoyo added this to silex v3 Mar 4, 2023
@lexoyo lexoyo converted this from a draft issue Mar 11, 2023
@lexoyo lexoyo added the v3 label Mar 11, 2023
@lexoyo lexoyo added this to the Silex v3 - step #1 - beta milestone Mar 11, 2023
@lexoyo lexoyo moved this from Beta backlog to Draft in silex v3 Mar 11, 2023
@lexoyo lexoyo moved this from Draft to Ready in silex v3 Mar 21, 2023
@lexoyo lexoyo changed the title CSS editor plugged on GrapesJS api Complex CSS selectors plugin for grapesjs Apr 15, 2023
@lexoyo
Copy link
Member Author

lexoyo commented May 5, 2023

Solution 4

Do as they do in webflow:

  • button under the Selector Manager: style all H2
  • when styling a tag display a button to add a "nested rule" / a class which is on the parent

Add the ability to

  • select a css class as parent
  • select a pseudo class
  • have multiple pairs "child / parent", e.g. style .parent:pseudo .child

Image
Image
Image
Image

@lexoyo
Copy link
Member Author

lexoyo commented Jun 23, 2023

@ceubri

@lexoyo lexoyo changed the title Complex CSS selectors plugin for grapesjs Advanced CSS selectors plugin for grapesjs Apr 2, 2024
@lexoyo
Copy link
Member Author

lexoyo commented Apr 2, 2024

Solution 4 is good, it lets the user select a class among parents, but while we are at it, we should also let the user select among other CSS combinators such as "next sibling", which would mean we style the element when it is the next sibling of the 2nd selector

=> Replace "when nested in" with "when <select>"

Also why not support design tokens?

=> how?

@lexoyo
Copy link
Member Author

lexoyo commented Jul 5, 2024

@lexoyo lexoyo moved this from Ready to In Progress in silex v3 Jul 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: In Progress
Development

No branches or pull requests

1 participant