cozy-bar v7.32.0
Cozy Bar Library
What's Cozy?
Cozy is a platform that brings all your web services in the same private space. With it, your webapps and your devices can share data easily, providing you with a new experience. You can install Cozy on your own hardware where no one's tracking you.
What's cozy-bar.js?
cozy-bar.js is a javascript library made by Cozy. It enables the CozyBar component in your application. This component is a banner on the top of your application, responsible of cross-apps navigation, user facilities, intents, etc.
Use
cozy-bar.js is an asset directly served by the cozy-stack. To use it, simply add <script src="/js/cozy-bar.js" defer></script> in the <head> section of the index.html of your application. It exposes an API behind the window.cozy.bar namespace, that let you interact with the CozyBar itself.
The library requires your markup to contain an element with role=application and attributes data-cozy-domain and data-cozy-token. The DOM of the banner will be added before this element.
Once you have the library included in your application, starts by intialize it in your app bootstrap:
window.cozy.bar.init({
appName: MY_APP_NAME,
appNamePrefix: MY_APP_NAME_PREFIX
iconPath: PATH_TO_SVG_ICON,
lang: LOCALE
})appName param in hash is mandatory when appNamePrefix, lang and iconPath are optionals. If not passed, their values are detected into the DOM:
appNamePrefixis extracted from the manifest. Originally used for apps maintained by Cozy Cloud teams.langis extracted from thelangattribute of the<html>tag. Defaults to 'en'iconPathuses the favicon 32px. Defaults to a blank GIF
To make the icon of Cozy(icon-cozy-home.svg) compatible with an inverted theme, please set the parameter isInvertedTheme to true
Help link
Help link is defined in your Cozy's configuration file, in the context section. See the cozy.example.yaml file provided by the stack.
Coming Soon application
Coming Soon applications (or apps) are defined in your Cozy's configuration file. See the cozy.example.yaml file provided by the stack.
Customizing the content of the bar
From within your app, you can decide to take over certain areas of the cozy-bar. This might especially be useful on mobile where the area it occupies is prime real estate — we generally don't recommend to use this option on larger screen resolutions.
The bar is divided in 3 areas that you can control individually : left, center and right:

To do this, you need to call one of the 3 exposed functions like this:
const setBarLeft = cozy.bar.setBarLeft
setBarLeft('<div>Hello!</div>')
// there's also cozy.bar.setBarCenter and cozy.bar.setBarRightIf you're using React, you can use the component form instead:
const { BarLeft, BarCenter, BarRight } = cozy.bar
// then, somewhere in a render function
<BarLeft>
<div>Hello!</div>
</BarLeft>If you're using Redux and include a connected component in the bar, it might not work as expected since inside <BarLeft> and friends, the redux store is different.
const MyConnectedComponent = connect(mapStateToProps, mapDispatchToProps, MyComponent)
// … in a render function
<BarLeft>
<MyConnectedComponent /> // … you won't get the expected props from redux
</BarLeft>Instead, you can do something like this:
const MyWrappedComponent = (props) => (
<BarLeft>
<MyComponent {...props} />
</BarLeft>
)
const MyConnectedComponent = connect(mapStateToProps, mapDispatchToProps, MyWrappedComponent)
// …in a render function
<MyConnectedComponent />Change theme bar
It's possible to update theme on the cozy-bar with setTheme function.
const { setTheme } = cozy.bar
setTheme('default')
setTheme('primary')Development mode
In order to add new features to the cozy-bar v7 while working on another cozy-app:
Please ensure your app has the latest v7-stable
cozy-barversionPlease ensure your app has at least the 6.3.4
cozy-scriptsversionThen, follow these steps:
$ yarn link // in cozy-bar
$ rlink cozy-bar // in the cozy-app
$ yarn start // in cozy-bar
$ yarn start // in the cozy-app
How does it work?
When an app (like Drive) is building, the cozy-bar assets are defined dynamically if STACK_ASSETS = true inside the browser file
In dev mode on webpack, STACK_ASSETS = false
In that case, the cozy-bar is injected
Contribute
If you want to work on cozy-client-js itself and submit code modifications, feel free to open pull-requests! See the contributing guide for more information about this repository structure, testing, linting and how to properly open pull-requests.
Community
Maintainer
The lead maintainer for cozy-bar.js is @CPatchane, send him/her a :beers: to say hello!
Localization
Localization and translations are handled by Transifex, which is used by all Cozy's apps.
As a translator, you can login to Transifex (using your Github account) and claim an access to the app repository. Locales are pulled when app is build before publishing.
As a developer, you just have to modify json in /src/locales. New locales will be automatically added to Transifex. If you need to pull or push manually locales, you can use Transifex CLI. If you were using a transifex-client, you must move to Transifex CLI to be compatible with the v3 API.
Get in touch
You can reach the Cozy Community by:
- Chatting with us on IRC #cozycloud on Freenode
- Posting on our Forum
- Posting issues on the Github repos
- Say Hi! on Twitter
Licence
cozy-bar.js is developed by Cozy Cloud and distributed under the MIT.
11 months ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
7 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
8 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago