1*c2f8f34eSDerick Montague# Presentation Layer Architecture 2*c2f8f34eSDerick Montague 3*c2f8f34eSDerick MontagueThis section discusses the structure and purpose of the SCSS files and how to 4*c2f8f34eSDerick Montaguecustomize the application using Bootstrap theming. 5*c2f8f34eSDerick Montague 6*c2f8f34eSDerick Montague[Read more about Bootstrap 7*c2f8f34eSDerick MontagueTheming](https://getbootstrap.com/docs/4.0/getting-started/theming) 8*c2f8f34eSDerick Montague 9*c2f8f34eSDerick Montague## SCSS Directory Structure 10*c2f8f34eSDerick Montague 11*c2f8f34eSDerick Montague### `bmc` Directory 12*c2f8f34eSDerick Montague 13*c2f8f34eSDerick MontagueThe `bmc` directory contains Sass helpers and default styles for customizing the OpenBMC 14*c2f8f34eSDerick MontagueWeb UI. 15*c2f8f34eSDerick Montague 16*c2f8f34eSDerick Montague```{5} 17*c2f8f34eSDerick Montague. 18*c2f8f34eSDerick Montague├─ src 19*c2f8f34eSDerick Montague ├─ assets 20*c2f8f34eSDerick Montague ├─ styles 21*c2f8f34eSDerick Montague ├─ bmc 22*c2f8f34eSDerick Montague ├─ custom 23*c2f8f34eSDerick Montague └─ helpers 24*c2f8f34eSDerick Montague ├─ bootstrap 25*c2f8f34eSDerick Montague └─ _obmc-custom.scss 26*c2f8f34eSDerick Montague``` 27*c2f8f34eSDerick Montague 28*c2f8f34eSDerick Montague### `custom` Directory 29*c2f8f34eSDerick Montague 30*c2f8f34eSDerick MontagueThe `custom` Directory imports all the styles needed to customize the UI. These 31*c2f8f34eSDerick Montagueare small changes used to reach parity with the OpenBMC Design Workgroup's 32*c2f8f34eSDerick Montagueagreed-upon design. The file naming convention closely follows the Bootstrap or 33*c2f8f34eSDerick MontagueBoostrap-vue library file naming since most of the ruleset selectors in these 34*c2f8f34eSDerick Montaguefiles are based on these two libraries. 35*c2f8f34eSDerick Montague 36*c2f8f34eSDerick Montague```{6} 37*c2f8f34eSDerick Montague. 38*c2f8f34eSDerick Montague├─ src 39*c2f8f34eSDerick Montague ├─ assets 40*c2f8f34eSDerick Montague ├─ styles 41*c2f8f34eSDerick Montague ├─ bmc 42*c2f8f34eSDerick Montague ├─ custom 43*c2f8f34eSDerick Montague ├─ alert.scss 44*c2f8f34eSDerick Montague ├─ _badge.scss 45*c2f8f34eSDerick Montague ├─ _base.scss 46*c2f8f34eSDerick Montague ├─ _bootstrap-grid.scss 47*c2f8f34eSDerick Montague ├─ _buttons.scss 48*c2f8f34eSDerick Montague ├─ _calendar.scss 49*c2f8f34eSDerick Montague ├─ _card.scss 50*c2f8f34eSDerick Montague ├─ _dropdown.scss 51*c2f8f34eSDerick Montague ├─ _forms.scss 52*c2f8f34eSDerick Montague ├─ _index.scss 53*c2f8f34eSDerick Montague ├─ _kvm.scss 54*c2f8f34eSDerick Montague ├─ _modal.scss 55*c2f8f34eSDerick Montague ├─ _pagination.scss 56*c2f8f34eSDerick Montague ├─ _sol.scss 57*c2f8f34eSDerick Montague ├─ _tables.scss 58*c2f8f34eSDerick Montague └─ _toasts.scss 59*c2f8f34eSDerick Montague ├─ helpers 60*c2f8f34eSDerick Montague ├─ bootstrap 61*c2f8f34eSDerick Montague └─ _obmc-custom.scss 62*c2f8f34eSDerick Montague``` 63*c2f8f34eSDerick Montague 64*c2f8f34eSDerick Montague### `helpers` Directory 65*c2f8f34eSDerick Montague 66*c2f8f34eSDerick MontagueThe `helpers` directory contains a set of Sass helper files containing Sass 67*c2f8f34eSDerick Montaguevariables that establish the custom theme of the application. 68*c2f8f34eSDerick Montague 69*c2f8f34eSDerick Montague```{6} 70*c2f8f34eSDerick Montague. 71*c2f8f34eSDerick Montague├─ src 72*c2f8f34eSDerick Montague ├─ assets 73*c2f8f34eSDerick Montague ├─ styles 74*c2f8f34eSDerick Montague ├─ bmc 75*c2f8f34eSDerick Montague ├─ helpers 76*c2f8f34eSDerick Montague ├─ _colors.scss 77*c2f8f34eSDerick Montague ├─ _functions.scss 78*c2f8f34eSDerick Montague ├─ _index.scss 79*c2f8f34eSDerick Montague ├─ _motion.scss 80*c2f8f34eSDerick Montague └─ _variables.scss 81*c2f8f34eSDerick Montague ├─ bootstrap 82*c2f8f34eSDerick Montague └─ _obmc-custom.scss 83*c2f8f34eSDerick Montague``` 84*c2f8f34eSDerick Montague 85*c2f8f34eSDerick Montague#### `_colors.scss` 86*c2f8f34eSDerick Montague 87*c2f8f34eSDerick MontagueThe `_colors.scss` file sets all the SASS variables and color maps for the OpenBMC 88*c2f8f34eSDerick MontagueWeb UI. Any color settings needed to meet company brand guidelines will happen 89*c2f8f34eSDerick Montaguein this file. 90*c2f8f34eSDerick Montague 91*c2f8f34eSDerick Montague##### Sass Color Variables 92*c2f8f34eSDerick Montague 93*c2f8f34eSDerick Montague```scss 94*c2f8f34eSDerick Montague$black: #000; 95*c2f8f34eSDerick Montague$white: #fff; 96*c2f8f34eSDerick Montague 97*c2f8f34eSDerick Montague$blue-500: #2d60e5; 98*c2f8f34eSDerick Montague$green-500: #0a7d06; 99*c2f8f34eSDerick Montague$red-500: #da1416; 100*c2f8f34eSDerick Montague$yellow-500: #efc100; 101*c2f8f34eSDerick Montague 102*c2f8f34eSDerick Montague$gray-100: #f4f4f4; 103*c2f8f34eSDerick Montague$gray-200: #e6e6e6; 104*c2f8f34eSDerick Montague$gray-300: #d8d8d8; 105*c2f8f34eSDerick Montague$gray-400: #cccccc; 106*c2f8f34eSDerick Montague$gray-500: #b3b3b3; 107*c2f8f34eSDerick Montague$gray-600: #999999; 108*c2f8f34eSDerick Montague$gray-700: #666666; 109*c2f8f34eSDerick Montague$gray-800: #3f3f3f; 110*c2f8f34eSDerick Montague$gray-900: #161616; 111*c2f8f34eSDerick Montague``` 112*c2f8f34eSDerick Montague 113*c2f8f34eSDerick Montague##### Custom Color Variables 114*c2f8f34eSDerick Montague 115*c2f8f34eSDerick Montague```scss 116*c2f8f34eSDerick Montague// Sass Base Color Variables 117*c2f8f34eSDerick Montague$blue: $blue-500; 118*c2f8f34eSDerick Montague$green: $green-500; 119*c2f8f34eSDerick Montague$red: $red-500; 120*c2f8f34eSDerick Montague$yellow: $yellow-500; 121*c2f8f34eSDerick Montague``` 122*c2f8f34eSDerick Montague 123*c2f8f34eSDerick Montague##### Custom Colors Map 124*c2f8f34eSDerick Montague 125*c2f8f34eSDerick Montague```scss 126*c2f8f34eSDerick Montague$colors: ( 127*c2f8f34eSDerick Montague "blue": $blue, 128*c2f8f34eSDerick Montague "green": $green, 129*c2f8f34eSDerick Montague "red": $red, 130*c2f8f34eSDerick Montague "yellow": $yellow, 131*c2f8f34eSDerick Montague); 132*c2f8f34eSDerick Montague``` 133*c2f8f34eSDerick Montague 134*c2f8f34eSDerick Montague##### Custom Theme Color Variables 135*c2f8f34eSDerick Montague 136*c2f8f34eSDerick Montague```scss 137*c2f8f34eSDerick Montague// Sass Theme Color Variables 138*c2f8f34eSDerick Montague// Can be used as variants 139*c2f8f34eSDerick Montague$danger: $red; 140*c2f8f34eSDerick Montague$dark: $gray-900; 141*c2f8f34eSDerick Montague$info: $blue; 142*c2f8f34eSDerick Montague$light: $gray-100; 143*c2f8f34eSDerick Montague$primary: $blue; 144*c2f8f34eSDerick Montague$secondary: $gray-800; 145*c2f8f34eSDerick Montague$success: $green; 146*c2f8f34eSDerick Montague$warning: $yellow; 147*c2f8f34eSDerick Montague``` 148*c2f8f34eSDerick Montague 149*c2f8f34eSDerick Montague##### Custom Theme Colors Map 150*c2f8f34eSDerick Montague 151*c2f8f34eSDerick Montague```scss 152*c2f8f34eSDerick Montague$theme-colors: ( 153*c2f8f34eSDerick Montague "primary": $primary, 154*c2f8f34eSDerick Montague "secondary": $secondary, 155*c2f8f34eSDerick Montague "dark": $dark, 156*c2f8f34eSDerick Montague "light": $light, 157*c2f8f34eSDerick Montague "danger": $danger, 158*c2f8f34eSDerick Montague "info": $info "success": $success "warning": $warning, 159*c2f8f34eSDerick Montague); 160*c2f8f34eSDerick Montague``` 161*c2f8f34eSDerick Montague 162*c2f8f34eSDerick Montague##### Color Resources 163*c2f8f34eSDerick Montague 164*c2f8f34eSDerick Montague- [Learn more about Bootstrap 165*c2f8f34eSDerick Montague colors](https://getbootstrap.com/docs/4.0/getting-started/theming/#color) 166*c2f8f34eSDerick Montague- [Learn more about Bootstrap 167*c2f8f34eSDerick Montague variables](https://getbootstrap.com/docs/4.0/getting-started/theming/#css-variables) 168*c2f8f34eSDerick Montague- [View the color palette and hex values in the color 169*c2f8f34eSDerick Montague guidelines](/guide/guidelines/colors) 170*c2f8f34eSDerick Montague 171*c2f8f34eSDerick Montague#### `_functions.scss` 172*c2f8f34eSDerick Montague 173*c2f8f34eSDerick MontagueTwo functions provide a customized way to set color highlights. The 174*c2f8f34eSDerick Montague`theme-color-light` and `theme-color-dark` are custom functions used to create 175*c2f8f34eSDerick Montaguecolors for the `alert`, `badge`, `card`, and `toast` components. They have also 176*c2f8f34eSDerick Montagueset color highlights for some pseudo-elements like `: hover`. 177*c2f8f34eSDerick Montague 178*c2f8f34eSDerick Montague##### Functions 179*c2f8f34eSDerick Montague 180*c2f8f34eSDerick Montague```scss 181*c2f8f34eSDerick Montague// This function is usually used to get a lighter 182*c2f8f34eSDerick Montague// theme variant color to use as a background color 183*c2f8f34eSDerick Montague@function theme-color-light($variant) { 184*c2f8f34eSDerick Montague @return theme-color-level($variant, -11.3); 185*c2f8f34eSDerick Montague} 186*c2f8f34eSDerick Montague 187*c2f8f34eSDerick Montague@function theme-color-dark($variant) { 188*c2f8f34eSDerick Montague @return theme-color-level($variant, 2); 189*c2f8f34eSDerick Montague} 190*c2f8f34eSDerick Montague``` 191*c2f8f34eSDerick Montague 192*c2f8f34eSDerick Montague##### Examples 193*c2f8f34eSDerick Montague 194*c2f8f34eSDerick Montague```scss{8-10,16} 195*c2f8f34eSDerick Montague.b-table-sort-icon-left { 196*c2f8f34eSDerick Montague background-position: left calc(1.5rem / 2) center !important; 197*c2f8f34eSDerick Montague padding-left: calc(1.2rem + 0.65em) !important; 198*c2f8f34eSDerick Montague &:focus { 199*c2f8f34eSDerick Montague outline: none; 200*c2f8f34eSDerick Montague box-shadow: inset 0 0 0 2px theme-color('primary') !important; 201*c2f8f34eSDerick Montague } 202*c2f8f34eSDerick Montague &:hover { 203*c2f8f34eSDerick Montague background-color: theme-color-dark('light'); 204*c2f8f34eSDerick Montague } 205*c2f8f34eSDerick Montague } 206*c2f8f34eSDerick Montague} 207*c2f8f34eSDerick Montague 208*c2f8f34eSDerick Montague&.alert-info { 209*c2f8f34eSDerick Montagueborder-left-color: theme-color("info"); 210*c2f8f34eSDerick Montaguebackground-color: theme-color-light("info"); 211*c2f8f34eSDerick Montaguefill: theme-color("info"); 212*c2f8f34eSDerick Montague} 213*c2f8f34eSDerick Montague``` 214*c2f8f34eSDerick Montague 215*c2f8f34eSDerick Montague#### `_motion.scss` 216*c2f8f34eSDerick Montague 217*c2f8f34eSDerick MontagueThis bezier curves and durations in this file determine the motion styles 218*c2f8f34eSDerick Montaguethroughout the application. These guidelines from the Cabon Design System avoid 219*c2f8f34eSDerick Montagueeasing curves that are unnatural, distracting, or purely decorative. 220*c2f8f34eSDerick Montague 221*c2f8f34eSDerick Montague##### Motion Styles 222*c2f8f34eSDerick Montague 223*c2f8f34eSDerick Montague```scss 224*c2f8f34eSDerick Montague$duration--fast-01: 70ms; //Micro-interactions such as button and toggle 225*c2f8f34eSDerick Montague$duration--fast-02: 110ms; //Micro-interactions such as fade 226*c2f8f34eSDerick Montague$duration--moderate-01: 150ms; //Micro-interactions, small expansion, short distance movements 227*c2f8f34eSDerick Montague$duration--moderate-02: 240ms; //Expansion, system communication, toast 228*c2f8f34eSDerick Montague$duration--slow-01: 400ms; //Large expansion, important system notifications 229*c2f8f34eSDerick Montague$duration--slow-02: 700ms; //Background dimming 230*c2f8f34eSDerick Montague 231*c2f8f34eSDerick Montague$standard-easing--productive: cubic-bezier(0.2, 0, 0.38, 0.9); 232*c2f8f34eSDerick Montague$standard-easing--expressive: cubic-bezier(0.4, 0.14, 0.3, 1); 233*c2f8f34eSDerick Montague$entrance-easing--productive: cubic-bezier(0, 0, 0.38, 0.9); 234*c2f8f34eSDerick Montague$entrance-easing--expressive: cubic-bezier(0, 0, 0.3, 1); 235*c2f8f34eSDerick Montague$exit-easing--productive: cubic-bezier(0.2, 0, 1, 0.9); 236*c2f8f34eSDerick Montague$exit-easing--expressive: cubic-bezier(0.4, 0.14, 1, 1); 237*c2f8f34eSDerick Montague``` 238*c2f8f34eSDerick Montague 239*c2f8f34eSDerick Montague##### Example 240*c2f8f34eSDerick Montague 241*c2f8f34eSDerick Montague```scss{6,9} 242*c2f8f34eSDerick Montague.link-skip-nav { 243*c2f8f34eSDerick Montague position: absolute; 244*c2f8f34eSDerick Montague top: -60px; 245*c2f8f34eSDerick Montague left: 0.5rem; 246*c2f8f34eSDerick Montague z-index: $zindex-popover; 247*c2f8f34eSDerick Montague transition: $duration--moderate-01 $exit-easing--expressive; 248*c2f8f34eSDerick Montague &:focus { 249*c2f8f34eSDerick Montague top: 0.5rem; 250*c2f8f34eSDerick Montague transition-timing-function: $entrance-easing--expressive; 251*c2f8f34eSDerick Montague } 252*c2f8f34eSDerick Montague} 253*c2f8f34eSDerick Montague``` 254*c2f8f34eSDerick Montague 255*c2f8f34eSDerick Montague##### Motion Resources 256*c2f8f34eSDerick Montague 257*c2f8f34eSDerick Montague- [Including Animation In Your Design 258*c2f8f34eSDerick Montague System](https://www.smashingmagazine.com/2019/02/animation-design-system/) 259*c2f8f34eSDerick Montague- [Carbon Design System motion 260*c2f8f34eSDerick Montague guidelines](https://www.carbondesignsystem.com/guidelines/motion/basics/) 261*c2f8f34eSDerick Montague 262*c2f8f34eSDerick Montague#### `_variables.scss` 263*c2f8f34eSDerick Montague 264*c2f8f34eSDerick MontagueThis file contains all the global Sass options. There are Bootstrap option 265*c2f8f34eSDerick Montagueoverrides, Bootstrap global variable overrides, and custom BMC global variables. 266*c2f8f34eSDerick MontagueRead more about these in the [Customization section](/customize/theme). 267*c2f8f34eSDerick Montague 268*c2f8f34eSDerick Montague### `bootstrap` Directory 269*c2f8f34eSDerick Montague 270*c2f8f34eSDerick MontagueThe `bootstrap` directory contains all the import references. The references are 271*c2f8f34eSDerick Montaguesplit into multiple files to support import order based on dependency. Helper 272*c2f8f34eSDerick Montaguestyles need to be imported before all other styles. 273*c2f8f34eSDerick Montague 274*c2f8f34eSDerick Montague```{6} 275*c2f8f34eSDerick Montague. 276*c2f8f34eSDerick Montague├─ src 277*c2f8f34eSDerick Montague ├─ assets 278*c2f8f34eSDerick Montague ├─ styles 279*c2f8f34eSDerick Montague ├─ bmc 280*c2f8f34eSDerick Montague ├─ bootstrap 281*c2f8f34eSDerick Montague ├─ _helpers.scss 282*c2f8f34eSDerick Montague └─ _index.scss 283*c2f8f34eSDerick Montague └─ _obmc-custom.scss 284*c2f8f34eSDerick Montague``` 285*c2f8f34eSDerick Montague 286*c2f8f34eSDerick Montague#### `_helpers.scss` 287*c2f8f34eSDerick Montague 288*c2f8f34eSDerick MontagueThis file contains all the helper import references for Bootstrap. 289*c2f8f34eSDerick Montague 290*c2f8f34eSDerick Montague#### `_index.scss` 291*c2f8f34eSDerick Montague 292*c2f8f34eSDerick MontagueThis file contains all the import references needed to support the base, 293*c2f8f34eSDerick Montaguecomponents, and utility styles. 294*c2f8f34eSDerick Montague 295*c2f8f34eSDerick Montague### `_obmc-custom.scss` 296*c2f8f34eSDerick Montague 297*c2f8f34eSDerick Montague```{9} 298*c2f8f34eSDerick Montague. 299*c2f8f34eSDerick Montague├─ src 300*c2f8f34eSDerick Montague ├─ assets 301*c2f8f34eSDerick Montague ├─ styles 302*c2f8f34eSDerick Montague ├─ bmc 303*c2f8f34eSDerick Montague ├─ bootstrap 304*c2f8f34eSDerick Montague └─ _obmc-custom.scss 305*c2f8f34eSDerick Montague``` 306*c2f8f34eSDerick Montague 307*c2f8f34eSDerick MontagueThe `obmc-custom.scss` file defines all of the presentational layer 308*c2f8f34eSDerick Montaguedependencies. 309*c2f8f34eSDerick Montague 310*c2f8f34eSDerick Montague- [Read more about Bootstrap 311*c2f8f34eSDerick Montague options](https://getbootstrap.com/docs/4.0/getting-started/theming/#sass-options) 312*c2f8f34eSDerick Montague- [Read more about 313*c2f8f34eSDerick Montague Importing](https://getbootstrap.com/docs/4.0/getting-started/theming/#importing) 314*c2f8f34eSDerick Montague 315*c2f8f34eSDerick Montague## Component / View Styles 316*c2f8f34eSDerick Montague 317*c2f8f34eSDerick MontagueSome stylistic changes only apply to a single-file component or view instance. 318*c2f8f34eSDerick MontagueIn this case, rather than adding a Sass file, the scoped styles include the 319*c2f8f34eSDerick Montaguestyles in the component's `<style>` block. It is required to import the 320*c2f8f34eSDerick Montague`_helpers` Sass file when using a BMC or Bootstrap variable in the component's 321*c2f8f34eSDerick Montague`<style>` block. Without this import, webpack cannot compile the OpenBMC Web UI 322*c2f8f34eSDerick MontagueCSS styles correctly. 323*c2f8f34eSDerick Montague 324*c2f8f34eSDerick Montague### Scoped style block using SASS 325*c2f8f34eSDerick Montague 326*c2f8f34eSDerick Montague```html 327*c2f8f34eSDerick Montague<style scoped lang="scss"> 328*c2f8f34eSDerick Montague ... 329*c2f8f34eSDerick Montague</style> 330*c2f8f34eSDerick Montague``` 331*c2f8f34eSDerick Montague 332*c2f8f34eSDerick Montague### Scoped style block using CSS 333*c2f8f34eSDerick Montague 334*c2f8f34eSDerick Montague```html 335*c2f8f34eSDerick Montague<style scoped> 336*c2f8f34eSDerick Montague ...; 337*c2f8f34eSDerick Montague</style> 338*c2f8f34eSDerick Montague``` 339*c2f8f34eSDerick Montague 340*c2f8f34eSDerick Montague### Example - PageSection.vue 341*c2f8f34eSDerick Montague 342*c2f8f34eSDerick Montague```html 343*c2f8f34eSDerick Montague<style lang="scss" scoped> 344*c2f8f34eSDerick Montague .page-section { 345*c2f8f34eSDerick Montague margin-bottom: $spacer * 2; 346*c2f8f34eSDerick Montague } 347*c2f8f34eSDerick Montague 348*c2f8f34eSDerick Montague h2 { 349*c2f8f34eSDerick Montague @include font-size($h3-font-size); 350*c2f8f34eSDerick Montague margin-bottom: $spacer; 351*c2f8f34eSDerick Montague &::after { 352*c2f8f34eSDerick Montague content: ""; 353*c2f8f34eSDerick Montague display: block; 354*c2f8f34eSDerick Montague width: 100px; 355*c2f8f34eSDerick Montague border: 1px solid $gray-300; 356*c2f8f34eSDerick Montague margin-top: 10px; 357*c2f8f34eSDerick Montague } 358*c2f8f34eSDerick Montague } 359*c2f8f34eSDerick Montague</style> 360*c2f8f34eSDerick Montague``` 361*c2f8f34eSDerick Montague 362*c2f8f34eSDerick Montague:::tip 363*c2f8f34eSDerick MontagueYou might notice that there is an HTML element, `<h2>`, used in the example. This is an anti-pattern in global `.scss` files. However, in a single file component that generates the markup it is acceptable. 364*c2f8f34eSDerick Montague::: 365*c2f8f34eSDerick Montague 366*c2f8f34eSDerick Montague[Learn more about single file components](https://vuejs.org/v2/guide/single-file-components.html) 367*c2f8f34eSDerick Montague 368*c2f8f34eSDerick MontagueCustomization of the application requires knowledge of Sass and CSS. It also 369*c2f8f34eSDerick Montaguewill require becoming familiar with the Bootstrap and Bootstrap-Vue component 370*c2f8f34eSDerick Montaguelibraries. This section outlines the global options and variables that can be 371*c2f8f34eSDerick Montagueremoved or updated to meet organizational brand guidelines. 372