image of man and laptop in office setting
Requires Login
Brightspot front-end training webinar

Looking to learn more about handlebars and front-end engineering using Brightspot? Start with this training, led by our world-class team of experts.

Click here to download a copy of the front-end training deck.




Morning, all attendees are in listen only mode.


Hi, everyone.


We'll get started in a couple of minutes here.


We're just waiting for everyone to get logged in.


Thanks for joining.


All right, I think that was I think that's basically the kind of good enough to let everybody join and we'll go ahead and get started.


can just making sure audio is working, Liz.


You can hear me pretty good and you can see my screen.






Right on.


So welcome everyone.


So my name is Tom Hoppe. I'm one of the front end architects here at Brightspot.


And what we're gonna do today is go over basic, I mean bright Brightspot, front end training, basically kind of the cliff notes of how front end works here at Brightspot.


And we're not gonna get into like super in depth into, into like into code are gonna get a little bit.


but it's kind of meant as sort of an overview to sort of describe all the different aspects of doing Front end here.


So our agenda is as far as we're kind of gonna go over the, the, the stack and talk a little bit about like what front end means here.


We'll get into this, what we call the root style guide in our, in our view system.


We'll talk about the style guide application that we have, which is, you know, a way for us to locally develop.


We'll talk about the front end bundle and kind of how all of that all of our code gets kind of bundled together and then go over a little bit in not quite like in depth, but dive just a little deeper on to each of the three major portions of our front end handle bars for rendering javascript for making site interactive cs S and styling.


And then we'll talk about how kind of json is used throughout our front end stack for examples, configurations and et cetera.


And then we have a couple of small code examples at the very end just to sort of summarize everything we talked about and show it more as of an example instead of just in the presentation.


So really to get started, you know, what is front end here at Brightspot.


So for us, it's everything you'd think of as a front end developer.


You know, you work with html, work with templating cs S and javascript.


but one of the sort of additional things that we get to do as front end developers here is we help create the views, which is really we determine the data that we need to show on the website and we tell our back end team of what, what that is.


And also we're able to incorporate publishing features into Brightspot with just front end code.


That's what we'll get into the JSON configuration and how that works a little further down.


But normally, you know, like back end developers are modeling modelers or who sort of create modules in the C MS.


But here, we've got some controls on the front end to apply some publishing features and let and let editors sort of control the front end of the site inside the C MS.


So that's kind of unique.


And then, so for our front end stack, we use JSON for configuration files and to deal with those with those views and those generate those views in the with the JSON schema, we use handlebars to do html templating.


In the end, all of the everything in Brightspot lives as JSON.


So we use handlebars to turn that json into HTML.


We use less as our CS S processor.


There's no real reason that, that has to be used over a but in our sort of out of the box Brightspot go product, we, we use just less because that's what we're kind of familiar with.


we use javascript where we write natively in ESC six syntax and then we use babble to trans that to whatever browsers that this site needs to support.


But that way, all of our stuff lives as a native javascript with ESC six syntax.


Again, there's no real huge reason.


We wouldn't use something like typescript or anything else like that if, if we needed to.


But again, sort of in our sort of default bundle.


We're still, we're still using javascript.


We use web to create our modules and to create all of our bundles.


And basically, you know, create that build, we use yarn to deal with our workflow and to and package Js sorry package that Jason and to pull in all of our external packages.


And we use node when we run the local style guide and the style guide is our application that we use that runs in the background and runs on local host.


And that allows us to essentially simulate what the C MS is doing locally so that we can develop much faster locally versus having to develop and then upload to either a local C MS instance or to some kind of, you know, a hosted C MS instance in order to see our front end code.


So we'll get into how that works in a little while as well.


So we're gonna start this thing off by talking about the root style guide and we sort of refer this to sort of like as the glue between the back end and the front end.


And what, the Roots style guide, the reason it's called the root is it originally lived in the project route?


But we actually moved it into the front end folder.


just because it, that's where I actually makes sense, that's what it's doing.


But what the Roots Style guide does is it specifies the views which are a collection of fields that you need as a friend and developer to display the the site.


So a, a field could be such like like a headline and a subhead line in an article.


Those are on an article page, those are like 22 fields and we specify these fields in these Json files.


And each view requires that Json file with the collection of fields and a handlebar file which is empty, but it's really a render hook because that Json file specifies what its template and what its render is.


And then that H BS file is there to be the render hook.


And each of these views results in a java interface for the back end to implement.


And that gets automatically created on the build as the the view generator system goes through each of these JSON files and creates a view for each one of these things.


So as front and developers, we create this Jason schema in the field because that's what we know and what the data that we need to show on the site.


So again, for example, for an article page, you know, when you get the article page design, you might have a headline and a subhead line for the article.


So as front and developers, we would put that data into the into the view, we would create those 22 fields.


And then that's we'll get that when the page is being rendered from the back end.


And then what the backend devs do is they do the data modeling behind creating for example, an article inside the C MS, they create those modules and there's pages inside the C MS and then they create the view models that place that data into the views for us.


The contract between the front end and the back end is that JSON file because the, the way this whole system works is that creates the view.


And then we again as front and developers said we need this data.


So that's the data that we put in our handlebar files.


But what we as front and developers don't have to care about is really how that data modeling, how the modules work in the C MS and how that data is actually getting to us.


We really don't have to worry about that because the back end DEVS have to provide that data to us.


How they provide that data to us is basically up to the business.


Again, most of the time it's coming from the C MS.


where the back end devs created those modules of those pages inside the C MS.


But sometimes that data could come from some kind of back end or third party API could be whatever.


That's what we'll talk about in the back end training tomorrow.


But as front of developers, we really don't care how that data appears into the view.


what we know and what we care about is that, that Jason Schema is that, that's what, that's the data that we said we need up to the back end developers to how they're gonna provide it.


But what when we do get that data, we can then we can then work with it and we can show it on the website using the rest of the front end stack.


So we'll talk a little bit about the style guide application.


And what the Style guide app is is a no Js app that comes with Brightspot that runs locally and processes example, JSON view files using our actual handlebar renderers, the same ones that are gonna be used on the live site.


And that simulates what is happening with the C MS.


And it basically simulates the fact that data was entered into the C MS or however, the back end provided the data.


