Skip to content

Instantly share code, notes, and snippets.

@RealTong
Created February 18, 2024 15:57
Show Gist options
  • Save RealTong/d1dad966e7d8d1ee86011e3272f32b72 to your computer and use it in GitHub Desktop.
Save RealTong/d1dad966e7d8d1ee86011e3272f32b72 to your computer and use it in GitHub Desktop.
TailwindCSS-screen-checkpoint plugin
module.exports = function ({ addComponents, theme }) {
const screens = theme('screens')
const ignoredScreens = theme('debugScreens.ignore', ['dark'])
const selector = theme('debugScreens.selector', '.debug')
const components = {
[`${selector}::before`]: Object.assign({
position: 'fixed',
zIndex: '50',
width: 6,
height: 6,
borderRadius: '50%',
bottom: '12px',
right: '12px',
padding: 12,
fontSize: '0.75rem',
lineHeight: '1rem',
backgroundColor: 'rgba(0, 0, 0, 0.75)',
color: '#fff',
display: 'flex',
alignItems: 'center',
justifyContent: 'center',
content: `'xs'`,
}),
}
Object.entries(screens)
.filter(([screen]) => !ignoredScreens.includes(screen))
.forEach(([screen]) => {
components[`@screen ${screen}`] = {
[`${selector}::before`]: {
content: `'${screen}'`,
},
}
})
addComponents(components)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment