< Shortcuts Page

Developer Documentation

Introduction

See documentation/README.md for an overview of the project structure and general guidelines for using BXI before digging into docs on this page.

Adding a new vertical

To add a new vertical add a folder for it in public/ (put images here if you have them) scss/ and src/pages/ along with appropriate files (see an existing vertical as an example). At this point you'll need to add the customizations.scss file in scss/index.scss, and adjust the vertical values in the newly created index and dashboard files (see the branding partial and body class). Then you will need run npm run start from the BXI repo. At this point server.js should pick up the new vertical and you should be able to access it via your browser and start developing!

Branding and Content

Each vertical has a branding.hbs and settings.json file next to the index.hbs (/<vertical>) and dashboad.hbs (/<vertical>/dashboard) pages. The branding file contains various css vars that typically handle colors and make re-branding a vertical easy for the user. Each branding file has a Global vars sections (variables that are using in the common scss styles and are typically the same across all verticals) and a vertical specific section (variables that are used in scss/<vertical>/customizations.scss). Generally you should never hard-code a color in a customizations or common scss file since it wouldn't be easy for users to customize. Some exceptions are made for non-brand specific colors (e.g. white). Content such as text and image locations should always be in the settings.json file for the vertical.

CSS and Layout

The general philosophy for page structure is use bootstrap 5.2 for as much as possible. If layout or adjustments can't be done with bootstrap, check for a BXI utility CSS class or add one (if it makes sense). Specific size values or colors that don't make sense as a common utility class can be added to customizations.scss for that vertical. Utility classes and classes added to the customizations file should be prefixed with .bxi- this is particulary important for trials and DV flows to help prevent styles from leaking outside of BXI. A similar pattern should also be followed with CSS variables.

Buttons

Name Example Code Snippet Notes
Small Button <button class="bxi-button">Click Me</button>
Medium Button <button class="bxi-button bxi-button--md">Click Me</button>
Large Button <button class="bxi-button bxi-button--lg">Click Me</button>
Link Button <button class="bxi-button bxi-button--link">Click Me</button>
Link Button Bold <button class="bxi-button bxi-button--link-bold">Click Me</button> Changes font-weight from 300 - 400 on hover, this is used in health, may not have any effect on other verticals depending on font
Icon Button <button class="bxi-button bxi-button--icon">{{> facebookIcon}}</button> Works with bxi-button--md and bxi-button--lg as well
X-Large Icon Button <button class="bxi-button bxi-button--xl bxi-button--icon">{{> facebookIcon}}</button> xl size only applies to icon buttons, necessary for alignment on some verticals in footer
Outline Button <button class="bxi-button bxi-button--outline">Click Me</button> Works with bxi-button--md and bxi-button--lg as well
White Button <button class="bxi-button bxi-button--white">Click Me</button> Works with bxi-button--md and bxi-button--lg as well
White Secondary Button <button class="bxi-button bxi-button--white-secondary">Click Me</button> Works with bxi-button--md and bxi-button--lg as well
Submit Button <button class="bxi-button bxi-button--submit">Click Me</button> Works with bxi-button--md and bxi-button--lg as well
Footer Outline Button
                  
<footer class="bxi-footer">
  ...
  <button class="bxi-button bxi-button--md bxi-button-outline">
    Click Me
  </button>
  ...
</footer>
                  
                
Footer Outline Icon Button
                  
<footer class="bxi-footer">
  ...
  <button class="bxi-button bxi-button--outline bxi-button--icon">
    {{> twitterIcon }}
  </button>
  ...
</footer>
                  
                

Auth Buttons

These are pretty confusing, there were no "stardards" followed when the original verticals were designed so each vertical has slightly different sizes, colors, borders etc. Here are some common examples, however often-times customizations to colors and sizes are necessary in the vertical's customizations.scss file (especially on mobile sizes where bg color can vary). Furthering the problem, since the nav buttons are in one file (home-nav-button.hbs) to make it easy to configure common buttons, the classes on the buttons cannot be modified directly, forcing us to rely on the bxi-auth-buttons parent element.

Name Example Code Snippets Description
Default <div class="bxi-auth-buttons"><button class="bxi-button">Login</button></div> Default button styling
Link <div class="bxi-auth-buttons bxi-auth-buttons--link"><button class="bxi-button">Login</button></div> White link, primary hover
Link Bold <div class="bxi-auth-buttons bxi-auth-buttons--link-bold"><button class="bxi-button">Login</button></div> Primary link, bold hover (behaves like bxi-button--link-bold)
White Link <div class="bxi-auth-buttons bxi-auth-buttons--white-link"><button class="bxi-button">Login</button></div> White link, off-white hover
Primary Link <div class="bxi-auth-buttons bxi-auth-buttons--primary-link"><button class="bxi-button">Login</button></div> Primary link, secondary hover
Secondary Link <div class="bxi-auth-buttons bxi-auth-buttons--secondary-link"><button class="bxi-button">Login</button></div> Secondary link, primary hover
Outline Button - Dark BG <div class="bxi-auth-buttons bxi-auth-buttons--outline-dark-bg"><button class="bxi-button">Login</button></div> White outline button, white bg secondary text on hover
Outline Button - Light BG <div class="bxi-auth-buttons bxi-auth-buttons--outline-light-bg"><button class="bxi-button">Login</button></div> White outline button, white bg secondary text on hover

