Skip to content

Commit

Permalink
Add debug mode
Browse files Browse the repository at this point in the history
  • Loading branch information
meduzen committed Nov 15, 2020
1 parent f324649 commit 90d9c8f
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 2 deletions.
12 changes: 11 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ Double Dash is a SCSS library helping to declare [custom media queries](docs/cus
- [Introduction](#introduction)
- [Available mixins](#available-mixins)
- [Partial import](#partial-import)
- [Debug](#debug)

## Installation

Expand Down Expand Up @@ -177,7 +178,7 @@ Available files: `color`, `js`, `light`, `motion`, `pointer`, `ratio`, `refresh`

### Import mixins for ranged media queries

First, import the generic `--media` mixins: the other mixins use it:
First, import the generic `--media` mixins (the other mixins use it):

```scss
@import '~double-dash.scss/src/mixins/base';
Expand All @@ -190,3 +191,12 @@ Then, pulls the mixins for viewport sizes custom media queries:
```

Available files: `ratio`, `resolution`, `sizes`.

## Debug

You can output each custom media query generated with Double Dash in your CLI by setting the `$dash-dash-debug` variable before importing Double Dash.

```scss
$dash-dash-debug: true;
@import '~double-dash.scss';
```
7 changes: 6 additions & 1 deletion src/mixins/_base.scss
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
@import 'debug';

/*
* MEDIA MIXIN
*
Expand Down Expand Up @@ -27,7 +29,10 @@
}

@custom-media --#{$name} #{$features};
// @debug --#{$name} unquote('#{$features}'); // Uncomment for console debug.

@if $dash-dash-should-debug {
@debug unquote('@custom-media ') --#{$name} unquote('#{$features}');
}
}

/* --media() ALIAS */
Expand Down
5 changes: 5 additions & 0 deletions src/mixins/_debug.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
$dash-dash-should-debug: false;

@if variable-exists('dash-dash-debug') == true and $dash-dash-debug == true {
$dash-dash-should-debug: true;
}

0 comments on commit 90d9c8f

Please sign in to comment.