68 lines
1.4 KiB
SCSS
68 lines
1.4 KiB
SCSS
|
// SVG Grid Math
|
||
|
// =============
|
||
|
|
||
|
|
||
|
|
||
|
// SVG Column Position
|
||
|
// -------------------
|
||
|
/// Determine the proper horizontal position
|
||
|
/// for a column rectangle
|
||
|
///
|
||
|
/// @access private
|
||
|
///
|
||
|
/// @param {Integer} $column -
|
||
|
/// 1-indexed column location on the grid
|
||
|
/// @param {Map} $grid -
|
||
|
/// Normalized settings map representing the current grid
|
||
|
///
|
||
|
/// @return {Length} -
|
||
|
/// Horizontal position of svg column rectangle,
|
||
|
/// as distance from the grid edge
|
||
|
@function _susy-svg-column-position(
|
||
|
$column,
|
||
|
$grid
|
||
|
) {
|
||
|
$x: $column - 1;
|
||
|
|
||
|
@if ($x > 0) {
|
||
|
$x: susy-span(first $x wide, $grid);
|
||
|
}
|
||
|
|
||
|
@return $x;
|
||
|
}
|
||
|
|
||
|
|
||
|
|
||
|
// SVG Offset
|
||
|
// ----------
|
||
|
/// Determine if a grid image needs to be offset,
|
||
|
/// to account for edge gutters.
|
||
|
///
|
||
|
/// @access private
|
||
|
///
|
||
|
/// @param {Map} $grid -
|
||
|
/// Normalized settings map representing the current grid
|
||
|
///
|
||
|
/// @return {Length | null} -
|
||
|
/// Expected distance from container edge to first column,
|
||
|
/// based on spread values and gutter-widths
|
||
|
@function _susy-svg-offset(
|
||
|
$grid
|
||
|
) {
|
||
|
$columns: su-valid-columns(map-get($grid, 'columns'));
|
||
|
$gutters: su-valid-gutters(map-get($grid, 'gutters'));
|
||
|
$container: su-valid-spread(map-get($grid, 'container-spread')) + 1;
|
||
|
|
||
|
@if ($container == 0) {
|
||
|
@return null;
|
||
|
}
|
||
|
|
||
|
$gutter: su-call('su-gutter', $grid);
|
||
|
|
||
|
@if (type-of($gutter) == 'string') {
|
||
|
@return 'calc(#{$container} * #{$gutter} / 2)';
|
||
|
}
|
||
|
|
||
|
@return $container * $gutter / 2;
|
||
|
}
|