I don’t know if this one makes sense, but hear me out…
I’m just wondering if there could be a way to create shared components in Bricks without having to manually create a custom class name for every single element:
e.g .acme-card, .acme-card__heading, .acme-card__image etc. (choose you classname methodology)
This method helps organize components and prevents nesting when manually writing CSS, but I’m wondering if it’s the best way to work with CSS in builder like Bricks?
Instead, would make sense to be able to create a shared component in Bricks? Class names for each element would be auto-generated and scoped to the component like in React or Svelte.
Either way, the component can be reused in multiple locations, and if its styling is updated, all instances are updated. The advantage is that you’re getting this without having to manually add a bunch of custom classes.
Maybe I’m not understanding what you saying. Are you requesting the ability to setup classes that are auto added to elements? Because you can already create custom classes in Bricks of course, but you need to manually add them to elements.
Yes, that’s part of what I’m saying. Let’s say you want to build a card element in Bricks. As you said, you can make a reusable card by adding custom classes and styling the card elements. I’m suggesting a way to make that easier.
In component based frameworks like React or Svelte, you don’t need to come up with all these classnames. You create a “component”, and all your styles are scoped to that component. You can see how React does it in the screenshot above – React creates classnames for your component and adds them to your stylesheet. It’s the same as if you added your own, but you don’t even need to think about classes.
After taking a closer look at Bricks, it seems like that functionality is already there with “Save as global element”. Unfortunately it’s not implemented correctly because it creates invalid HTML.
We are love component based concepts how we know it from our favorite javascript frameworks But I think that should be something for the core. As an add-on plugin, we would work too far into the core concepts and many things would only be possible through unclean workarounds.
I agree with you to suggest this to the Bricks Team