Grape JS classes styling #6563
Unanswered
saadali1221
asked this question in
Q&A
Replies: 1 comment
-
@saadali1221 Check this https://grapesjs.com/docs/modules/Selectors.html#component-first-selectors |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I recently come with a thing in Grape JS and that is when you add a block with a class name , lets say I added bootstrap row with a class name "row". So when I drop this in to the canvas editor twice and select the first one and apply style to that, let say I applied background colour. So it changes the colour for both of the components.
So what I found is adding a unique classes as you can see below.
// Row block (Bootstrap row)
editor.BlockManager.add("row", {
label: "Row",
category: "Layout",
attributes: { class: "fa fa-bars" },
content: () =>{
const uniqueClass =
custom-container-${Date.now()}-${Math.floor(Math.random() * 1000)}
;return {
tagName: "div",
classes: ["row", uniqueClass],
style: { "min-height":"50px",padding: "10px" },
droppable: true,
components: [],
}
},
});
Beta Was this translation helpful? Give feedback.
All reactions