varminer-app-header 2.1.3 → 2.1.5

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 DELETED
@@ -1,209 +0,0 @@
1
- # varminer-app-header
2
-
3
- A plug-and-play React header component built with Material-UI (MUI) that provides a professional app header with drawer toggle, notifications, user profile menu, and responsive design.
4
-
5
- ## Features
6
-
7
- - 🎨 **Material-UI Integration** - Built with MUI components
8
- - 📱 **Responsive Design** - Mobile and desktop support
9
- - 🔔 **Notifications** - Badge support for notifications and messages
10
- - 👤 **User Profile Menu** - Dropdown menu with user info and actions
11
- - 🎯 **Drawer Toggle** - Built-in drawer context for sidebar navigation
12
- - 🎨 **Customizable** - Configurable props for branding and behavior
13
- - 📦 **TypeScript** - Full TypeScript support
14
- - 🎨 **SCSS Styling** - Customizable styles
15
-
16
- ## Installation
17
-
18
- ```bash
19
- npm install varminer-app-header
20
- ```
21
-
22
- ## Peer Dependencies
23
-
24
- Make sure you have these installed in your project:
25
-
26
- ```bash
27
- npm install react react-dom react-router-dom @mui/material @mui/icons-material @emotion/react @emotion/styled
28
- ```
29
-
30
- **Important:** The package uses React Router's `useNavigate` hook for internal navigation. Make sure your app is wrapped with a `BrowserRouter` (or similar router) from `react-router-dom`.
31
-
32
- ## Usage
33
-
34
- ### Plug-and-Play (Zero Configuration)
35
-
36
- The package is **100% plug-and-play** - no props needed! It automatically loads everything from localStorage and handles all interactions internally:
37
-
38
- ```tsx
39
- import React from 'react';
40
- import { AppHeader, DrawerProvider } from 'varminer-app-header';
41
- import 'varminer-app-header/dist/index.css'; // Don't forget the CSS!
42
-
43
- function App() {
44
- return (
45
- <DrawerProvider>
46
- <AppHeader />
47
- </DrawerProvider>
48
- );
49
- }
50
- ```
51
-
52
- **That's it!** The component automatically:
53
- - ✅ Loads user data from `localStorage` (`persist:userdb`)
54
- - ✅ Loads notification count from `localStorage`
55
- - ✅ Loads message count from `localStorage`
56
- - ✅ Handles hamburger menu toggle internally
57
- - ✅ Uses default logo ("VAR" and "MINER")
58
- - ✅ Uses default routes: `/account/overview`, `/profile`, `/logout`
59
- - ✅ Handles all navigation internally
60
- - ✅ Shows online status badge
61
-
62
- ### Zero Configuration
63
-
64
- The component requires **no props at all** - it's completely plug-and-play!
65
-
66
- **Defaults:**
67
- - Logo: "VAR" and "MINER"
68
- - Routes: `/account/overview` (settings), `/profile` (profile), `/logout` (logout)
69
- - Navigation: Handled internally with React Router
70
-
71
- ### With Custom Callbacks (Override Default Behavior)
72
-
73
- You can override the default navigation by providing custom callbacks:
74
-
75
- ```tsx
76
- import React from 'react';
77
- import { AppHeader, DrawerProvider } from 'varminer-app-header';
78
- import { useNavigate } from 'react-router-dom';
79
-
80
- function App() {
81
- const navigate = useNavigate();
82
-
83
- return (
84
- <DrawerProvider>
85
- <AppHeader
86
- user={{
87
- name: "Jane Smith",
88
- email: "jane@example.com",
89
- role: "Manager",
90
- avatar: "/path/to/avatar.jpg"
91
- }}
92
- isOnline={true}
93
- logo={{ first: "MY", second: "APP" }}
94
- routes={{
95
- settings: "/settings",
96
- profile: "/profile",
97
- logout: "/login"
98
- }}
99
- onDrawerToggle={() => {
100
- // Handle drawer toggle
101
- console.log('Drawer toggled');
102
- }}
103
- onSettingsClick={() => {
104
- // Custom logic before navigation
105
- console.log('Custom settings handler');
106
- navigate('/custom-settings');
107
- }}
108
- onSignOutClick={() => {
109
- // Custom sign out logic
110
- localStorage.clear();
111
- sessionStorage.clear();
112
- navigate('/user/login');
113
- }}
114
- />
115
- </DrawerProvider>
116
- );
117
- }
118
- ```
119
-
120
- ## Props
121
-
122
- ### AppHeaderProps
123
-
124
- | Prop | Type | Default | Description |
125
- |------|------|---------|-------------|
126
- | `user` | `UserProfile` | See below | User profile information |
127
- | `isOnline` | `boolean` | `true` | Whether the user is online |
128
- | `logo` | `{ first: string, second: string }` | `{ first: "VAR", second: "MINER" }` | App logo/brand name (optional) |
129
- | `notificationCount` | `number` | `0` | Notification badge count (only shown if > 0) |
130
- | `messageCount` | `number` | `undefined` | Message badge count (optional, shown only in mobile menu) |
131
- | `onDrawerToggle` | `() => void` | - | Callback when drawer toggle is clicked |
132
- | `routes` | `{ settings?: string, profile?: string, logout?: string }` | See below | Route paths for navigation (optional) |
133
- | `onSettingsClick` | `() => void` | - | Callback when settings is clicked (overrides default navigation) |
134
- | `onProfileClick` | `() => void` | - | Callback when profile is clicked (overrides default navigation) |
135
- | `onSignOutClick` | `() => void` | - | Callback when sign out is clicked (overrides default navigation) |
136
- | `className` | `string` | - | Custom CSS class name |
137
-
138
- **Default routes (used if not provided):**
139
- - `settings`: `"/account/overview"`
140
- - `profile`: `"/profile"`
141
- - `logout`: `"/logout"`
142
-
143
- **Note:** If callbacks are not provided, the package will automatically handle navigation using React Router's `useNavigate` hook. For sign out, it will also clear `localStorage` before navigating.
144
-
145
- ### UserProfile
146
-
147
- | Property | Type | Required | Description |
148
- |----------|------|----------|-------------|
149
- | `name` | `string` | Yes | User's full name |
150
- | `email` | `string` | Yes | User's email address |
151
- | `role` | `string` | Yes | User's role/title |
152
- | `avatar` | `string` | No | URL to user's avatar image |
153
- | `initials` | `string` | No | Custom initials (auto-generated from name if not provided) |
154
-
155
- ## DrawerProvider
156
-
157
- The `DrawerProvider` component provides drawer state management. Wrap your app with it to enable drawer functionality:
158
-
159
- ```tsx
160
- import { DrawerProvider, useDrawer } from 'varminer-app-header';
161
-
162
- function MyApp() {
163
- return (
164
- <DrawerProvider>
165
- <YourApp />
166
- </DrawerProvider>
167
- );
168
- }
169
-
170
- // Use the drawer context in any component
171
- function Sidebar() {
172
- const { isDrawerOpen, toggleDrawer } = useDrawer();
173
-
174
- return (
175
- <Drawer open={isDrawerOpen} onClose={toggleDrawer}>
176
- {/* Sidebar content */}
177
- </Drawer>
178
- );
179
- }
180
- ```
181
-
182
- ## Styling
183
-
184
- The component includes SCSS styles that can be customized. The styles use SCSS variables defined in `src/styles/_variables.scss`. You can override these by importing the styles and customizing the variables.
185
-
186
- ### Custom Styling
187
-
188
- ```tsx
189
- import 'varminer-app-header/dist/index.css';
190
- // Your custom overrides
191
- ```
192
-
193
- ## Development
194
-
195
- ```bash
196
- # Install dependencies
197
- npm install
198
-
199
- # Build the package
200
- npm run build
201
-
202
- # Watch mode for development
203
- npm run dev
204
- ```
205
-
206
- ## License
207
-
208
- MIT
209
-