|
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441 |
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- @function su-span(
- $span,
- $columns,
- $gutters,
- $spread,
- $container-spread: $spread,
- $location: 1
- ) {
- $span: su-valid-span($span);
- $columns: su-valid-columns($columns);
- $gutters: su-valid-gutters($gutters);
- $spread: su-valid-spread($spread);
-
- @if (type-of($span) == 'number') {
- @if (not unitless($span)) {
- @return $span;
- }
-
- $location: su-valid-location($span, $location, $columns);
- $span: su-slice($span, $columns, $location, $validate: false);
- }
-
- @if _su-needs-calc-output($span, $columns, $gutters, $spread, not 'validate') {
- @return _su-calc-span($span, $columns, $gutters, $spread, $container-spread, not 'validate');
- }
-
- $span-width: _su-sum($span, $gutters, $spread, $validate: false);
-
- @if unitless($span-width) {
- $container-spread: su-valid-spread($container-spread);
- $container: _su-sum($columns, $gutters, $container-spread, $validate: false);
- @return percentage($span-width / $container);
- }
-
- @return $span-width;
- }
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- @function su-gutter(
- $columns,
- $gutters,
- $container-spread
- ) {
- @if (type-of($gutters) == 'number') {
- @if ($gutters == 0) or (not unitless($gutters)) {
- @return $gutters;
- }
- }
-
- @if _su-needs-calc-output($gutters, $columns, $gutters, -1, not 'validate') {
- @return _su-calc-span($gutters, $columns, $gutters, -1, $container-spread, not 'validate');
- }
-
- $container: _su-sum($columns, $gutters, $container-spread);
- @return percentage($gutters / $container);
- }
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- @function su-slice(
- $span,
- $columns,
- $location: 1,
- $validate: true
- ) {
- @if $validate {
- $columns: su-valid-columns($columns);
- $location: su-valid-location($span, $location, $columns);
- }
-
- $floor: floor($span);
- $sub-columns: ();
-
- @for $i from $location to ($location + $floor) {
- $sub-columns: append($sub-columns, nth($columns, $i));
- }
-
- @if $floor != $span {
- $remainder: $span - $floor;
- $column: $location + $floor;
- $sub-columns: append($sub-columns, nth($columns, $column) * $remainder);
- }
-
- @return $sub-columns;
- }
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- @function _su-sum(
- $columns,
- $gutters,
- $spread,
- $validate: true
- ) {
- @if $validate {
- $columns: su-valid-span($columns);
- $gutters: su-valid-gutters($gutters);
- $spread: su-valid-spread($spread);
- }
-
-
- $column-sum: 0;
- @each $column in $columns {
- $column-sum: $column-sum + $column;
- }
-
- $gutter-sum: (ceil(length($columns)) + $spread) * $gutters;
- $total: if(($gutter-sum > 0), $column-sum + $gutter-sum, $column-sum);
-
- @return $total;
- }
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- @function _su-calc-span(
- $span,
- $columns,
- $gutters,
- $spread,
- $container-spread: $spread,
- $validate: true
- ) {
- @if $validate {
- $span: su-valid-span($span);
- $columns: su-valid-columns($columns);
- $gutters: su-valid-gutters($gutters);
- $spread: su-valid-spread($spread);
- $container-spread: su-valid-spread($container-spread);
- }
-
-
- $span: _su-calc-sum($span, $gutters, $spread, not 'validate');
- $context: _su-calc-sum($columns, $gutters, $container-spread, not 'validate');
-
-
- $fixed-span: map-get($span, 'fixed');
- $fluid-span: map-get($span, 'fluid');
- $fixed-context: map-get($context, 'fixed');
- $fluid-context: map-get($context, 'fluid');
-
- $calc: '#{$fixed-span}';
- $fluid-calc: '(100% - #{$fixed-context})';
-
-
- @if (not $fluid-span) {
- $fluid-calc: null;
- } @else if ($fluid-span != $fluid-context) {
- $fluid-span: '* #{$fluid-span}';
- $fluid-context: if($fluid-context, '/ #{$fluid-context}', '');
- $fluid-calc: '(#{$fluid-calc $fluid-context $fluid-span})';
- }
-
- @if $fluid-calc {
- $calc: if(($calc != ''), '#{$calc} + ', '');
- $calc: '#{$calc + $fluid-calc}';
- }
-
- @return calc(#{unquote($calc)});
- }
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- @function _su-calc-sum(
- $columns,
- $gutters,
- $spread,
- $validate: true
- ) {
- @if $validate {
- $columns: su-valid-span($columns);
- $gutters: su-valid-gutters($gutters);
- $spread: su-valid-spread($spread);
- }
-
- $fluid: 0;
- $fixed: ();
- $calc: null;
-
-
- $gutters: $gutters * (length($columns) + $spread);
-
-
- @each $col in append($columns, $gutters) {
- @if unitless($col) {
- $fluid: $fluid + $col;
- } @else {
- $fixed: _su-map-add-units($fixed, $col);
- }
- }
-
-
- @each $unit, $total in $fixed {
- @if ($total != (0 * $total)) {
- $calc: if($calc, '#{$calc} + #{$total}', '#{$total}');
- }
- }
-
-
- @if $calc {
- $calc: if(str-index($calc, '+'), '(#{$calc})', '#{$calc}');
- }
-
-
- $fluid: if(($fluid == 0), null, $fluid);
-
-
-
- $return: (
- 'fixed': $calc,
- 'fluid': $fluid,
- );
-
- @return $return;
- }
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- @function _su-needs-calc-output(
- $span,
- $columns,
- $gutters,
- $spread,
- $validate: true
- ) {
- @if $validate {
- $span: su-valid-span($span);
- $columns: su-valid-columns($columns);
- $gutters: su-valid-gutters($gutters);
- }
-
- $has-gutter: if((length($span) > 1) or ($spread >= 0), true, false);
- $check: if($has-gutter, append($span, $gutters), $span);
- $safe-span: _su-is-comparable($check...);
-
- @if ($safe-span == 'static') {
- @return false;
- } @else if (not $safe-span) {
- @return true;
- }
-
- $safe-fluid: _su-is-comparable($gutters, $columns...);
-
- @return not $safe-fluid;
- }
|