you're simulating the fact that that that view file was actually, you know, filled out by the back end.


And then it renders that on the web.


So it uses a DEV environment of web pack to compile all of our Js and CS S.


But that way, since it's a, it's a DEV en environment version of it, it's easier to kind of step through and go through because it's not like modified or or fully transpired.


And one of the main kind of advantages of this is it's since it's using the exact same code and the same build systems that the real site does, it allows us to work locally and then see the results of your work instantly.


There's Watchers running for both cs S and javascript.


So that when your stuff is saved in the ID E, it's automatically recoiled.


And most importantly, you have to trust that this is that since this is the same code, it'll work correctly once deployed.


So again, just to kind of summarize, we basically create some example, JSON files that essentially simulate what the C MS is doing a lot in live.


But then you're processing, use it, using it, your real handlebars and your real javascript and CS S.


And again, that allows us to work super fast locally without needing to run a local C MS instance and needing to like compile our code, push it to the C MS instance every time you make a small CS S change, so you can see all of your work instantly.


So now we'll talk about kind of the front end bundle and all the different sort of things that go into it.


We originally call this thing a theme, but the word theme is a little bit kind of diluted in what the heck it means different things to different people.


So we sort of renamed it to the bundle, which it really is, it's just a bundle of all of the front end code that goes to create the site.


So it's really the whole front end of the site.


It's everything that we basically work with as front end devs.


And for us, the, the default bundle is a whole bunch of handlebar files which do all of the html rendering.


Most of the time we use javascript just for site interactivity.


There's absolutely cases where we work with full javascript frameworks like VV level frameworks and state frameworks like something like react where we use graph QL end points to render portions of the site.


But a lot of the times we'll use that for big heavy applications that are contained within the site.


but not for the entire like you know, running the site full headless and and, and rendering the whole site that can absolutely happen.


But then the whole the bundle and the whole stack kind of shifts from handlebars doing the rendering, and javascript doing the rendering.


But again, most of the time and, and definitely in our sort of default, like out of the box Brightspot product, We use H BS handlebars to deal with the html rendering.


That way that HTML is there, it ends up going through and getting, getting cashed.


And not, it only gets rendered sort of the first time that a user or someone look pulls a page.


But then after that, it gets cashed, javascript comes in over the top and makes the site interactive, think something like carousels or menus or whatnot.


The all the CS S styles that are built from less for all the styling.


whether they're, you know, instantly, whether they're like linked in the page or some dynamically loaded CS, all that stuff in the bundle.


We've also sometimes times we have assets such as some SPG icon, iconography or some other static image assets that we don't want in AC MS.


You know, it's kind of few and far between.


most of the use case for this are might be like SPG icons or things like that.


And then the bundle is gonna have a bunch of Jason.


These are both the, the all the view examples for the local style guide, as well as all the configuration files for how that front end bundle is going to interact with the site and interact with the C MS.


We'll so we're gonna do is like go into a little bit in depth over each one of these and kind of show a little bit how, how they work and how kind of we work with it.


So we'll start with handlebars.


We use that again as our templating language to convert Json to html.


It provides a nice strong separation between your template styles and javascript.


While that like, you know, separation is not super duper important, it is kind of nice having that that like, hey, this is, this is how your html is rendering your styles and Js can be a little bit separate from that.


And while it's defined as a logic list templating language, we found that having a few bits of extra helpers really help out in composition of templates.


we created some helpers for doing some comparisons, some logical helpers, little bit things like math and some string manipulation.


And then we've got a option that you can create your own helpers via javascript where you can feed the data from the handlebar file to a javascript helper and run some, you know, run whatever kind of logic you need on that.


If you really need to, a lot of we would, we would push to have, if it's heavy logic, we would rather have that on the back end and have that done in the view model.


But depending on what it is.


again, I haven't, we do have that option to create your own helpers.


There, there's a link in here to a comprehensive collection of all of the helpers that come out of the box with a Brightspot.


But I'm gonna go through a few of them here and kind of talk about.


So some, some of the highlight ones.


So, like I said, we've got some comparison helpers that are not in handle bars by default.


They're, we, we found that these are great for moving through item arrays with, if you need a little bit of logic or some conditional rendering or conditional formatting, something like equals greater than less than and or while these are really useful for you know, again, moving through item arrays and index based things.


We sort of discourage using these for like string comparisons and things like that.


While it can be done, it can lead to just like a little bit too much logic into your, into your templating.


And again, that kind of stuff should sort of be reserved for back end.


We have two very important helpers that we kind of have use all over the place.


And it's the set and get helpers.


Since we have a, a kind of large tree of parent and Children templating in a page where you know the page has a top level render and then something like a like a module is gonna have its render then then down to like even an image render that is a, a number of levels deep inside.


we needed a good way to pass values from parent to Children templates.


So the set and get helpers allow us to do that where on a parent level you can set some variables and then Children can react to those to those variables via get.


And this allows for a lot of template reuse.


So that's kind of where we use this.


And I use the example of you know, an image and a a module above it.


Whereas something like our image render is a pretty generic render that's used all over the site everywhere.


And then we use set and get to deal with the image sizing of that image.


I I'll get into it.


There's a little further down.


There's a better example of this that I'll get into.


We've also got this include helper which literally includes another template within a template.


It passes it the current context or the current data set that it's working with.


so that you can have good template reus throughout the site.


So for example, that image render is something where something I can include might be used or something where you might want to create.


Like we have out of the box, we have one render to, to render a link and just a simple A HF And we call it the link dot HPS file and we'll use that all over the place when we want to create a link.


and pass it some data instead of having to literally rewrite a every time and then forgetting the one of the one of the attributes like forgetting to deal with the target or whatever, like that's not there.


That's not a thing because we use include to to do that every time.


And we, we have this render helper also.


And it's kind of a little like a brother to the include.


But it's a contextual rendering concept.


It many of our templates have different what we call styles but different visual variations of a template.


So for example, if we have a list of items, you can display a list of items, number of different ways.


A list of items could be displayed as a grid, as a carousel as you know, whatever as a single as a straight vertical list.


And there, there's a concept that allows us to basically render a specific style of a template unless an editor chooses an override.


So for example, if you wanted the first module on your homepage to always be a carousel, you can use this kind of pattern to where if if an editor adds a list to the top of a home page, it automatically gets rendered as a carousel every time unless they override it.


So kind of it's a concept that allows us to create a little bit of a easier editorial experience.


So you'll see that used throughout some of our out of the box stuff.


Then we have a handle bar helper that we created for image sizing.


And then we have this which is a dynamic image sizing system.


And the resize helper is a directive to receive a specifically resized image from Dems.


We use this essentially everywhere we use, we create imagery because we set a, we create an image size JSON configuration file that has all of the different image size options and crops that are gonna be available.


And then we resize images to that specific crop.


We use this with set and get a lot of times to allow again for code reuse and contextual image sizing.


So I'll show a couple quick little code snippets of this.


Whereas we have one image tag dot H BS which is used all over this, the, the place.


And here you'll see the resize helper.


Oops, sorry.


Too many clicks we have this resize helper here that resizes an image to a certain size and you can kind of see it using the get helper here.


And then there's one more helper called the Fallback helper.


which if a specific get fails, it'll fall back to a string.


So the way this code ends up working is we have, you know, one image tag that's used all over the website, it will resize an image to again if a parent has set that otherwise it'll fall back to just like a generic 16 by nine image if you don't specify an image size.


and something like a recipe module here uses this exact pattern where it basically says here's my image.


And for the image, it's going to set an image size of medium four by three because we all want a 16 by nine image in our recipe model based on the design and then it'll just defer the rendering to the to that child image.


And then that image will basically render itself with a four by three image instead of the default 16 by nine.


So this is kind of a pattern you can see throughout.


but this again, we like this because it supports that template reuse of allowing this, this code to be basically this image code to be used all over the site.


But the image size to be changed per instance that it needs to be changed in.


So that kind of goes through all of our handlebar examples.


So now you got a bunch of html.


So now we're gonna talk a little bit about our javascript.


where again, we use javascript to mostly to make things interactive.


It's es six written javascript.


It's a mixture of classes where we need like base classes and then some stuff on top and custom elements.


A lot of we basically use the custom element pattern to instantiate our javascript.


so that our javascript is tied to a Dom element.


And when that Dom element gets placed in the Dom, you know, the custom elements are supported, you know, are pretty ubiquitous.


So that's how we instantiate our javascript instead of trying to have some kind of monolithic Js where we need to go through and like scan the page and do things like that.


We use these we use custom elements most of the time to in our javascript.


Again, we use babble to trans file that es six into browsers.


We need to support, we've got a browser list file that can determine that.


So based on that Apple can trans it as much or as little as it needs to.


And then we package our javascript using web pack into a combined javascript.


That kind of goes out to every page as well as chunks that get dynamically imported.


So those chunks can be something as as simple as taking some third party large javascript code and doing a dynamic import on that inside of our web pack and then web pack will automatically chunk that out separately and only pull in that javascript when necessary.


So for example, this is something we use in our carousel code where we use Flic as a third party library to deal with all of the interactions of a carousel.


But we dynamically import Flic.


So that means that if your page does not have a carousel on it, such as like an article or something that Flic library isn't loaded on that page.


That Flic library dynamically gets loaded.


when the custom element to deal with the carousel gets loaded, Because the HTML for a Carousel is on the page, then that will dynamically load that chunk that web pack automatically creates.


And again, we can use this sort of pattern to dynamically load this javascript and kind of make that initial, you know, we want to have this initial javascript file contain all of the code that is, you know, based on all the pages for, for a faster load time and for cache.


But to create some efficiency, if you've got a bunch of javascript that is not used on every page, you can dynamically pull that in whenever you need to.


again, we use custom elements to bind that javascript to the Dom.


And then for most content driven sort of I put in quote static websites, there really isn't a need to load a full javascript framework to sort of deal with things like if use because we're dealing with that through handlebars, There is no state or sort of used to handle so that full javascript framework is just sort of overhead, that's not really necessary.


So we want to create a performance site.


But if this allows us to use javascript and make the site more interactive and sort of enhance the html versus using it for rendering.


Again, that's not to say that we don't use frameworks or we don't use something like react with pull in data from graph QL because we absolutely do.


But again, we reserve that for more things that are more application based.


a good example for this could be like a sports site where you know, the article that has to do with a player or something like that or an article or like a team page which has information about the team.


That is seo is a heavy consideration for that.


So we don't, we want to go ahead and have that be static html, that's cash that's crawled, that's etcetera.


And it's easily rendered and it's fast but the scoreboard or like a leader board of an event that might be happening right now.


That's something that sort of enhances that page and that's something that makes total sense to have as a React application that's hitting a graph QL endpoint that pulls every minute and updates that leader board.


So the way we'll do that is that React app will be a custom element that is bound to the dom that can then dynamically load react if it's all, if it's not when it's necessary and reload that application, go off, hit graphical end points, go ahead and render itself as you know, basically a deal with its own javascript rendering, deal with the views.


Whereas again, the rest of the, the page is sort of static content which is driven from the C MS and processed through handlebars.


But they're getting back a little bit to that javascript custom element.


There's an example that I was talking about with the carousel code where the carousel code is super light to because most of the work we outsource out to quick flic, but you can see here where we have an await dynamic import of Felicity.


This is the directive that web pack will use to chunk out Felicity.


So what you see the 40 lines on this screen, that's what's getting compiled into your main javascript file.


And then that's what gets, you know, this connected callback is what gets triggered when a carousel is detected on a page by the browser.


And then it dynamically imports Felicity.


So we, we use this sort of pattern to keep our main javascript lighter but still be able to use third party libraries when we want to.


So that's what I've got for the javascript.


Now, we'll talk a little bit about our our kind of CS S patterns and, and our styling like I said, we use less as the CS S preprocessing.


There's nothing in Brightspot or in our build systems that requires less versus SASS.


We just chose that a while a while ago and we really haven't changed the SAS because it's essentially, you know, less and SAS are basically doing the exact same thing, same thing, which is pre process, right?


Letting you write basically you know, that language and it, and it ends, ends up in the end getting processed into CS S.


Anyway, we use sort of a ben style syntax for class and element naming.


that's blog element modifier versus having like a full object oriented CS S framework, something like bootstrap or one of the other frameworks that's out there.


