Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This new component allows you to change the CozyTheme variant of the cozy-bar. The useContext is no longer exposed, as it can lead to infinite re-renders.
- Loading branch information
Showing
10 changed files
with
57 additions
and
211 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import { useEffect } from 'react' | ||
|
||
import { useBarContext } from './BarProvider' | ||
|
||
function BarTheme({ variant }) { | ||
const barContext = useBarContext() | ||
|
||
useEffect(() => { | ||
if (barContext && barContext.setTheme !== undefined) { | ||
barContext.setThemeVariant(variant) | ||
return () => { | ||
barContext.setThemeVariant('normal') | ||
} | ||
} else { | ||
console.warn('You should not use BarTheme outside of a BarProvider') | ||
} | ||
}, [barContext, variant]) | ||
|
||
return null | ||
} | ||
|
||
export { BarTheme } |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.