Navigation Links

All navigation links have an accompanying breakpoint version that activates on large + screen sizes, this is used for links that need to be a different color in the dropdown hamburger menu.

Name Example Usage Breakpoint Class Notes
Link Link <a href="#" class="bxi-link">Link</a> n/a (see Link Primary)
Link White Link <a href="#" class="bxi-link bxi-link--white">Link</a> bxi-link-lg--white
Link White Bold Link <a href="#" class="bxi-link bxi-link--white-bold">Link</a> bxi-link-lg--white-bold Changes font-weight from 300 - 400 on hover, this is used in health, may not have any effect on other verticals depending on font
Link Primary Link <a href="#" class="bxi-link bxi-link--primary">Link</a> bxi-link-lg--primary Same as default
Link Primary Bold Link <a href="#" class="bxi-link bxi-link--primary-bold">Link</a> bxi-link-lg--primary-bold Changes font-weight from 300 - 400 on hover, this is used in health, may not have any effect on other verticals depending on font
Link Secondary Link <a href="#" class="bxi-link bxi-link--secondary">Link</a> bxi-link-lg--secondary
Link Light Primary Link <a href="#" class="bxi-link bxi-link-light--primary">Link</a> bxi-link-light-lg--primary
Link Light Secondary Link <a href="#" class="bxi-link bxi-link-light--secondary">Link</a> bxi-link-lg-light--secondary
Link Dark Primary Link <a href="#" class="bxi-link bxi-link-dark--primary">Link</a> bxi-link-dark-lg--primary
Link Dark Secondary Link <a href="#" class="bxi-link bxi-link-dark--secondary">Link</a> bxi-link-lg-dark--secondary

BXI Utility CSS

Note: the first few are not prefixed with bxi- I did this on purpose as they are filling in gaps with Bootstrap's utility classes.

Name Example Usage Description
.fw-boldish Text class="fw-boldish" Sets font weight to 500 (in addition to bootraps font weight classes)
.ls-none
  • 1
  • 2
<ul class="ls-none">...</ul> Remove bullets from an ordered or unordered list
.fs-7 Text class="fs-7" Font Size to 14px (continues bootstrap fs-1 - fs-6)
.fs-8 Text class="fs-8" Font Size to 12px (continues bootstrap fs-1 - fs-6)
.cursor-pointer Hover over me class="cursor-pointer" Cursor changed to pointer on hover
.bxi-overflow-x-auto
Lots and lots and lots and lots and lots and lots and lots of text
class="bxi-overflow-x-auto" Makes overflow content scrollable horizontally
.bxi-zi-1 N/A class="bxi-zi-1" Set z-index to 1
.bxi-zi-2 N/A class="bxi-zi-2" Set z-index to 2
.bxi-zi-3 N/A class="bxi-zi-3" Set z-index to 3
.bxi-zi-4 N/A class="bxi-zi-4" Set z-index to 4
.bxi-zi-5 N/A class="bxi-zi-5" Set z-index to 5
.bxi-truncate
Lots and lots and lots and lots and lots and lots and lots of text
class="bxi-truncate" Trancate overflow text and end with ellipsis
.bxi-ff-primary Text class="bxi-ff-primary" Apply primary font family (defined in branding) to element, note primary font is default but this is necessary to override where secondary is used
.bxi-ff-secondary Text class="bxi-secondary" Apply secondary font family (defined in branding) to element
.pe-lg-none class="pe-lg-none" Disable pointer events on large + screens
.bxi-footer class="bxi-footer" Apply color and bg color from associated branding vars
.bxi-copyright-color class="bxi-copyright-color" Apply color from --bxi-copyright-color var
.bxi-color-dark Text class="bxi-color-dark" This cannot be branded, do not use in a vertical, it was intented for dialogs
.bxi-color-light Text class="bxi-color-light" This cannot be branded, do not use in a vertical, it was intented for dialogs
.bxi-color-primary Text class="bxi-color-primary" Set element text color to --bxi-primary-color
.bxi-color-secondary Text class="bxi-color-secondary" Set element text color to --bxi-secondary-color
.bxi-bg-primary class="bxi-bg-primary" Set element background color to --bxi-primary-color
.bxi-bg-secondary class="bxi-bg-secondary" Set element background color to --bxi-secondary-color
.bxi-bg-transparent N/A class="bxi-bg-transparent" Set element background color to transparent
.bxi-bg-lg-transparent N/A class="bxi-bg-lg-transparent" Set element background color to transparent at large + sizes
.bxi-bg-image N/A class="bxi-bg-image" Use this along with style="background-image: xxx" sets background size position and repeat
.bxi-img-cover N/A class="bxi-img-cover" Use this on an abosulte positioned img that needs to behave like background-size: cover
.bxi-main-header Text class="bxi-main-header" Common class for large headers that are bigger than Bootstrap h1 or fs-1
.bxi-main-header-xl Text class="bxi-main-header-xl" Common class for large headers that are bigger than .bxi-main-header
.bxi-icon-color-primary <div class="bxi-icon-color-primary">{{>foodIcon}}</div> Color child svgs with --bxi-primary-color
.bxi-icon-color-secondary <div class="bxi-icon-color-secondary">{{>foodIcon}}</div> Color child svgs with --bxi-secondary-color
.bxi-stretch-third-md N/A <div class="row bxi-stretch-third-md">...</div> Occassionally it has been necessary to stretch the third column when it wraps and is all alone (e.g. airlines home), use this utility for that

