To migrate cozy-bar from v8 (or v9, v10, which is the same as v8) to v11, follow these steps:
-
Update the cozy-bar in your project by running the following command:
yarn add [email protected]
-
You need to add the cozy-bar CSS
import 'cozy-bar/dist/stylesheet.css'
into your index or an other file -
You can remove the bar initialization. Generally you can search for
cozy.bar.init({
-
Add the
BarComponent
into your layout like the following code:import { BarComponent } from 'cozy-bar' const App = () => { return ( <Layout> <BarComponent /> </Layout> ) }
-
If you were using customs elements, you need to wrap the
BarComponent
and your elements into aBarProvider
. Generally you can add this into providers file:<BarProvider> <OtherProvider> {children} </OtherProvider> </BarProvider>
-
Then, replace
{ BarLeft } = cozy.bar
with a direct import:import { BarLeft } from 'cozy-bar' const Title = ({ title }) => { const { isMobile } = useBreakpoints() if(isMobile) { return ( <BarLeft>{title}</BarLeft> ) } return ( <h2>{title}</h2> ) }
-
You no longer need to include the providers inside your custom bar element. Now, you can access all the providers that wrap the
BarComponent
directly within your custom element.