Skip to content

Commit

Permalink
fix(dark theme): use tailwind default dark class to apply theme
Browse files Browse the repository at this point in the history
deprecates `theme-dark` and introduces the Tailwind default way with `dark` class. If you didn't
touch the theming for Windmill in the past, you should see no difference (eg.: changing the class
applied to `body`)
  • Loading branch information
estevanmaito committed May 15, 2021
1 parent 8095735 commit 4c42027
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion src/Windmill.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ const Windmill: React.FC<Props> = ({
if (setMode != null) {
setMode('dark')
}
document.documentElement.classList.add(`theme-dark`)
document.documentElement.classList.add(`dark`)
}
}, [dark])

Expand Down
12 changes: 6 additions & 6 deletions src/__tests__/Windmill.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ describe('Windmill Context', () => {
expect(wrapper.find('button').getDOMNode().getAttribute('class')).toContain(expected)
})

it('should add theme-light class to html element is usePreferences is present', () => {
const expected = 'theme-light'
it('should add light class to html element if usePreferences is present', () => {
const expected = 'light'
mount(
<Windmill usePreferences>
<Button />
Expand All @@ -66,7 +66,7 @@ describe('Windmill Context', () => {
})

it('should execute the toggleTheme method', () => {
const expected = 'theme-dark'
const expected = 'dark'
const wrapper = mount(
<Windmill usePreferences>
<TestButton />
Expand All @@ -91,7 +91,7 @@ describe('Windmill Context', () => {
}),
})

const expected = 'theme-dark'
const expected = 'dark'
mount(
<Windmill usePreferences>
<Button />
Expand All @@ -102,7 +102,7 @@ describe('Windmill Context', () => {
})

it('should add dark theme class to html element', () => {
const expected = 'theme-dark'
const expected = 'dark'
mount(
<Windmill dark>
<Button />
Expand All @@ -113,7 +113,7 @@ describe('Windmill Context', () => {
})

it('should add dark theme class to html element when usePreferences is enabled', () => {
const expected = 'theme-dark'
const expected = 'dark'
mount(
<Windmill dark usePreferences>
<Button />
Expand Down
6 changes: 3 additions & 3 deletions src/utils/useDarkMode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ export const useDarkMode = (
const toggleMode = () => {
if (mode === 'light') {
document.documentElement.className = ''
document.documentElement.classList.add('theme-dark')
document.documentElement.classList.add('dark')
setMode('dark')
} else {
document.documentElement.className = ''
document.documentElement.classList.add('theme-light')
document.documentElement.classList.add('light')
setMode('light')
}
}
Expand All @@ -32,7 +32,7 @@ export const useDarkMode = (
useEffect(() => {
if (mode) {
window.localStorage.setItem('theme', mode)
document.documentElement.classList.add(`theme-${mode}`)
document.documentElement.classList.add(mode)
}
}, [mode])

Expand Down

0 comments on commit 4c42027

Please sign in to comment.