Skip to content

Commit 0cee330

Browse files
authored
Merge pull request jorenvanhee#2 from venyii/ignore-screens
Add ability to ignore specific screens
2 parents 7768ef2 + 150a99f commit 0cee330

File tree

2 files changed

+30
-9
lines changed

2 files changed

+30
-9
lines changed

README.md

+20-2
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,27 @@ Make sure the class is only present during development. Here's an example of how
4242
<body class="{{ devMode ? 'debug-screens' : '' }}">
4343
```
4444

45-
### Custimization
45+
### Customization
4646

47-
You can customize the position and styles in the `theme.debugScreens` section of your `tailwind.config.js` file.
47+
You can customize this plugin in the `theme.debugScreens` section of your `tailwind.config.js` file.
48+
49+
#### Ignore screens
50+
51+
To ignore a specific screen (for instance if you use [dark mode](https://tailwindcss.com/docs/breakpoints/#dark-mode)), add the screen name to the `ignore` configuration array.
52+
53+
```js
54+
// tailwind.config.js
55+
module.exports = {
56+
theme: {
57+
debugScreens: {
58+
ignore: ['dark'],
59+
},
60+
},
61+
plugins: [
62+
require('tailwindcss-debug-screens'),
63+
],
64+
}
65+
```
4866

4967
#### Position
5068

index.js

+10-7
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
module.exports = function ({ addComponents, theme }) {
22
const screens = theme('screens');
33
const userStyles = theme('debugScreens.style', {});
4+
const ignoredScreens = theme('debugScreens.ignore', [])
45

56
const defaultPosition = ['bottom', 'left'];
67
const position = theme('debugScreens.position', defaultPosition);
@@ -24,13 +25,15 @@ module.exports = function ({ addComponents, theme }) {
2425
}, userStyles),
2526
};
2627

27-
Object.entries(screens).forEach(([screen]) => {
28-
components[`@screen ${screen}`] = {
29-
'.debug-screens::before': {
30-
content: `'screen: ${screen}'`,
31-
},
32-
};
33-
});
28+
Object.entries(screens)
29+
.filter(([screen]) => !ignoredScreens.includes(screen))
30+
.forEach(([screen]) => {
31+
components[`@screen ${screen}`] = {
32+
'.debug-screens::before': {
33+
content: `'screen: ${screen}'`,
34+
},
35+
};
36+
});
3437

3538
addComponents(components);
3639
}

0 commit comments

Comments
 (0)