There are no notes for this item.

<div class="title  title--bg-pink  title--has-tail">
    <h2 class="title__highlight">
        This is a pink highlighted title with a tail
    </h2>
</div>
{% set textElement = textElement ?: 'h2' %}

{% set classString = '' %}
{% for modifier in modifiers %}
  {% set classString = classString ~ '  title--' ~ modifier %}
{% endfor %}
{% if background %}
  {% set classString = classString ~ '  title--bg-' ~ background %}
{% endif %}
{% if tail %}
  {% set classString = classString ~ '  title--has-tail' %}
{% endif %}
{% if animate %}
  {% set classString = classString ~ '  js-waypoint' %}
{% endif %}


<div class="title{{ classString }}">
  <{{ textElement }} class="title__highlight{{ textElementStyle ? '  ' ~ textElementStyle }}">
  {{ text }}
</{{ textElement }}>
</div>
  • Content:
    .title {
      // $title-bg-colors: see __vars/colours
    
      position: relative;
      --background: #{$primary};
      --color: white;
      max-width: 42em; // @TODO: why? what does this relate to? make a variable
      margin-bottom: $spacing-lg;
      margin-right: $spacing-md;
    
      + .title {
        margin-top: -$spacing-md;
      }
    }
    
    .slab, .mini-template-grid {
      .title {
        margin-top: 0;
      }
    }
    
    .title__highlight {
      position: relative;
      display: inline;
      left: $spacing-xs;
      padding: 0.25rem;
      line-height: 1.4;
      background: $primary;
      background: var(--background, #{$primary});
      color: white;
      color: var(--color);
      box-shadow: -$spacing-xs 0 0 0 #{$primary}, $spacing-xs 0 0 0 #{$primary};
      box-shadow: -$spacing-xs 0 0 0 var(--background, #{$primary}), $spacing-xs 0 0 0 var(--background, #{$primary});
      box-decoration-break: clone;
      //border-top: 0.25rem solid transparent;
      //border-bottom: 0.25rem solid transparent;
    
      a {
        color: white;
        color: var(--color);
      }
    }
    
    .title--has-tail {
      margin-top:  $spacing-3xl;
      
      .title__highlight { // @TODO: Consider refactoring onto parent to reduce specificity further
        &:before {
          position: absolute;
          content: '';
          margin-top: 2px;
          top: 0;
          left: -0.5rem;
          display: block;
          width: 1000px;
          height: 2px;
          transform: rotate(225deg);
          transform-origin: top left;
          background: $primary;
          background: var(--background, #{$primary});
          transition: transform 500ms;
        }
      }
    
      // We could use an animation if we wanted this to only run once...
      //
      //@keyframes title__drawIn {
      //  from { transform: translate(-50vw, -50vw) rotate(225deg); }
      //  to   { transform: translate(0, 0) rotate(225deg); }
      //}
    
      &.js-waypoint {
        .title__highlight {
          &:before {
            transform: translate(-50vw, -50vw) rotate(225deg);
          }
        }
      }
    
      &.is-waypoint-reached {
        .title__highlight {
          &:before {
            transform: rotate(225deg);
          }
        }
      }
    
      @at-root .no-js & {
        .title__highlight {
          &:before {
            transform: rotate(225deg);
          }
        }
      }
    }
    
    
    @each $name, $value in $title-bg-colors {
      .title--bg-#{$name} {
        --background: #{$value};
        @if ($value == 'white') {
          // we should probably be using choose-contrast-color($value) in the if here,
          // but someone wanted $gold--tef text to be white ¯\_(ツ)_/¯
          --color: black;
        }
      }
    }
    
    
    
  • URL: /components/raw/title/_title.scss
  • Filesystem Path: src/components/title/_title.scss
  • Size: 2.4 KB