{"version":3,"sources":["../../../../src/nhsuk/core/tools/_spacing.scss"],"names":[],"mappings":"AAAA,4CAA4C;;AAE5C,gBAAgB;AAChB,eAAe;AACf,gBAAgB;AAChB,gBAAgB;AAChB,uBAAuB;AACvB,qBAAqB;AACrB,mBAAmB;;AAEnB,GAAG;AACH,UAAU;AACV,EAAE;AACF,eAAe;AACf,GAAG;;AAEH,uBAAuB;AACvB,EAAE;AACF,oEAAoE;AACpE,EAAE;AACF,8DAA8D;AAC9D,qCAAqC;AACrC,wEAAwE;AACxE,mEAAmE;AACnE,yDAAyD;AACzD,+CAA+C;AAC/C,EAAE;AACF,gBAAgB;AAChB,eAAe;AACf,iCAAiC;AACjC,MAAM;AACN,EAAE;AACF,uCAAuC;AACvC,eAAe;AACf,qCAAqC;AACrC,MAAM;AACN,EAAE;AACF,0DAA0D;AAC1D,eAAe;AACf,+CAA+C;AAC/C,MAAM;AACN,EAAE;AACF,6GAA6G;;AAE7G;EACE;IACE;yCACqC;EACvC;;EAEA;IACE,gCAAgC;EAClC;;EAEA,mBAAmB;EACnB;IACE,kBAAkB;IAClB,wCAAwC;EAC1C;;EAEA;IACE;mDAC+C;EACjD;;EAEA,8DAA8D;;EAE9D;IACE,mCAAmC;EACrC;;EAEA;IACE,+CAA+C;EACjD;;EAEA;IACE;MACE,kDAAkD;IACpD,EAAE;MACA,4CAA4C;IAC9C;EACF;;EAEA;IACE,yCAAyC;EAC3C;;EAEA,sBAAsB;AACxB;;AAEA,qBAAqB;AACrB,EAAE;AACF,+EAA+E;AAC/E,+EAA+E;AAC/E,qDAAqD;AACrD,EAAE;AACF,mEAAmE;AACnE,oCAAoC;AACpC,EAAE;AACF,8EAA8E;AAC9E,iEAAiE;AACjE,yEAAyE;AACzE,wEAAwE;AACxE,6CAA6C;AAC7C,wEAAwE;AACxE,mEAAmE;AACnE,yDAAyD;AACzD,EAAE;AACF,gBAAgB;AAChB,WAAW;AACX,uDAAuD;AACvD,oGAAoG;AACpG,MAAM;AACN,EAAE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ChB,WAAW;AACX,sEAAsE;AACtE,MAAM;AACN,EAAE;AACF,6GAA6G;;AAE7G;;;;;;;EAOE,mHAAmH;AACrH","file":"_spacing.scss","sourcesContent":["// stylelint-disable declaration-no-important\n\n@use \"sass:list\";\n@use \"sass:map\";\n@use \"sass:math\";\n@use \"sass:meta\";\n@use \"../settings\" as *;\n@use \"functions\" as *;\n@use \"sass-mq\" as *;\n\n////\n/// Spacing\n///\n/// @group tools\n////\n\n/// Single point spacing\n///\n/// Returns measurement corresponding to the spacing point requested.\n///\n/// @param {Number} $spacing-point - Point on the spacing scale\n///  (set in `settings/_spacing.scss`)\n/// @param {Boolean} $important [false] - Whether to mark as `!important`\n/// @param {Number} $adjustment [null] - Offset to adjust spacing by\n/// @param {String} $unit [\"px\"] - Unit to use for spacing\n/// @return {String} Spacing measurement eg. 8px\n///\n/// @example scss\n///   .element {\n///     padding: nhsuk-spacing(5);\n///   }\n///\n/// @example scss Using negative spacing\n///   .element {\n///     margin-top: nhsuk-spacing(-1);\n///   }\n///\n/// @example scss Marking spacing declarations as important\n///   .element {\n///     margin-top: nhsuk-spacing(1) !important;\n///   }\n///\n/// @link https://github.com/alphagov/govuk-frontend Original code taken from GDS (Government Digital Service)\n\n@function nhsuk-spacing($spacing-point, $important: false, $adjustment: null, $unit: \"px\") {\n  @if meta.type-of($spacing-point) != \"number\" {\n    @error \"Expected a number (integer), but got a \"\n      + \"#{meta.type-of($spacing-point)}\";\n  }\n\n  @if not list.index((\"px\", \"rem\"), #{$unit}) {\n    @error \"Unknown unit `#{$unit}`\";\n  }\n\n  $is-negative: false;\n  @if $spacing-point < 0 {\n    $is-negative: true;\n    $spacing-point: math.abs($spacing-point);\n  }\n\n  @if not map.has-key($nhsuk-spacing-points, $spacing-point) {\n    @error \"Unknown spacing point `#{$spacing-point}`. Make sure you are using a point from the \"\n      + \"spacing scale in `_settings/spacing.scss`\";\n  }\n\n  $spacing-value: map.get($nhsuk-spacing-points, $spacing-point);\n\n  @if $is-negative {\n    $spacing-value: $spacing-value * -1;\n  }\n\n  @if $unit == \"rem\" {\n    $spacing-value: nhsuk-px-to-rem($spacing-value);\n  }\n\n  @if $adjustment {\n    @if not math.compatible($spacing-value, $adjustment) {\n      $spacing-value: calc($spacing-value + $adjustment);\n    } @else {\n      $spacing-value: $spacing-value + $adjustment;\n    }\n  }\n\n  @if $important == true {\n    $spacing-value: $spacing-value !important;\n  }\n\n  @return $spacing-value;\n}\n\n/// Responsive spacing\n///\n/// Adds responsive spacing (either padding or margin, depending on `$property`)\n/// by fetching a 'spacing map' from the responsive spacing scale, which defines\n/// different spacing values at different breakpoints.\n///\n/// To generate responsive spacing, use 'nhsuk-responsive-margin' or\n/// 'nhsuk-responsive-padding' mixins\n///\n/// @param {Number} $responsive-spacing-point - Point on the responsive spacing\n///  scale, corresponds to a map of breakpoints and spacing values\n/// @param {String} $property - Property to add spacing to (e.g. 'margin')\n/// @param {String | List} $direction [all] - Direction to add spacing to\n///  (`top`, `right`, `bottom`, `left`, `all`)\n/// @param {Boolean} $important [false] - Whether to mark as `!important`\n/// @param {Number} $adjustment [null] - Offset to adjust spacing by\n/// @param {String} $unit [\"px\"] - Unit to use for spacing\n///\n/// @example scss\n///   .foo {\n///     @include nhsuk-responsive-spacing(4, \"padding\");\n///     @include nhsuk-responsive-spacing(2, \"top\", $important: true); // if `!important` is required\n///   }\n///\n/// 1. Make sure that the return value from `_settings/spacing.scss` is a map.\n/// 2. Loop through each breakpoint in the map\n/// 3. The 'null' breakpoint is for mobile.\n///\n/// @link https://github.com/alphagov/govuk-frontend Original code taken from GDS (Government Digital Service)\n\n@mixin nhsuk-responsive-spacing(\n  $responsive-spacing-point,\n  $property,\n  $direction: \"all\",\n  $important: false,\n  $adjustment: null,\n  $unit: \"px\"\n) {\n  @if meta.type-of($responsive-spacing-point) != \"number\" {\n    @error \"Expected a number (integer), but got a \" + \"#{meta.type-of($responsive-spacing-point)}\";\n  }\n\n  @if not list.index((\"px\", \"rem\"), #{$unit}) {\n    @error \"Unknown unit `#{$unit}`\";\n  }\n\n  $is-negative: false;\n  @if $responsive-spacing-point < 0 {\n    $is-negative: true;\n    $responsive-spacing-point: math.abs($responsive-spacing-point);\n  }\n\n  @if not list.index((\"string\", \"list\"), meta.type-of($direction)) {\n    @error \"Expected a string or list, but got a \" + \"#{meta.type-of($direction)}\";\n  }\n\n  $directions: ();\n  @if meta.type-of($direction) == \"list\" {\n    $directions: list.join($directions, $direction);\n  } @else {\n    $directions: ($direction);\n  }\n\n  @if not map.has-key($nhsuk-spacing-responsive-scale, $responsive-spacing-point) {\n    @error \"Unknown responsive spacing point `#{$responsive-spacing-point}`. Make sure you are using a point from the \"\n      + \"responsive spacing scale in `_settings/spacing.scss`\";\n  }\n\n  $scale-map: map.get($nhsuk-spacing-responsive-scale, $responsive-spacing-point); // [1]\n  @if meta.type-of($scale-map) != \"map\" {\n    @error \"Expected a number (integer), but got a \"\n      + \"#{meta.type-of($scale-map)}. Make sure you are using a map to set the responsive spacing in `_settings/spacing.scss`)\";\n  }\n\n  // [2]\n  @each $breakpoint, $breakpoint-value in $scale-map {\n    @if $is-negative {\n      $breakpoint-value: $breakpoint-value * -1;\n    }\n\n    @if $unit == \"rem\" {\n      $breakpoint-value: nhsuk-px-to-rem($breakpoint-value);\n    }\n\n    @if $adjustment {\n      @if not math.compatible($breakpoint-value, $adjustment) {\n        $breakpoint-value: calc($breakpoint-value + $adjustment);\n      } @else {\n        $breakpoint-value: $breakpoint-value + $adjustment;\n      }\n    }\n\n    @if $important == true {\n      $breakpoint-value: $breakpoint-value !important;\n    }\n\n    & {\n      // [3]\n      @if not $breakpoint {\n        @each $direction in $directions {\n          @if $direction == all {\n            #{$property}: $breakpoint-value;\n          } @else {\n            #{$property}-#{$direction}: $breakpoint-value;\n          }\n        }\n      } @else {\n        @media #{nhsuk-from-breakpoint($breakpoint)} {\n          @each $direction in $directions {\n            @if $direction == all {\n              #{$property}: $breakpoint-value;\n            } @else {\n              #{$property}-#{$direction}: $breakpoint-value;\n            }\n          }\n        }\n      }\n    }\n  }\n}\n\n/// Responsive margin\n///\n/// Adds responsive margin by fetching a 'spacing map' from the responsive\n/// spacing scale, which defines different spacing values at different\n/// breakpoints. Wrapper for the `nhsuk-responsive-spacing` mixin.\n///\n/// @param {Number} $responsive-spacing-point - Point on the responsive spacing\n/// scale, corresponds to a map of breakpoints and spacing values\n/// @param {String | List} $direction [all] - Direction(s) to add spacing to\n///   (`top`, `right`, `bottom`, `left`, `all`)\n/// @param {Boolean} $important [false] - Whether to mark as `!important`\n/// @param {Number} $adjustment [null] - Offset to adjust spacing by\n/// @param {String} $unit [\"px\"] - Unit to use for spacing\n///\n/// @example scss\n///   .foo {\n///     @include nhsuk-responsive-margin(6, \"left\", $adjustment: 1px);\n///   }\n///\n/// @link https://github.com/alphagov/govuk-frontend Original code taken from GDS (Government Digital Service)\n\n@mixin nhsuk-responsive-margin(\n  $responsive-spacing-point,\n  $direction: \"all\",\n  $important: false,\n  $adjustment: null,\n  $unit: \"px\"\n) {\n  @include nhsuk-responsive-spacing($responsive-spacing-point, \"margin\", $direction, $important, $adjustment, $unit);\n}\n\n/// Responsive padding\n///\n/// Adds responsive padding by fetching a 'spacing map' from the responsive\n/// spacing scale, which defines different spacing values at different\n/// breakpoints. Wrapper for the `nhsuk-responsive-spacing` mixin.\n///\n/// @param {Number} $responsive-spacing-point - Point on the responsive spacing\n///   scale, corresponds to a map of breakpoints and spacing values\n/// @param {String | List} $direction [all] - Direction(s) to add spacing to\n///   (`top`, `right`, `bottom`, `left`, `all`)\n/// @param {Boolean} $important [false] - Whether to mark as `!important`\n/// @param {Number} $adjustment [null] - Offset to adjust spacing by\n/// @param {String} $unit [\"px\"] - Unit to use for spacing\n///\n/// @example scss\n///   .foo {\n///     @include nhsuk-responsive-padding(6, 'left', $adjustment: 1px);\n///   }\n///\n/// @link https://github.com/alphagov/govuk-frontend Original code taken from GDS (Government Digital Service)\n\n@mixin nhsuk-responsive-padding(\n  $responsive-spacing-point,\n  $direction: \"all\",\n  $important: false,\n  $adjustment: null,\n  $unit: \"px\"\n) {\n  @include nhsuk-responsive-spacing($responsive-spacing-point, \"padding\", $direction, $important, $adjustment, $unit);\n}\n"]}