SCSS Mixins

These are a collection of SCSS mixins that can be used within SCSS files (make sure to add @import "./mixins"; to the top of your scss file to use them).

Name Usage Description
breakpoint-sm @include breakpoint-sm { ... } Styles that will apply on sm (576px) + screen sizes
breakpoint-md @include breakpoint-md { ... } Styles that will apply on md (768px) + screen sizes
breakpoint-lg @include breakpoint-lg { ... } Styles that will apply on lg (992px) + screen sizes
breakpoint-xl @include breakpoint-xl { ... } Styles that will apply on xl (1200px) + screen sizes
breakpoint-lt-sm @include breakpoint-sm { ... } Styles that will apply on smaller than sm (575px) screen sizes
breakpoint-lt-md @include breakpoint-md { ... } Styles that will apply on smaller than md (767px) screen sizes
breakpoint-lt-lg @include breakpoint-lg { ... } Styles that will apply on smaller than lg (991px) screen sizes
breakpoint-lt-xl @include breakpoint-xl { ... } Styles that will apply on smaller than xl (1199px) screen sizes
color-icon($color) .some-element { @include color-icon(var(--bxi-some-color-car)); } Used to color child SVGs that are used via an icon partial
triangle($size, $color, $direction) @include triangle(4px, var(--bxi-some-color), 'down') { top: 10px; left: 10px } Used to add an absolute positioned triangle to an element, ensure element has position relative. You can pass down, up left or right as direction parameter.

Icons

To add a new icon, first create a new .hbs file for it in the src/partials/icons folder. Then copy the svg into the new file. After the file has been created change the class on the svg element to class="{{class}}" so that classes can be passed as parameters. Also make sure to find fill and stroke attribute on all path elements and change them to #fff (white). Any path element that has a fill attributes also needs class="fill-target" added to it, and all path elements that have a stroke attribute need to have class="stroke-target" added. This ensures our color-icon SCSS mixin will work with it. After you are done you will need to restart npm run start before the new icon partial will be picked up in server.js.

Description Example Usage
alert {{> alertIcon }}
arrow {{> arrowIcon }}
bell {{> bellIcon }}
calendar {{> calendarIcon }}
caret {{> caretIcon }}
cart {{> cartIcon }}
checkmark {{> checkmarkIcon }}
clock {{> clockIcon }}
document {{> documentIcon }}
dollar {{> dollarIcon }}
facebook {{> facebookIcon }}
favorite {{> favoriteIcon }}
food {{> foodIcon }}
gear {{> gearIcon }}
grocery {{> groceryIcon }}
hamburger {{> hamburgerIcon }}
instagram {{> instagramIcon }}
key {{> keyIcon }}
message {{> messageIcon }}
notification {{> notificationIcon }}
pdf {{> pdfIcon }}
pin {{> pinIcon }}
search {{> searchIcon }}
shield {{> shieldIcon }}
star {{> starIcon }}
timer {{> timerIcon }}
twitter {{> twitterIcon }}
user {{> userIcon }}

Trials

When a new vertical is added and complete it must be configured in the trials export as well. To do this ensure all of your changes are checked in and pushed (preferably merged into qa as well). And merge qa into the trials branch, then push it to origin. Before you can run the trials build, you need to add a settings override file (trials/settings/<vertical>.json) and a scss file (trials/scss/<vertical>.scss). The scss file is typically only needed for background-image style properties because webpack on the P1 side doesn't handle those inline properties (you'll notice these inline styles are removed in html-manipulations as well). The settings override file is merged into the main settings vertical file when a trials build occurs. This allows us to remove CTA buttons and override image locations (P1 needs ./<image-location>.(png|svg|jpg) instead of /<vertical>/<image-location>.(png|svg|jpg). Please note if you need to update images within an array whole array (including text values and all) must be preserved because they are overridden in their entirety.

You can test out changes in a "trials like" build by navigating to the trials folder in a terminal and running npm run test-build then cd dist and http-server in that dist folder. Run npm install -g http-server if you receive a package not found error. After you have verified changes and made any tweaks run npm run build to generate the files we merge into the trials repository in gitlab.

**IMPORTANT**
All changes in the trials/ folder should be checked into the trials branch, and any modifications in the BXI source code should go back into your branch, eventually qa and then merged back into trials.