@x4b/banner 28.4.0
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.
- package/README.MD +76 -0
- package/dist/banner.es.js +6380 -0
- package/dist/banner.es.js.map +1 -0
- package/dist/banner.umd.js +122 -0
- package/dist/banner.umd.js.map +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/library/components/AppSelector.d.ts +6 -0
- package/dist/library/components/AppTitle.d.ts +5 -0
- package/dist/library/components/Banner.d.ts +3 -0
- package/dist/library/components/BannerContent.d.ts +20 -0
- package/dist/library/components/HelpMenu.d.ts +6 -0
- package/dist/library/components/LanguageSelector.d.ts +8 -0
- package/dist/library/components/MenuContent.d.ts +6 -0
- package/dist/library/components/NotificationButton.d.ts +5 -0
- package/dist/library/components/UserProfileMenu.d.ts +7 -0
- package/dist/library/constants.d.ts +1 -0
- package/dist/library/index.d.ts +14 -0
- package/dist/library/locales/localeConfiguration.d.ts +36 -0
- package/dist/library/providers/AuthProvider.d.ts +19 -0
- package/dist/library/utils/applications.d.ts +12 -0
- package/dist/library/utils/auth.d.ts +9 -0
- package/dist/library/utils/language.d.ts +4 -0
- package/dist/library/utils/mail.d.ts +7 -0
- package/dist/library/utils/toggleMenu.d.ts +3 -0
- package/dist/library/utils/token.d.ts +11 -0
- package/dist/mockServiceWorker.js +302 -0
- package/dist/vite-env.d.ts +9 -0
- package/package.json +49 -0
- package/styles.css +1 -0
package/README.MD
ADDED
@@ -0,0 +1,76 @@
|
|
1
|
+
# X4B Banner
|
2
|
+
|
3
|
+
This project provides a React component for the banner
|
4
|
+
|
5
|
+
It also includes a Provider and a hook to manage your App authentication.
|
6
|
+
|
7
|
+
## Install
|
8
|
+
|
9
|
+
The library requires React>=16.8
|
10
|
+
|
11
|
+
- Install the peer dependencies
|
12
|
+
|
13
|
+
```sh
|
14
|
+
npm install @x4b/design-system
|
15
|
+
# or
|
16
|
+
yarn add @x4b/design-system
|
17
|
+
```
|
18
|
+
|
19
|
+
- Install the banner package
|
20
|
+
|
21
|
+
```sh
|
22
|
+
npm install @x4b/banner
|
23
|
+
# or
|
24
|
+
yarn add @x4b/banner
|
25
|
+
```
|
26
|
+
|
27
|
+
- Install the fonts
|
28
|
+
|
29
|
+
By default, the banner uses the open sans font.
|
30
|
+
In the head of the HTML file, add the following code:
|
31
|
+
|
32
|
+
```html
|
33
|
+
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Open+Sans:wght@300;400;500;600&display=swap" />
|
34
|
+
```
|
35
|
+
|
36
|
+
## Example
|
37
|
+
|
38
|
+
Wrap the Banner component inside an AuthProvider to use the X4B authentication.
|
39
|
+
Here's a code example:
|
40
|
+
|
41
|
+
```javascript
|
42
|
+
function App() {
|
43
|
+
return (
|
44
|
+
<>
|
45
|
+
<AuthProvider appsServiceUrl="https://x4b.dev.xcomponent.com/apps">
|
46
|
+
<AppContent />
|
47
|
+
</AuthProvider>
|
48
|
+
<GlobalStyle />
|
49
|
+
</>
|
50
|
+
);
|
51
|
+
}
|
52
|
+
|
53
|
+
function AppContent() {
|
54
|
+
const [lang, setLang] = React.useState(() => getDefaultLanguage());
|
55
|
+
const { getBannerProps, authResult } = useAuth();
|
56
|
+
|
57
|
+
React.useEffect(() => {
|
58
|
+
console.debug('token', authResult?.token);
|
59
|
+
}, [authResult]);
|
60
|
+
|
61
|
+
return (
|
62
|
+
<Banner
|
63
|
+
{...getBannerProps({
|
64
|
+
application: 'scenario',
|
65
|
+
notificationCount: 2,
|
66
|
+
onNotificationClick: () => console.debug('notification button clicked'),
|
67
|
+
onToggleMenuClick: isMenuOpen => console.debug(`Menu open: ${isMenuOpen}`),
|
68
|
+
language: lang,
|
69
|
+
languages: ['en', 'fr'],
|
70
|
+
onLanguageChange: setLang,
|
71
|
+
version: 'dev-test',
|
72
|
+
})}
|
73
|
+
/>
|
74
|
+
);
|
75
|
+
}
|
76
|
+
```
|