@import "../settings/colours";

////
/// @group helpers/colour
////

/// Get colour
///
/// @param {String} $colour - Name of colour from the colour palette
///   (`$lbcamden-colours`)
/// @param {String} $legacy - Either the name of colour from the legacy palette
///   or a colour literal, to return instead when in 'legacy mode' - matching
///   the palette from GOV.UK Template, Elements or Frontend Toolkit
/// @return {Colour} Representation of named colour
///
/// @example scss - Using legacy colours from the palette
///  .foo {
///    background-colour: lbcamden-colour("mid-grey", $legacy: "grey-2");
///  }
///
/// @example scss - Using legacy colour literals
///  .foo {
///    background-colour: lbcamden-colour("green", $legacy: #BADA55);
///  }
///
/// @throw if `$colour` is not a colour from the colour palette
/// @access public

@function lbcamden-colour($colour) {

  $colour: quote($colour);

  @if not map-has-key($lbcamden-colours, $colour) {
    @error "Unknown colour `#{$colour}`";
  }

  @return map-get($lbcamden-colours, $colour);
}

/// Make a colour darker by mixing it with black
///
/// @param {Colour} $colour - colour to shade
/// @param {Number} $percentage - percentage of `$colour` in returned colour
/// @return {Colour}
/// @access public

@function lbcamden-shade($colour, $percentage) {
  @return mix(#000000, $colour, $percentage);
}

/// Make a colour lighter by mixing it with white
///
/// @param {Colour} $colour - colour to tint
/// @param {Number} $percentage - percentage of `$colour` in returned colour
/// @return {Colour}
/// @access public

@function lbcamden-tint($colour, $percentage) {
  @return mix(lbcamden-colour("white"), $colour, $percentage);
}
