Deprecated: Grav\Common\Grav::setup(): Implicitly marking parameter $environment as nullable is deprecated, the explicit nullable type must be used instead in /home/julienmaik/docs/system/src/Grav/Common/Grav.php on line 189

Deprecated: Grav\Common\Grav::header(): Implicitly marking parameter $response as nullable is deprecated, the explicit nullable type must be used instead in /home/julienmaik/docs/system/src/Grav/Common/Grav.php on line 484

Deprecated: Grav\Common\Grav::fireEvent(): Implicitly marking parameter $event as nullable is deprecated, the explicit nullable type must be used instead in /home/julienmaik/docs/system/src/Grav/Common/Grav.php on line 547

Deprecated: Return type of Pimple\Container::offsetExists($id) should either be compatible with ArrayAccess::offsetExists(mixed $offset): bool, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /home/julienmaik/docs/vendor/pimple/pimple/src/Pimple/Container.php on line 133

Deprecated: Return type of Pimple\Container::offsetGet($id) should either be compatible with ArrayAccess::offsetGet(mixed $offset): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /home/julienmaik/docs/vendor/pimple/pimple/src/Pimple/Container.php on line 98

Deprecated: Return type of Pimple\Container::offsetSet($id, $value) should either be compatible with ArrayAccess::offsetSet(mixed $offset, mixed $value): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /home/julienmaik/docs/vendor/pimple/pimple/src/Pimple/Container.php on line 79

Deprecated: Return type of Pimple\Container::offsetUnset($id) should either be compatible with ArrayAccess::offsetUnset(mixed $offset): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /home/julienmaik/docs/vendor/pimple/pimple/src/Pimple/Container.php on line 143

Deprecated: Grav\Common\Debugger::profile(): Implicitly marking parameter $message as nullable is deprecated, the explicit nullable type must be used instead in /home/julienmaik/docs/system/src/Grav/Common/Debugger.php on line 543

Deprecated: Grav\Common\Debugger::stopProfiling(): Implicitly marking parameter $message as nullable is deprecated, the explicit nullable type must be used instead in /home/julienmaik/docs/system/src/Grav/Common/Debugger.php on line 584

Deprecated: Grav\Common\Debugger::addEvent(): Implicitly marking parameter $time as nullable is deprecated, the explicit nullable type must be used instead in /home/julienmaik/docs/system/src/Grav/Common/Debugger.php on line 775
Quantity Query | Julien Maxant - Docs

Quantity Query

Le principe de cette mixin est de permettre d'appliquer un style à des éléments en fonction de leur nombre.

Par exemple :

.class {
    @include quantity-query(4, 'greater') {
      background: red;   
    }
}

ajoutera un background rouge aux éléments .class dés qu'ils y en aura plus de 4.


@mixin quantity-query( $number, $comparison: 'equal' ) {
  $nth: '';
  @if index(('greater' 'more' '>'), $comparison) {
    $nth: 'n + #{$number}';
  } @else if index(('less' 'fewer' '<'), $comparison) {
    $nth: '-n + #{$number}';
  } @else if index(('equal' 'same' '='), $comparison) {
    $nth: $number;
  } @else {
    @warn "Sorry, that’s an invalid $comparison value."
  }

  &:nth-last-child(#{$nth}):first-child {
    &,
    & ~ * {
      @content;
    }
  }
}