@ukpc-lib/react 0.1.6 → 0.1.8

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 CHANGED
@@ -1,2 +1,109 @@
1
- # UKPC AUTH LIBRARY
2
- ![Screenshot 2024-01-22 at 11 40 08](https://github.com/UKParkingControl/LibShareJS/assets/153060345/99004010-67a2-436b-a5b7-317992137205)
1
+ # @ukpc-lib/react
2
+
3
+ @ukpc-lib is a comprehensive npm library designed to provide a suite of reusable components, themes, colors, hooks, and auth providers for UKPC applications. It aims to streamline development and ensure consistency across different projects.
4
+
5
+ ## Installation
6
+
7
+ ### React
8
+
9
+ To install package, use the following command:
10
+
11
+ ```bash
12
+ npm install @ukpc-lib/react
13
+ ```
14
+
15
+ ### .NET
16
+
17
+ With .NET applications, you can import the script and use it as follows:
18
+
19
+ Topbar:
20
+ https://unpkg.com/@ukpc-lib/react@latest/web-components-bundle/global-topbar/index.js
21
+
22
+ Global Menu:
23
+ https://unpkg.com/@ukpc-lib/react@latest/web-components-bundle/global-menu/index.js
24
+
25
+ ## Usage
26
+
27
+ **To ensure the correct display, you should use the layout as shown below:**
28
+
29
+ ### React
30
+
31
+ After installation, you can start using components by importing it into your project. Here's an example of how to use Global Menu:
32
+
33
+ ```js
34
+ import { GlobalMenu } from '@ukpc-lib/react/components';
35
+ import { useAuth } from '@ukpc-lib/react/share';
36
+ import { Outlet } from 'react-router-dom';
37
+ import TopBar from './TopBar';
38
+
39
+ export default function PrivateLayout() {
40
+ const { logout } = useAuth();
41
+
42
+ return (
43
+ <div style={{ display: 'flex', flexDirection: 'column', height: '100vh' }}>
44
+ <div style={{ height: '64px' }}>
45
+ <TopBar />
46
+ </div>
47
+ <div
48
+ style={{
49
+ display: 'flex',
50
+ flexDirection: 'row',
51
+ flex: 1,
52
+ overflow: 'hidden',
53
+ }}
54
+ >
55
+ <GlobalMenu
56
+ baseUrl="https://saas.dev-intelli-park.com"
57
+ menuPath="/global-menu-config/api/v1/menu-items/user"
58
+ logout={logout}
59
+ />
60
+ <div style={{ flex: 1, padding: '40px', overflow: 'auto' }}>
61
+ <Outlet />
62
+ </div>
63
+ </div>
64
+ </div>
65
+ );
66
+ }
67
+ ```
68
+
69
+ ### .NET
70
+
71
+ ```js
72
+ <div style="display: flex; flex-direction: column; height: 100vh;">
73
+ <div style="height: 64px;">
74
+ <global-topbar
75
+ base-url="@baseurl"
76
+ user="@userJson"
77
+ logo="logoURL"
78
+ ></global-topbar>
79
+ </div>
80
+ <div style="display: flex; flex-direction: row; flex: 1; overflow: hidden;">
81
+ <global-menu
82
+ menu-path="/global-menu-config/api/v1/menu-items/user"
83
+ base-url="@baseurl"
84
+ logout="logout"
85
+ ></global-menu>
86
+ <div style="flex: 1; padding: 40px; overflow: auto;">
87
+ <Outlet />
88
+ </div>
89
+ </div>
90
+ </div>
91
+ ```
92
+
93
+ ## API
94
+
95
+ #### Global menu:
96
+
97
+ - `baseUrl`: This is the root path where the global menu resources are located.
98
+ - `menuPath`: This is appended to the `baseUrl` to form the full URL to the menu resource.
99
+ - `logout()`: A method that logs out the current user. When called, it will clear the user's session and redirect them to the login page.
100
+
101
+ #### Topbar:
102
+
103
+ - `baseUrl`: This is the root path where the global topbar resources are located.
104
+ - `user`: A JSON string representing the current user.
105
+ - `logo`: The URL of the logo image to be displayed on the topbar.
106
+
107
+ ## Contributing
108
+
109
+ We always welcome community contributions. If you want to contribute, please create a Pull Request and we will review it.
@@ -1,7 +1,7 @@
1
1
  type GlobalMenuProps = {
2
2
  baseUrl: string;
3
3
  menuPath?: string;
4
- logout(): void;
4
+ logout?(): void;
5
5
  };
6
6
  export declare function GlobalMenu(props: GlobalMenuProps): import("react/jsx-runtime").JSX.Element;
7
7
  export {};