Skip to content

Commit

Permalink
feat: support darkMode: 'media'
Browse files Browse the repository at this point in the history
  • Loading branch information
nolimits4web committed Sep 2, 2021
1 parent 975f062 commit d0d960e
Showing 1 changed file with 19 additions and 5 deletions.
24 changes: 19 additions & 5 deletions src/config/plugin-base.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,30 @@
const plugin = require('tailwindcss/plugin');

module.exports = () =>
plugin(({ addBase }) => {
plugin(({ addBase, config }) => {
const darkMode = config('darkMode');
const darkProps =
darkMode === 'class'
? {
'.dark': {
'--twm-hairline-color': 'rgba(255, 255, 255, 0.15)',
color: '#fff',
},
}
: {
'@media (prefers-color-scheme: dark)': {
':root': {
'--twm-hairline-color': 'rgba(255, 255, 255, 0.15)',
color: '#fff',
},
},
};
addBase({
':root': {
'--twm-device-pixel-ratio': '1',
'--twm-hairline-color': 'rgba(0, 0, 0, 0.2)',
},
'.dark': {
'--twm-hairline-color': 'rgba(255, 255, 255, 0.15)',
color: '#fff',
},
...darkProps,
'@media (min-resolution: 2dppx)': {
':root': {
'--twm-device-pixel-ratio': '2',
Expand Down

0 comments on commit d0d960e

Please sign in to comment.