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