We feel that working with like AC MS working with a bunch of modules and a larger developer team, CS S changes and bug fixes are a little bit less likely to create regression issues as working with a be style syntax.


You're literally working with that block or that element and creating CS S for that.


Versus working with like a full object oriented CS S framework file.


And then that would that basically, you know, we essentially know what you're working with.


And that allows for multiple developers to work together a little bit more easily than having, you know, to someone that manages this O CS S library and then people that are sort of using it.


If you're creating if you're not working with the out of the box bundle, but you're making your own.


The world is your oyster in terms of how much what you can do, you can absolutely like, there's nothing that restricts in Brightspot, there's nothing that restricts what kind of styling you're doing, what kind of patterns you want to work with.


I am just sort of describing what we do in our out of the box bundle.


And what sort of are like quote unquote go to is but that's not to say that we don't use some object or CS S concepts because we do for some things that are a little bit more global in places where it makes sense.


We have a, we have a few of those concepts as well.


But we use there we go.


So we use descriptive names for modules and components and use kind of the ben pattern to name their elements.


We use less to abstract some styles allows us to sort of use less extends or mix ins depending on the use case to abstract some styles.


But we then do do a little slight bit of object oriented as well to sort of create some kind of global concepts that can be reused throughout html.


So we don't have to repeat the CS S a whole bunch.


So an example of that is like the page, like a page list for us.


A page list is a very common content type.


That is essentially a list of, of pro we call them promos.


So it's a list of elements.


And so, this, a page list is something, that's used all over like section pages and home pages.


So that could be a carousel of news stories or a grid of news stories or a list of new stories and all these things a lot of times have a bunch of common elements.


So a page list might have a footer and it might have a call to action and it might have a set, it's got a set of items and it's got a header or something like that.


So these things we kind of create this sort of object oriented like OO CS S kind of page list footer where this html can be used reused directly.


But then for things that are not common between all the different page lists, this is where we create instances or versions of them with some the, the, the modifiers where this is a page list, it's a standard a page list.


We kind of use these names out of the box.


We I think naming things is probably one of the harder things when you're working with, with code or with module or with like instances of styles.


So instead of trying to create fancy names like page list grid for across or whatever, we just we just call them A through Z and then we use the display name option or configuration files, which we'll talk about later.


So you can, you can create a more colorful name for your editors if you need to.


But for the developers, we just went through the, the alphabet.


But this is where you can create and you can write some CS s for certain instances of of these lists to have the styling done done here.


Rather than creating like fully object oriented CS CS S where you just distribute those classes throughout the html.


This is the kind of pattern that we work with, with the out of the box theme.


We use CS S variables to allow us to set values whether they're in CS S or in line html.


This allows us to create this nice pattern to set these CS S variables at the root level through C MS editorial fields.


And that allows us to create to allow for customization by editors.


We use less for places where variables are helpful, but editorial overrides are not necessary for something like Z index.


We just use it, we just use less variables.


There's no reason we should use CS S bars for those and we might actually like transition from less bars to CS S bars for those later.


But really less far is just definitely do the job there.


But again, for a lot of things, we do use CS S bars and a to show a little bit of that pattern.


Something like colors is a perfect spot where we want to allow editors to set these colors through the C MS editorial interface.


So we have this colors HPS file which is a handlebar file which takes variables that are coming out from the C MS that editors can set such as primary color or a primary text color.


And then it'll create an in line root style sheet with these with the, with setting these CS S variables.


And then now we have a less file that pulls in the next level of those where it pulls in those variables that got set by the handlebar file and actually sets the CS S variables that are used throughout our code and then creates a fall a little bit of fallback for that.


So basically, if an editor sets a primary code inside the C MS, this variable will be set and then it will be used for the actual primary color.


But if the editor does not set that we've got like a fallback for that, that we can create you know, a, a color palette in our code.


If the editors don't make any choices and then this color primary for example is what's used actually color header backgrounds.


The example that I have where like the white header background, unless the editor chooses a different color inside the C MS, this is the variable that's actually used throughout our code.


And you can see it in the page header, CS, S or page head or less that CS S variable sets the background of the color.


So we use that pattern throughout for dealing with things that again are changeable by editors such as colors, things like topography and fonts.


We use that as well or font sizing where like an editor can go in and determine some different font sizes for a certain list or something like that.


We use this pattern for those places.


So, let's there we go.


So that's kind of it, it on the CS S like I said, we don't really dive too deep into these in this presentation.


But all of these examples and everything is in the training repo And all of these links will be sent out if you want to dive deeper into this stuff yourself.


So we'll talk a little bit now about Jason.


We use that throughout our bundle versus whether it's these view examples that are in the style grad application which I'll talk about.


or a lot of like for most of our Json also is all of our configuration of how that bundle interacts with the C MS and interacts with the site.


So json for view examples to it, we use this JSON to simulate how the C MS is going to fill out the views.


So again, this also, this essentially allows us to simulate what an editor is doing in the C MS and allow us to create examples of content type and even entire pages locally.


So then when the style guide application is, is run, it's processing this json using the handlebar files that are the same handlebar files that will be used when this bundle is uploaded to the server.


So that way, you know, you can simulate what the heck is going on and we'll these are a few examples of these sort of JSON files, view examples.


So page dot JSON is sort of our kind of route and like every page has all of these JSON file, Json keys and this is the view of a page where it has you know, things like a, a language attribute that might be used in the head.


And the title description, it's got a, a logo and it's got some navigation, social icons and that this is sort of the, the main base of what a page has.


And then something like an article page.


It leans on top of that page that Jason because it includes all those things that a page might have, but it has things like a headline, a subhead line, some authors and an article body.


So these are the views that we we created in that root style guide.


And these are examples of that view filled in by an editor to again, essentially simulate what's happening in the C MS because if you could have an article page that's created in the C MS like the and the headline are all going to be filled in by editors.


But here we have these little text generator helpers that we have that allow you to basically insert random words for the headline and, and random words for the subhead line and a random date which allows us to not only like view this stuff locally in the roots style guy with these kind of fake words, but also sort of stress test.


our TML and our design with this kind of pattern where we can say, hey, insert between five and 15 words per reload of this page.


So every time we refresh, we get a different headline so we can see how you know, our HTML and our design reacts to a short or long headline.


And this sort of pattern continues where, you know, we can insert paragraphs in the article body and include some enhancements as examples to simulate an editor, adding these enhancements.


But here we can view this instantly and see it in our local style guide.


Furthermore, we have a pattern to allow us to pull down already existing pages in the C MS using a query string directive to, to see this.


And I guess I can show a, a quick example of this pa if this where if you pull up one of our pages with this render style guide designator, this creates this same exact this creates sorry, not the same guy.


This is the JSON representation inside the C MS of this particular page.


So this allows you to even pull down like a live page into your local instance.


So if you needed to troubleshoot something or whatever, But this is the JSON representation of this page and this entire Jason Blob could be pulled down to your local style guide and this home page for a Brightspot could be rendered locally in your local style guide instance.


So that way you could, you know, do some local editing and local code editing super fast and see your results instantly.


So the we also, so I guess that, you know, again, you can create these files manually or these files, you can pull down like if you already have a production instance or a page that you're trying to troubleshoot or a page that you're trying to get an example of in the, in that local style guide application, you've got a couple of different ways of getting this JSON.


But again, the, the main point is that Jason gets down into your local your local bundle and when local style guide is run, you can see these things real time, which is super helpful.


So we use JSON file, json all over the place to set these also configuration files.


They're the mechanism that define how the bundle interacts with Brightspot and actually the style guide application as well.


These config files have all of the configuration for image size options.


Like we talked about additional fields that the front end can added to the MS because we kind of talked a little bit about the sort of how we can allow editors to, to sort of control that front end using something like those color variables or some other front end fields that we'll talk about a sec.


The style variations of content types also.


So like we talked about like a, a list of things can be interpreted as a bunch of different ways, whether it's a grid or a carousel.


So we create sort of instances of these content types and then editors can select those.


and then configuration options for that style guide application So we kind of configure that style guide app to show like a navigation.


So we'll talk, I'll show that also in a second.


So configuration files may be defined at the root of the style guide or a subdirectory.


We can have the best practices that we like want to put those configured files local to the components.


And the global configuration file lives in the root of the style guide directory and at run time and during the build, all these everything that's star dot config dot JSON actually just gets combined into one giant Json file.


And like originally a long time ago, we actually had all of this just as one configuration file, but it got to be sort of a merge conflict mess, which is why we did this concatenation of all these configure that JSON files at the end and, and sort of distribute them down into the sub subdirectories where they make sense.


So something like the image size options are defined at the root because those are kind of global.


But then some style variations of a page list will end up being going into the page list folder.


Because then that kind of that makes contextual sense of where to look for those.


So we'll talk a little bit about the image sizing.


We can kind of dive dove into it how that resize helper works.


But image sizes are defined in a configuration file in the root.


And then to define an image, you're gonna need at least a width or a height or a maximum within a maximum height if you want sort of dynamic resizing.


once these are defined, these are then what's used with that resize helper to fetch those images from Dems.


And this is where you'll also CRE create designations if you want to use like web P versus JPEG, if you need some source set, descriptors are like that for your image.


But this is where you know we define and we say we call a small 16 by 9, 100 by 57.


And for that one, we do want web P images served.


We've also got patterns that allow us to do dynamic widths and heights and cropping based on.


So for example, where's there?


a here's a good example of a 14 by 40 width image and it's a not a fixed aspect ratio.


So this will create a 14 40 pixel wide image.


But since there's no height designator in this image size, it will will pull the height of whatever the original source image was.


So if a giant square is uploaded into the C MS by the editor and this image size is picked for a particular module, it will turn a 14 40 by 14 40 image.


this preview height, the preview kind of designator is used just so that their local style guide can kind of see an example of something.


So it sort of knows to to render something.


So this is only going to be used for your local style guide application to make sure that this image can be shown since there is no C MS in a source image.


but this kind of pattern can be used.


And then something like we you can also create something like a maximum height and a maximum width without having a width and height.


And this will purely resize the image based on the longest dimension based on the low based on the aspect ratio that was uploaded by the editor.


So you've got lots of patterns to kind of deal with with aspect ratios and what's uploaded into the C MS.


But all of this is defined in this image sizes, configuration file.


These image sizes are given names and then these names are what is used in your handlebar file with that resize helper to fetch the right image from you when the site is rendered.


And then this is where we get into like adding editorial fields into the C MS as front end editors, I'm sorry, as front end developers.


So we can specify additional fields that are added into the styles tab of into the C MS which allows editors control over those styles of content types.


These fields only persist within this data bundle within this front end bun bundle and they're not part of that content types data.


So that's a pretty important distinction.


because again, these fields are really meant to be used by editors to add certain styling or visual elements to this data.


They don't actually manipulate that content's data.


So what this means is these are very useful for additional styling options such as background colors, image alignments, dealing with the number of columns that a grid might show.


but these shouldn't be used for data.


So for example, you shouldn't use something like a front end field to add some text.


Unless that text is some purely visual flair, I wouldn't want to have a subtitle or a subheading of a module be created with a front end field be before.


Because if I had a piece of data that's like a subtitle, I want that to be with that content types data, I like to say for clients that like a, a good way to think about this is if you had a feed of your site like it, simple as RSS feed or complicated as whatever other feed there might be to some third party source.


If there is, if you want something to go in that feed and you're working with a variable that should be in that feed that should be a back end field that belongs in the view.


But if some piece of config editorial configuration like a background color and an image alignment, some data like that is that not useful or necessary in a feed of the data?


So that's a perfect thing that could be a front end editorial field instead of needing to be a back end model data field.


So what we have is a fields config file where we specify a bunch of these front end fields.


So you'll see something like a header, text alignment in here or whether you want to like have a a number of columns for this field, whether you want to be full width or 55th, like how many columns do you want on this?


If we have an enhancement alignment, What do you want, how do you want to align that enhancement?


Do you want it to be centered?


Left, right, full width or whatnot?


These, these are like perfect examples of front end fields where we want, like how fast do you want this carousel to slide?


And we put that in in seconds.


So you can actually type in a number and that'll be that, that'll be given to the javascript to control that carousel speed.


Sound like that is not necessary at all in a data feed of a module that has a carousel, but this allows the editors to sort of control that carousel speed.


And it allows us as front and developers to add that into the C MS as an editorial field.


So you can get that feedback from editors.


So you can then use that in your handle bars and use that in your javascript.


So for example, a page promo module is a a promo module for us.


in Brightspot is something that promotes a piece of content and promotes it by having like a title, a description of usually an image and a link.


So we have you know a number of these promo modules A through C here.


And these are a bunch of the fields that we as front and editors have added to configuring a page promo module where you might want to hide the category, you might want to show the byline, you might want the toor to be able to set a specific image aspect ratio.


align the text center like right set of background color in that module, maybe inverse the text on the on that module.


If they choose a black background color, they might want to inverse the text and you know, you could animate module and scrolls down into the page.


So these are the kind of things that again are front of front end visual extra fields that can be defined by editors that don't necessarily need to be added to the data for that module.


But they are kind of visual that we might want editors to mess with.


So that is again, one way we can add editorial control over some styles.


And another thing is the JSON configuration for the styles of content types.


So this is a powerful concept that lets us create many different looks of a content type by using the same data scheme.


So for example, like I, like I talked about where we have a page list, a page promo and a page promo module content types.


And these are content types that are used to assemble a lot of pages that are sort of modular pages that are, that drive users to content, something like a home page or a section page.


Our page list is for us a a list of promos and a list of promos can be displayed visually a large number of different ways.


And we happen to have you know, 20 something ways of showing that whether that is that could be a grid, that could be a carousel, that could be an in line list.


This is where we create handlebar files to create the html, to take the same content type and the same data schema.


But show it a number of visual ways and we create this configuration file that lets editors choose which styled variation of that content type they want.


So they might add a module to the top of the home page and then they're gonna go into the styles tab and they get all these different choices to, to choose from for how to visually lay out that particular set of data.


And that concept applies to literally every module that in every content type that's in Brightspot.


So you can create maybe two different styles of an article.


You can create multiple different styles of a page list, multiple styles of a page promo of even a section page could have multiple different front end styles.


Which, what that means is that a section page content type could be rendered using different handlebar files to have two completely different looks and feels if that's what the design and your product people and your editors call for.


So this sort of concept is pretty powerful and it's used sort of all over the place to again let editors control visually.






So I think that that sort of goes through and is the kind of basic outline basic kind of cliff notes of front end.


And where I wanted to go now is to just show a couple of code examples of of these different things.


And we've got two specific code examples.


One, The first one is gonna be, talking about the front end for a recipe page and a recipe module.


this is sort of our, kind of exercise and like our training exercise that's in the training repo,, that you'll get links to, this whole presentation by the way and this repo.


and all this, all these links kind of go out in, they'll go out like, I think next week or something like that.


My Liz will send those out to everybody.


And so what I'm gonna do is we have a, we created this recipe page and recipe modules which you'll go through and and Brennan and the back end training will kind of talk about creating some of the view, some of the models and the view models for the recipe page and the recipe module.


But here I'm gonna show a little bit of code around how you can create like when you're creating a new content type, how you're gonna do that on the front end.


So, the first that we start off with, we work with the back end team as well as the product team as well as design to determine what the recipe and the recipe module.


JSON will look like that.


We wanna know what the view will look like, this will establish the contract between the front and the back end and that is placed in that root style guide.


So basically before the sort of the front end really starts their work, we will determine this these views, right?


We create the view specifications that goes in the root style guide folder, it for this particular case, we're creating a recipe content type and then there's a recipe article page and then a recipe module that can be placed in places.


So we will create this recipe article page Jason.


And it is a creative work page which means it's a certain type of page that already brings in some concept.


So that already has all of the page json associated with it that brings in all the things that a page needs.


But then a recipe article page also will have it'll have a lead that an editor can add because there might be like an image or a video lead.


It'll have an article body that the editor can use to describe that recipe and then it'll have the recipe itself.


And then, so we create these as when, when we create these JSON files, we're creating that view that tells the back end that like somehow you've got you as back end developers have to give a lead, an article body and a recipe to the front end.


And then the recipe module is a sorry that a recipe module then is a totally new content type.


It's not actually a page, it's just a module.


And with that module, here's the data fields that we determine together, you know, based on the design or based on what the product team wants that an recipe has.


And it's gonna have a title.


It's got an image.


and then some properties like difficulty, prep time, cook time, it's got a list of re and some directions.


So we've determined that these are the fields that we need to show a recipe.


So then we're gonna create a handlebar file that uses all of these fields.


And then, but we as front and developers again, we don't care how these fields get to us.


We just care that these fields are gonna be there because we know that we need these fields to show a recipe.


So once we have these o once we have these views set up, then we can take the following steps to actually create the actual front end.


So what we're gonna wanna do is we'll, we'll add a JSON example for ourselves and the handlebar renderers to deal with that recipe.


So you notice that this is in the bundle instead of just the root of the front end style guide, We create we've got the same recipe folder here and we create some jasons that are the examples of what these things would look like if they're filled out by editors in the C MS.


So start with a simpler one, which is a recipe module.


And this is got the render associated with it.


And here we put some test data in to kind of simulate an editor, filling out a title, adding an image and you know, so we can, we could have used the words helper here or we can just write easy, it doesn't matter.


And then for the ingredients, we simulate again, the editor adding a list into the RT E here.


This is what it would look like.


And you know, again, we got the rest of these fields filled out here.


And then it's the same thing for an article where we create an example, we've already created like a root example of an article page that already has all of the other fields kind of filled out with examples.


But what the recipe article page has differently is it's got we just created a very straightforward article body instead of creating a giant one with a bunch of enhancements.


But so it just simulates that an editor, put a couple of paragraphs in to describe the recipe and then they added the recipe module into the recipe field that we created right here.


So now that we have these two jasons, we can create the handlebar files.


Both for the recipe module and the recipe article page.


So for the recipe article page, we kind of made that straightforward because it really kind of looks and functions and works exactly like an article page.


So we actually the handlebar is straightforward because we just included the article page using that include helper.


Oh Sorry.


using that include helper.


we can actually literally include this code into this handlebar file.


Since we determine it for our design, it looks exactly the same.


We just want to reuse that handlebar, render the article page handlebar, render instead of pasting that code in here.


So that's a pretty cool pattern that you can create some code reuse around it.


But for the recipe module itself, this is where you're gonna create the HTML for that.


So we use that kind of block element pattern where we create a recipe module.


