Some basic questions about Bric Builder

Just starting to looking into what’s involved with building a Bric and have read through the Developers section in the KB. I have looked at the html of the demo Brics but I can’t reconcile how user entered data is reconciled with functions in html or CSS. Can anyone point me to documentation that covers this?

Wondering if there are any demo Brics that can be opened to show this? Nothing beats dismantling something to see how it works. Or if it is possible, wondering if its possivle to open a normal Bric, ideally in the Bric Builder?

If you click the plus icon to add a new bric you will get some options to try some starter brics.

Values are passed via attributes that you define in the HTML section.

There is a custom JavaScript file that’s in the bric package that you use to write all your functions for the Ui and assign the attributes in the HTML etc. (this file isn’t used on export)

To be fair there is little info about how to do this. It took me a little bit to figure out the first time.

Thanks. I’m fairly comfortable with the overview but it’s the detail that I am keen to see in action. The 4 demos are useful but there’s still a lot of guess work.

1 Like

Yep :joy:

You get there in the end though. There are things like bric_container that is buggy still. I have it as an option in Any Video but it’s marked as experimental, I wouldn’t use it as an essential part of a bric. The API is getting some focus and love next year I think. Which will be great as bric container has a lot of potential. :grin:

1 Like

Good news. I’m impressed with it so far and looking forward to creating a couple of ideas I have.

4 Likes

Looking forward to it

I can see how to create a Bric to select a dropdown value such as data-bg-color1 and then set it in the html using data-bg-color1="red".

However, how can I access that value in the CSS?

Eg. when setting a BG colour what would xxxx be in background-colour: xxxx

Do I need to set the Function in this simple case when just setting a CSS value?

PS None of the demo Brics seem to illustrate this.

Edit: sorry I think I misread your question.

Depends on how you want to use it. But you can use JavaScript to take the value from the attribute and add it as inline css, or add a class to an element (add a css file). You can even add style tags and css to the DOM.

You can target the editable area or your bric, so some changes appear on the canvas. Others require preview.

Thanks. I don’t want to use JavaScript if possible so I will have a play with adding inline as you suggest.

I remember trying to build my first stack by reading the Stacks Dev Docs and that was too much of a challenge for what turned out to be fairly easy to understand process, soon understood after you opened up a few stacks and peeped under the hood.

What you do really depends on what you’re making.

And yeah. You got way more info than I did trying to get started with it. :joy:

I think it’s still early days with the Bric Builder. I’ve never used RW, but I have heard the stacks api was rather substantial.

1 Like

Regarding development workflow in Blocs 5, what is required to reload an edited Custom Bric to view the change? I assume a restart of Blocs will do it, but I’m wondering if there is a softer way to reload?

You can right click on a Bric to test the HTML, resources etc.

There is also a setting in the menu someone where for dev mode that helps with cache in blocs. (I’m on my phone at the moment ).

Would be handy to hear what was not so clear.

@Norm i can relate. I recall when I first started experimenting with the Bric Builder, I asked some basic questions as it wasn’t clear and got no answers. It took a lot of playing around to start to understand it.

That could just be me, I was pretty much new to this stuff at the time.

So far I have not been able to find detailed examples of how to use the Attribute or Function to show specificaly how to use them.

E.g. How to use a Textfield to add a string of text into html or CSS. A real example woud be how to correctly setup a column template string and then what exactly to insert into .grid-template-rows:string in a css file added to resources.

What I would find most useful would be a demo Custom Bric that included all the main interface types and how they are used in CSS or js. The css and js files in the resources don’t appear to be available to open and view/edit, so being able to examine these files would also be useful to see what’s going on.

Also info on how to use the Interface Values.

No it’s vague in places. To be fair the API has never officially come out of beta. I think it’s time to get that sorted.

3 Likes

A lot is down your personal choice. In a nutshell you assign values to the html in a Bric with JS similar to how you manipulate the DOM of a website.

Then you call a few Blocs specific JS stuff to pass info to the canvas.

1 Like

I think it’s time. I know there were a couple of other users who are familiar with JavaScript who gave up trying.

I think I must have stuck at it longer to figure it out for the most part lol. Your example brics helped a lot.

I’m feel I’m pretty comfortable with it, I would like to know how to use the template section. That I haven’t spent any time on.

1 Like

On initial reading of the Dev docs, that wasn’t apparent to me, and was my fault for making my own assumptions and interpreting that all mention of JS, only applied if you wanted to include JS in your Custom Bric. Having read the docs again, this is now fully apparent.

So I will hold back until I improve my minimal JS skills and will revise the Bric Builder. Really looking forward to future development of the Bric Builder.

I am still keen to examine how a Bric works and realise that I work best when I can examine a working example. I have tried all of the Bric Builder demo Brics, but can’t find any that show the specific part that shows the sprcific JS that writes the specific setting into the specific part of the CSS you want to target.

Can anyone point me to a simple downloadable Bric that I can look at?

@Norm could such a new demo Bric be added to the Bric Builder?