cozy-bar 0.0.0-development

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (103) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +174 -0
  3. package/dist/cozy-bar.min.js +77 -0
  4. package/dist/cozy-bar.min.js.map +1 -0
  5. package/package.json +165 -0
  6. package/src/assets/icons/16/icon-storage-16.svg +3 -0
  7. package/src/assets/icons/24/icon-arrow-left.svg +3 -0
  8. package/src/assets/icons/32/icon-claudy.svg +1 -0
  9. package/src/assets/icons/apps/icon-collect.svg +25 -0
  10. package/src/assets/icons/apps/icon-drive.svg +17 -0
  11. package/src/assets/icons/apps/icon-market-soon.svg +25 -0
  12. package/src/assets/icons/apps/icon-photos.svg +19 -0
  13. package/src/assets/icons/apps/icon-soon.svg +21 -0
  14. package/src/assets/icons/apps/icon-store.svg +19 -0
  15. package/src/assets/icons/claudyActions/icon-bills.svg +6 -0
  16. package/src/assets/icons/claudyActions/icon-laptop.svg +7 -0
  17. package/src/assets/icons/claudyActions/icon-phone.svg +8 -0
  18. package/src/assets/icons/claudyActions/icon-question-mark.svg +6 -0
  19. package/src/assets/icons/comingsoon/icon-bank.svg +12 -0
  20. package/src/assets/icons/comingsoon/icon-sante.svg +12 -0
  21. package/src/assets/icons/comingsoon/icon-store.svg +6 -0
  22. package/src/assets/icons/icon-cozy.svg +3 -0
  23. package/src/assets/icons/icon-shield.svg +3 -0
  24. package/src/assets/icons/spinner.svg +4 -0
  25. package/src/assets/sprites/icon-apps.svg +1 -0
  26. package/src/assets/sprites/icon-cozy-home.svg +16 -0
  27. package/src/components/Apps/AppItem.jsx +117 -0
  28. package/src/components/Apps/AppItemPlaceholder.jsx +12 -0
  29. package/src/components/Apps/AppNavButtons.jsx +94 -0
  30. package/src/components/Apps/AppsContent.jsx +91 -0
  31. package/src/components/Apps/ButtonCozyHome.jsx +30 -0
  32. package/src/components/Apps/ButtonCozyHome.spec.jsx +53 -0
  33. package/src/components/Apps/IconCozyHome.jsx +38 -0
  34. package/src/components/Apps/index.jsx +72 -0
  35. package/src/components/Banner.jsx +41 -0
  36. package/src/components/Bar.jsx +295 -0
  37. package/src/components/Bar.spec.jsx +133 -0
  38. package/src/components/Claudy.jsx +81 -0
  39. package/src/components/ClaudyIcon.jsx +18 -0
  40. package/src/components/Drawer.jsx +227 -0
  41. package/src/components/Drawer.spec.jsx +98 -0
  42. package/src/components/SearchBar.jsx +358 -0
  43. package/src/components/Settings/SettingsContent.jsx +163 -0
  44. package/src/components/Settings/StorageData.jsx +29 -0
  45. package/src/components/Settings/helper.js +8 -0
  46. package/src/components/Settings/index.jsx +220 -0
  47. package/src/components/StorageIcon.jsx +16 -0
  48. package/src/components/SupportModal.jsx +59 -0
  49. package/src/components/__snapshots__/Bar.spec.jsx.snap +302 -0
  50. package/src/config/claudyActions.json +20 -0
  51. package/src/config/persistWhitelist.json +4 -0
  52. package/src/dom.js +80 -0
  53. package/src/index.jsx +242 -0
  54. package/src/index.spec.jsx +34 -0
  55. package/src/lib/api/helpers.js +13 -0
  56. package/src/lib/api/index.jsx +145 -0
  57. package/src/lib/exceptions.js +89 -0
  58. package/src/lib/expiringMemoize.js +13 -0
  59. package/src/lib/icon.js +77 -0
  60. package/src/lib/intents.js +16 -0
  61. package/src/lib/logger.js +11 -0
  62. package/src/lib/middlewares/appsI18n.js +57 -0
  63. package/src/lib/realtime.js +43 -0
  64. package/src/lib/reducers/apps.js +175 -0
  65. package/src/lib/reducers/apps.spec.js +59 -0
  66. package/src/lib/reducers/content.js +50 -0
  67. package/src/lib/reducers/context.js +86 -0
  68. package/src/lib/reducers/index.js +73 -0
  69. package/src/lib/reducers/locale.js +22 -0
  70. package/src/lib/reducers/settings.js +111 -0
  71. package/src/lib/reducers/theme.js +48 -0
  72. package/src/lib/reducers/unserializable.js +26 -0
  73. package/src/lib/stack-client.js +401 -0
  74. package/src/lib/stack.js +79 -0
  75. package/src/lib/store/index.js +44 -0
  76. package/src/locales/de.json +57 -0
  77. package/src/locales/en.json +57 -0
  78. package/src/locales/es.json +57 -0
  79. package/src/locales/fr.json +57 -0
  80. package/src/locales/it.json +57 -0
  81. package/src/locales/ja.json +57 -0
  82. package/src/locales/nl_NL.json +57 -0
  83. package/src/locales/pl.json +57 -0
  84. package/src/locales/ru.json +57 -0
  85. package/src/locales/sq.json +57 -0
  86. package/src/locales/zh_CN.json +57 -0
  87. package/src/proptypes/index.js +10 -0
  88. package/src/queries/index.js +16 -0
  89. package/src/styles/apps.css +248 -0
  90. package/src/styles/banner.css +64 -0
  91. package/src/styles/bar.css +106 -0
  92. package/src/styles/base.css +21 -0
  93. package/src/styles/claudy.css +98 -0
  94. package/src/styles/drawer.css +126 -0
  95. package/src/styles/index.styl +33 -0
  96. package/src/styles/indicators.css +58 -0
  97. package/src/styles/nav.css +81 -0
  98. package/src/styles/navigation_item.css +34 -0
  99. package/src/styles/searchbar.css +156 -0
  100. package/src/styles/settings.css +34 -0
  101. package/src/styles/storage.css +22 -0
  102. package/src/styles/supportModal.css +20 -0
  103. package/src/styles/theme.styl +25 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2017 Cozy.io
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,174 @@
1
+ [![Travis build status shield](https://img.shields.io/travis/cozy/cozy-bar/master.svg)](https://travis-ci.org/cozy/cozy-bar)
2
+ [![NPM release version shield](https://img.shields.io/npm/v/cozy-bar.svg)](https://www.npmjs.com/package/cozy-bar)
3
+ [![NPM Licence shield](https://img.shields.io/npm/l/cozy-bar.svg)](https://github.com/cozy/cozy-bar/blob/master/LICENSE)
4
+
5
+
6
+ # [Cozy] Bar Library
7
+
8
+ ## What's Cozy?
9
+
10
+ ![Cozy Logo](https://cdn.rawgit.com/cozy/cozy-guidelines/master/templates/cozy_logo_small.svg)
11
+
12
+ [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.
13
+
14
+
15
+ ## What's cozy-bar.js?
16
+
17
+ `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.
18
+
19
+
20
+ ## Use
21
+
22
+ `cozy-bar.js` is an asset directly served by the [cozy-stack](https://github.com/cozy/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.
23
+
24
+ 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.
25
+
26
+
27
+ Once you have the library included in your application, starts by intialize it in your app bootstrap:
28
+
29
+ ```js
30
+ window.cozy.bar.init({
31
+ appName: MY_APP_NAME,
32
+ appNamePrefix: MY_APP_NAME_PREFIX
33
+ iconPath: PATH_TO_SVG_ICON,
34
+ lang: LOCALE
35
+ })
36
+ ```
37
+
38
+ `appName` param in hash is mandatory when `appNamePrefix`, `lang` and `iconPath` are optionals. If not passed, their values are detected into the DOM:
39
+
40
+ - `appNamePrefix` is extracted from the manifest. Originally used for apps maintained by Cozy Cloud teams.
41
+ - `lang` is extracted from the `lang` attribute of the `<html>` tag. Defaults to 'en'
42
+ - `iconPath` uses the favicon 32px. Defaults to a blank GIF
43
+
44
+ ## Help link
45
+
46
+ Help link is defined in your Cozy's [configuration file](https://github.com/cozy/cozy-stack/blob/master/docs/config.md#main-configuration-file), in the `context` section. See the `cozy.example.yaml` file [provided by the stack](https://github.com/cozy/cozy-stack/blob/master/cozy.example.yaml#L80).
47
+
48
+ ## Coming Soon application
49
+
50
+ Coming Soon applications (or apps) are defined in your Cozy's [configuration file](https://github.com/cozy/cozy-stack/blob/master/docs/config.md#main-configuration-file). See the `cozy.example.yaml` file [provided by the stack](https://github.com/cozy/cozy-stack/blob/master/cozy.example.yaml#L80).
51
+
52
+ ## Claudy actions list
53
+
54
+ Claudy actions are declared in `src/config/claudy.yaml` with a slug as property name and some options (icon name and link options for example). The slugs list that will be used for Claudy is defined in your Cozy's [configuration file](https://github.com/cozy/cozy-stack/blob/master/docs/config.md#main-configuration-file). See the `cozy.example.yaml` file [provided by the stack](https://github.com/cozy/cozy-stack/blob/master/cozy.example.yaml#L101).
55
+ If no `claudy_actions` property is defined in the configuration, Claudy won't be displayed.
56
+
57
+ ## Customizing the content of the bar
58
+
59
+ 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.
60
+
61
+ The bar is divided in 3 areas that you can control individually : left, center and right:
62
+
63
+ ![cozy-bar-triplet](https://user-images.githubusercontent.com/2261445/33609298-de4d379e-d9c7-11e7-839d-f5ab6155c902.png)
64
+
65
+ To do this, you need to call one of the 3 exposed functions like this:
66
+
67
+ ```jsx
68
+ const setBarLeft = cozy.bar.setBarLeft
69
+ setBarLeft('<div>Hello!</div>')
70
+ // there's also cozy.bar.setBarCenter and cozy.bar.setBarRight
71
+ ```
72
+
73
+ If you're using React, you can use the component form instead:
74
+
75
+ ```jsx
76
+ const { BarLeft, BarCenter, BarRight } = cozy.bar
77
+
78
+ // then, somewhere in a render function
79
+ <BarLeft>
80
+ <div>Hello!</div>
81
+ </BarLeft>
82
+ ```
83
+
84
+ ### Using a context in the bar
85
+
86
+ If you're using Redux or React Context and include a connected component or a Provider in the bar, it might not work as expected since inside `<BarLeft>` and friends, the redux store and context are different.
87
+
88
+ ```jsx
89
+ const MyConnectedComponent = connect(mapStateToProps, mapDispatchToProps, MyComponent)
90
+
91
+ // … in a render function
92
+ <BarLeft>
93
+ <MyConnectedComponent /> // … you won't get the expected props from redux
94
+ </BarLeft>
95
+ ```
96
+
97
+ Instead, you can do something like this (for Context you can pass the values as prop):
98
+
99
+ ```jsx
100
+ const MyWrappedComponent = (props) => (
101
+ <BarLeft>
102
+ <MyComponent {...props} />
103
+ </BarLeft>
104
+ )
105
+
106
+ const MyConnectedComponent = connect(mapStateToProps, mapDispatchToProps, MyWrappedComponent)
107
+
108
+ // …in a render function
109
+ <MyConnectedComponent />
110
+ ```
111
+
112
+ ## Change theme bar
113
+
114
+ It's possible to update theme on the cozy-bar with `setTheme` function.
115
+
116
+ ```jsx
117
+ const { setTheme } = cozy.bar
118
+
119
+ setTheme('default')
120
+ setTheme('primary')
121
+ ```
122
+
123
+ ## Debugging
124
+
125
+ It is possible to activate the logger from the bar by activating the flag 'bar.debug'.
126
+ Then you have to reload the page.
127
+
128
+ ```
129
+ flag(bar.debug, true)
130
+ ```
131
+
132
+ ## Contribute
133
+
134
+ If you want to work on cozy-client-js itself and submit code modifications, feel free to open pull-requests! See the [contributing guide][contribute] for more information about this repository structure, testing, linting and how to properly open pull-requests.
135
+
136
+
137
+ ## Community
138
+
139
+ ### Maintainer
140
+
141
+ The lead maintainer for cozy-bar.js is [@CPatchane](https://github.com/CPatchane), send him/her a :beers: to say hello!
142
+
143
+
144
+ ### Get in touch
145
+
146
+ You can reach the Cozy Community by:
147
+
148
+ - Chatting with us on IRC [#cozycloud on Libera.Chat][libera]
149
+ - Posting on our [Forum][forum]
150
+ - Posting issues on the [Github repos][github]
151
+ - Say Hi! on [Twitter][twitter]
152
+
153
+
154
+ ## Licence
155
+
156
+ cozy-bar.js is developed by Cozy Cloud and distributed under the [MIT].
157
+
158
+
159
+
160
+ [cozy]: https://cozy.io "Cozy Cloud"
161
+ [setup]: https://dev.cozy.io/#set-up-the-development-environment "Cozy dev docs: Set up the Development Environment"
162
+ [doctypes]: https://dev.cozy.io/#main-document-types
163
+ [bill-doctype]: https://github.com/cozy-labs/konnectors/blob/master/server/models/bill.coffee
164
+ [konnector-doctype]: https://github.com/cozy-labs/konnectors/blob/master/server/models/konnector.coffee
165
+ [konnectors]: https://github.com/cozy-labs/konnectors
166
+ [MIT]: https://opensource.org/licenses/MIT
167
+ [contribute]: CONTRIBUTING.md
168
+ [libera]: https://web.libera.chat/#cozycloud
169
+ [forum]: https://forum.cozy.io/
170
+ [github]: https://github.com/cozy/
171
+ [twitter]: https://twitter.com/cozycloud
172
+ [mocha]: https://mochajs.org/
173
+ [should]: npmjs.com/package/should
174
+ [checkbox]: https://help.github.com/articles/basic-writing-and-formatting-syntax/#task-lists