And then we use just standard handle bars to you know, create a difficulty at total time to render the image with a four by three image and then create a some ingredients and, and, and directions and whatnot.


But this basically lays out the html based on that JSON data that you're gonna get.


you'll notice there's a helper that we use in here.


I kind of described earlier but there's a format helper, a format helper.


allows us to use Java style properties files to localize text that we might not want in the CM.




But we want to potentially include in many different languages.


So instead of we've got the Cook Time in our Jason.


but we want to put like a little heading that says cook time.


You don't want the editors to edit that every single time.


So we'll use that format helper to take the words cook time.


Because we, we never want to hard code that piece of text into the handlebar file because that would break localization if, if you did that versus using this format helper to deal with things like static text.


But again, so now that we're done with these things, we have a sorry, we've got the views.


Now we've got handlebar renders and we have some examples, Jason.


Then we're gonna wanna add some simple styling to that.


So for us, it's got some very straightforward styling or we just add a border to it, throw some margin around it.


And then we, you can see this less extend pattern that we use to deal with topography.


Where for us in our bundle, we create a, a large number of text styles and we name them like descriptions or subheadings or titles.


And then we just extend those less styles everywhere instead of pasting font size, whatever all over the place.


And then having to deal with the media queries of that, we do that once and then we use less extends to, to allow all those type types to be kind of distributed throughout the site.


So, we create some CS S to deal with that recipe module.


And lastly, we've got a navigational config file in the style guide which sort of creates the left side menu of the style guide application.


And we put that article page there so that we can view it in the style guide.


So once all of these things are done, we can run our local style guide obligation.


So I've got that running here in the terminal.


And once that style guide is run, if you now go to 80 80 which is the style guide, the left side shows that navigation that I was working on and there is that recipe right here.


which is that recipe article page which has the same look and feel as an article page because it's using that same handlebar render, but here it renders a recipe module and this is the recipe module.


This is that, this is all the data that we had in here.


oh sorry in that JSON file and the CS S that we created.


And again, since we're running the local style guide here.


I've got that, terminal running and I've got the style guide application running.


if I go into my, ID E and I go in and I edit my, recipe, I've got the handlebar file here, for the recipe module.


and I've got my CS S, in here as well.


oh, there it is.


I've got my CS S here as well.


So if I make changes to this, it auto runs the CS S and everything you, you've got the Watchers and you can see all of your code instantly and the effect of your code instantly in the local style guide.


So this is how you can develop super fast because you're changing your CS S.


this is run in the background again, if you change your html, you can see your changes instantly on your html, right here in your handlebar files and the same goes for javascript and the same goes for changing the data.


So if you, I wanted to, you know, stress test, whether, you know, how would 100 words potentially work inside my title?


I can do that and then I can see the results of both my testing of my data, testing my handle bars or testing of the CS S instantly here.


Yeah, in my local instance.


So, that's kind of how we create a new content type.


And that's how we see our changes super fast locally.


The other little code example that I want to show is making a new style of a content type.


So this will this will show let me step through real quick of again, a page list style, a page list is a list of promos that can be displayed a number of different ways.


Let me switch my branch real quick here locally.


And then I cannot show the style guide.


Let's see, we are got the branch switched.


And now so we have a a large number of lists on a site.


So for example, you know, a standard list a looks like this where it has one big promo, four of them without imagery.


And then a grid underneath.


A list can also be a grid this way it can be a you know, a grid.


This way it can be a vertical list, you can have 100 different styles.


But if for example, our, you know, for this, for the sake of this exercise, a our designers have decided that they want another style of a list.


And it's gonna be one large image and then a grid underneath it of smaller list.


So if you have a, if you have four or let's say five different promos that have been added to the list.


The first one's gonna be large, the next four are just going to be displayed in a two column grid because none of our current examples have that, you know, we might have like a one and we've got the three column one here.


We've got some that look like this, but we don't have like a kind of straightforward one.


So the way we would do that is we would go ahead and we create our kind of step one is we'll create a page list standard M because we already have all the letters until then taken.


So we will create the next one, then a list, which is a page list standard M.


So we're gonna create the handlebar file and a JSON for it.


So the JSON, we say that it's a page list as a template.


But the styled template is actually gonna be, that's the style template that the editor will choose is page list standard M.


We're gonna give it a title.


We're gonna give it some CCT A and we're gonna simulate that an editor has put nine promos into this particular list.


So that's the JSON for page list standard M.


Then we're gonna create the handlebar file for it because that's the style template that we, that the name that we designated here.


And we're gonna create the handlebar for it.


So we're gonna say it's gets a standard page list header at the top of it.


But then, you know, for the first item, so we'll say this is where we're gonna use some of these helpers that we've created that for the first item in that array.


We're gonna want to set a larger image size and render the promo.


for all the rest of the items, if the index is greater than zero, we're gonna just render a normal promo.


And in our case, a normal promo, the only difference here just has a smaller image that it uses.


because the first item, we're gonna have a bigger first item than the rest of the items.


So we create the handle bar, we create the JSON.


And then, so now the next step is to update the configuration file for the page for the list to have a new style show up in the C MS so that the editors can choose.


So we have this page list config Json.


And actually I'll just view this whole file so you can kind of see the whole file.


And here is where we specify all the lists, we have a through whatever.


But we've got m down here.


And this is where we created the standard list M.


And then with the only two front end options we gave it are a background color and the ability to set inverse colors.


The, that's the only options, you know, we decided for this module that, that we want to give to the editors.


But when we place this in this page list, config file, this this file now is available for editors to choose as a list style for for this list.


So once we've got those two steps, the next step is let's add some CS s for this thing.


So we created a page list, Standard M dot Less file.


We made sure to import it into our All dot Less and then we just gave it some very light styling.


We just do a little grid on the sucker.


We gave it a border.


And then if you're on a bigger break point, we either split this up into two columns or we split up into four columns.


So very, very straightforward.


And then, yeah, if you're the first item, then we span all the columns because we want the first item to be bigger.


So some very basic CS s to make sure that it's compiled.


And then the next the last step here is that we have we want to include it into that navigation file so that it's viewable in our local style guide.


So when this now that the style guide is running, we can now see here there is now a standard list M in our list on the NAV.


And as we talked about this has a just to make it a little easier.


