As many of you already know, all custom Brics execute their functions and code in a dedicated sandbox which is then synced to the Blocs design environment. Previously, Blocs only offered the developer console to debug, which was pretty basic and not that great when working on the functionality of Brics.
Introducing The Developer Sandbox Tool
Todays beta of Blocs V5.0.5 (b1) will introduce a new dedicated tool designed to aid developers in building and debugging custom Brics.
For the first time, the Blocs API sandbox environment is visualised
This new tool brings the following new features for Bric developers.
Visual Output
You can now see exactly what is going on in your Brics sandbox.
Sandbox Inspector
Inspect the web environment your Brics javascript functions are running in and access full debugging.
Javascript Sandbox Injection
You can now inject javascript directly into your Brics sandbox environment. This is ideal for quickly testing your JS functions and API calls.
Quick Sync
Trigger the API sync call (used to pass html back to the Blocs design environment) with a click.
Ok I’ve made the new breakpoint variable even easier to use.
By default the javascript variable activeBreakpoint will be declared in all custom Bric sandbox environments. So all a developer needs to do is simply use the variable activeBreakpoint.
Nice work Norm. we appreciate the advances in the API.
Should the number go the other way, considering bootstrap is mobile first, especially if one day you want to add XL, since it’s a bootstrap breakpoint and we have a lot more widescreens now?
With 5.0.5 beta 2 I’ll also be introducing a new set of built in Javascript Bric utilities that any Bric can access within the sandbox. To begin with the list is pretty small but, we can obviously build this out with your feedback.
The general plan here is to lower the amount of code developers need to write in order to get a Bric to function.
New JS Utilities
applyAlignmentClass(target,position,sync) = This function will apply the relevant bootstrap alignment class (text-start | text-center | text-end) for the provided target element, it supports breakpoints and removes any current class for that breakpoint that may already be applied. It also automatically handles Bootstrap 4 (text-left | text-center | text-right).
Here is an example, this function is connected to the alignment segmented control. I just assign a target element, feed the alignment right in and set the sync bool to true.
getAlignmentState(target) = This function will get the current bootstrap alignment class used on an element (text-start | text-center | text-end) based on breakpoint and bootstrap version and return an integer 0, 1, 2 which can be used to populate the alignment segmented control element from Bric Builder.