Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Changes to the global Bootstrap styles (Sass/CSS), font or color scheme variables or styles will apply to all pages / Angular components across the entire site.

  1. Global style changes: All global style changes can be made in your theme's styles folder (e.g. src/themes/mydspacesite/styles). There are four main files in that folder:
    1. _theme_sass_variable_overrides.scss - May be used to override Bootstrap's default Sass variables.  This is the file you may wish to use for most  style changes. There are a large number of Bootstrap variables available which control everything from fonts, colors and the base style for all Bootstrap web components.  For a full list of Bootstrap variables you can override in this file, see the node_modules/bootstrap/scss/_variables.scss file (which is installed in your source directory when you run "yarn install"). More information may also be found in the Bootstrap Sass documentation at https://getbootstrap.com/docs/4.0/getting-started/theming/#sass
    2. _theme_css_variable_overrides.scss - May be used to override DSpace's default CSS variables. DSpace's UI uses CSS variables for all its components. These variables all start with "--ds-*", and are listed in src/styles/_custom_variables.scss. You can also use this file to add your own, custom CSS variables which you want to use for your theme.  If you create custom variables, avoid naming them with a "--ds-*" or a "--bs-*" prefix, as those are reserved for DSpace and Bootstrap variables.
    3. _global-styles.scss - May be used to modify the global CSS/SCSS for the site.  This file may be used to override the default global style contained in src/styles/_global-styles.scss .  Keep in mind, many styles can be more quickly changed by simply updating a variable in one of the above "*_variable_overrides.scss" files.  So, it's often easier to use those first, where possible.
    4. theme.scss - This just imports all the necessary Sass files to create the theme. It's unnecessary to modify directly, unless you with to add new Sass files to your theme.
  2. Modifying the default font: The font used in your site can be quickly updated via Bootstrap variables in your theme's _theme_sass_variable_overrides.scss file. 
    1. One option is to add a new import statement and modify the "$font-family-sans-serif" variable:

      Code Block
      // Import the font (from a URL)
      @import url('https://fonts.googleapis.com/css?family=Source+Sans+Pro');
      
      // Configure Bootstrap to use this font (and list a number of backup fonts to use on various systems)
      $font-family-sans-serif: 'Source Sans Pro', -apple-system, BlinkMacSystemFont, "Segoe UI", "Roboto", "Helvetica Neue", Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol" !default;


    2. If your font requires installing local files, you can do the following
      1. Copy your font file(s) in your theme's assets/fonts/ folder
      2. Create a new ".scss" file specific to your font in that folder, e.g. assets/fonts/open-sans.scss, and use the "@font-face" CSS rule to load that font:

        Code Block
        titleopen-sans.scss
        @font-face {
          font-family: "Open Sans";
          src: url("/assets/fonts/OpenSans-Regular-webfont.woff2") format("woff2"),
               url("/assets/fonts/OpenSans-Regular-webfont.woff") format("woff");
        }


      3. Then, import that new "open-sans.scss" file and use it in the "$font-family-sans-serif" variable

        Code Block
        // Import the font via the custom SCSS file
        @import '../assets/fonts/open-sans';
        
        // Configure Bootstrap to use this font (and list a number of backup fonts to use on various systems) 
        $font-family-sans-serif: 'Open Sans', -apple-system, BlinkMacSystemFont, "Segoe UI", "Roboto", "Helvetica Neue", Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol" !default;


    3. Keep in mind, as changing the font just requires adjusting Bootstrap Sass variables, there are a lot of Bootstrap guides out there that can help you make more advanced changes
  3. Modifying default color scheme: The colors used in your site can be quickly updated via Bootstrap variables in your theme's _theme_sass_variable_overrides.scss file. 
    1. Again, you can use entirely Bootstrap variables to adjust color schemes.  See the Bootstrap Theming Colors documentation
    2. Additional examples can be found in the out-of-the-box "dspace" theme, which adjusts the default Bootstrap colors slightly for both accessibility & to match the DSpace logo.

Modify Logo in Header

  1. Copy your logo to your theme's assets/image/ folder
  2. Edit your theme's app/header/header.components.ts file & swap the "templateUrl" properties

    Code Block
    titleheader.component.ts
    @Component({
      selector: 'ds-header',
      // styleUrls: ['header.component.scss'],
      styleUrls: ['../../../../app/header/header.component.scss'],
      // Uncomment the templateUrl which references the "header.component.html" file in your theme directory
      templateUrl: 'header.component.html',
      // Comment out the templateUrl which references the default "src/app/header/header.component.html" file.
      //templateUrl: '../../../../app/header/header.component.html',
    })


  3. Your theme's version of the header.component.html file will be empty by default. Copy over the default HTML code from src/app/header/header.component.html into your version of this file.
  4. Then, modify your copy of header.component.html to use your logo. In this example, we're assuming you have a logo file named assets/images/my-logo.svg:

    Code Block
    <header>
      <div class="container">
        <div class="d-flex flex-row justify-content-between">
          <a class="navbar-brand my-2" routerLink="/home">
            <!-- Modify the logo on the next line -->
            <img src="assets/images/my-logo.svg" [attr.alt]="'menu.header.image.logo' | translate"/>
          </a>
          ...
    </header>


  5. Obviously, you can also make additional modifications to the HTML of the header in this file!  You'll also see that the header references several other DSpace UI components (e.g. <ds-search-navbar> is the search icon in the header). You can easily comment out these tags to disable them, or move them around to change where that component appears in the header.