So you can view these, it with, with this navigation or you can view these without this navigation.


So you can deal with things like responsive sizing and check, you know, check just this module in your browser without having the rest of this site around it.


So you can see this is like mirrors kind of what we talked about where we have the first one in a mobile break point.


Obviously, that's the, they're all the same.


But then when you get to a bigger break point, it's got a two double behind it.


And once you make it to a big old, big old break point, you get a four.


So you can verify that this is working well.


It's got all your styles.


I'm locally and I'm working in my HTML cs S javascript and I can make all of these changes.


And like this is like, you know, an example of like, hey, we might want to update some more styling, we might want to say, you know, for the rest of the promos here, you know, they, they're gonna have large text but these promos should have a smaller piece of text.


So I'll have, I'll add some extra CS s that say if you're not the first child, then I want a title six which is a smaller title than title five.


And again, these are the kind of changes as if I am.


Look if I am in my ID E I can go into my code directly and this is where I can make my oops, sorry, this is we're gonna go to styles standard M and this is where I can work with my CS S directly.


So I can say like if I take, you know, this is I'll just say that that gets, and then you see how the text got bigger right here.


And I'm like, I'm looking at this, you know, the designers wanted to smaller text here.


So that's where I'll put that code in.


And then you can see the result of my CS S automatically.


This is also where again, I can either change the CS S here or for example, I can say, and I can simulate what an editor is doing.


Because in this page list, configuration file for page list, M I allowed the editors to change the background color of this module or to inverse the color.


So I can simulate what the editors are doing by filling out those field fields here.


And I can change the background color of this module.


So this is it, this is simulating the editor changing the background color to black.


And then they'll probably at the same time hit inverse colors, hit the check box there.


And that's a bull in and I know that's a bullion because in these in this field configuration file, I created this inverse color which is a bully and field a type that it adds into the C MS that allows them to, to check that check box.


But then I can see that say that first and then, now I can see the fact that the colors are versed because this is again simulating the editor, making these editorial choices that I can create examples of these and check all this locally super fast.


So I can do all of my local development to, to, to be able to work the front end super fast, but then still have confidence that when I upload this stuff to the actual C MS that all of this is gonna work the same way it works on my local.


And that's not to say that we get, we get out of the, get out of like Q A as friend and developers.


But when you're done with your pull request and you're done with your code, you should still deploy it to a Q A environment and just check the actually work.


But you are pretty dang sure that it's going to be because you got to check it in that local style guide.


So this is all, all I've got in terms of the front end training.


So, thanks for attending.


Thanks for listening.


If you guys have any questions, feel free to draw into the the questions panel, I see there's one here.


So I'll go over that in a second.


And then, like I said, Liz is going to be sending out this presentation a little recording of this as well as links to the training rep out.


And there's links throughout this presentation to the training repo as well where it's got the examples of what I talked about.


So if you guys have any questions now, like I said, please drop them in into the questions panel in the webinar.


And then also if you come up with some questions or have something later, you know, you can respond, you can respond to Liz's note and we can figure out a way to, to answer them as well.


So, hang on a second, let me get trying to view this whole question.


So if there's a question about, is there a mapping documentation on what of the allowable keys are in the JSON for instance, like include template wrapper or repeat.


And yeah, it's true that most of them are self explanatory.


But it, it's kind of difficult to know when first learning what the options really are.


We should have that we've got this Brightspot sort of academy where we've got some documentation on this.


But I will make a note on this one to kind of actually just create some CRE create some if we don't have any.


But yeah, I think we try to do these as self-explanatory as possible.


But good call on the fact that it might be difficult to kind of know what those what those specific keys are.


So if I if we don't have it, I'll, we'll definitely, we'll, we'll definitely add that.


There, there's another question about the using the query string to pull down a local copy of a given page.


So, I definitely, this is in our documentation portal, but it's underscore render equals style guide.


That's the, the query string directive that pulls down the JSON view of what that entire page is, which includes you know, all of that root json as well as any any modules that are in that are there as well.


So basically, this is the JSON representation of the entire page.


And then there's one last question from Peter about there's we've got encountered some issues where things work in the style guide, but not on the cloud I think, if you have something like that, we should probably kind of talk about, if you wanna sort of kind of contact Liz and get some more sort of concrete examples of that.


you know, in general, that should not happen.


I mean, I've definitely seen a few instances sort of in my history here.


where if we've created some javascript specific helpers, for example, they, you know, the, the javascript language that's the processor that runs inside of java to sort of process the handle bars could sometimes be different.


But really this would be if, if there is something that that's working in the local style guide but not working on the cloud, I feel that would be a pretty solid edge case.


That's not something we commonly see.


So Peter, if you definitely have that contact Liz or you know, whoever else you're working with a Brightspot, let's try to kind of escalate that and kind of figure out what the particular problem could be because you know, we sort of base everything as a front end team off the fact that stuff in our local style guide should be the same as working in the cloud.


I think one potential common thing and maybe that's what you're saying is that and in general, everything in the Brightspot in this Jason is an array.


So even if you have one item.


So for example, here, this is a good example where the below object sorry, the below key is an array even though it's one item.


So there are times if you want to interact specifically in your handle bar with a particular item, you can't if you're working just with the below and then trying to find a specific key of its first item, that could be a little bit of a gotcha where locally in your style guide, you might have made a mistake and done something like this and skipped the array and made it an object and then something like could work locally.


And that's actually kind of a problem because it'll actually be an array.


So you can't really interact with it.


You have to then interact.


The this template has to deal with its own things because it's just the first item in an array and it is actually not owned by the below key.


So something like that could potentially be what you're seeing.


And that's kind of a gotcha in the sense that you sort of have to remember that in Brightspot.


Basically most most every Jason key is an array.


So everything's in array is a good concept to follow.


But anyways, please follow up with either sort of your who you, whoever you're working with or Liz and we can figure out how to get, get into that.


But anyways, again, that's all I have.


Thank you guys for attending the, the front end training.


And like I said, Liz will be sending out this presentation as well as any sort of kind of follow ups via email.


So, thanks everyone for your time.


Thanks Tom.

Let us give you a demo

Hear how Brightspot can turn your digital strategy goals into a reality and see how the lives of your content creators and developers will be changed using our platform.

Request Demo