@benpley/wappler-responsive-sidebar 1.0.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/LICENSE.md +21 -0
- package/README.md +352 -0
- package/app_connect/components.hjson +335 -0
- package/includes/responsive-sidebar.css +94 -0
- package/includes/responsive-sidebar.js +264 -0
- package/package.json +30 -0
package/LICENSE.md
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Ben Pleysier
|
|
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,352 @@
|
|
|
1
|
+
# Wappler Responsive Sidebar
|
|
2
|
+
|
|
3
|
+
A complete responsive sidebar layout component extension for Wappler with header, collapsible navigation, and main content area.
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
|
|
7
|
+
- ✅ **Fully Responsive** - Desktop sidebar, mobile offcanvas
|
|
8
|
+
- 🎨 **Easy Customization** - Edit CSS file directly for styling
|
|
9
|
+
- 📱 **Mobile-First** - Bootstrap 5 offcanvas on mobile devices
|
|
10
|
+
- 🔧 **Easy to Use** - Slot-based architecture for flexible content
|
|
11
|
+
- 🎯 **App Connect Integration** - Dynamic data binding support
|
|
12
|
+
- ⚡ **Lightweight** - Minimal JavaScript footprint
|
|
13
|
+
|
|
14
|
+
## Installation
|
|
15
|
+
|
|
16
|
+
### Via Wappler Extension Manager (Recommended)
|
|
17
|
+
|
|
18
|
+
1. Open your **Project Settings** in Wappler
|
|
19
|
+
2. Navigate to the **Extensions** section
|
|
20
|
+
3. Click on **Add Extension**
|
|
21
|
+
4. Use the **Extension Browser** dialog to browse or search for `@benpley/wappler-responsive-sidebar`
|
|
22
|
+
5. Click the **Add** button to add the extension to your project
|
|
23
|
+
|
|
24
|
+
### Via NPM
|
|
25
|
+
|
|
26
|
+
You can also install directly via npm:
|
|
27
|
+
|
|
28
|
+
```bash
|
|
29
|
+
npm install @benpley/wappler-responsive-sidebar
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
Then add the extension through Wappler's Extension Manager.
|
|
33
|
+
|
|
34
|
+
### Manual Installation
|
|
35
|
+
|
|
36
|
+
1. Download the extension files
|
|
37
|
+
2. Copy the `wappler-responsive-sidebar` folder to your Wappler extensions directory:
|
|
38
|
+
- **Windows**: `C:\Users\[YourUsername]\AppData\Local\Wappler\extensions\`
|
|
39
|
+
- **macOS**: `~/Library/Application Support/Wappler/extensions/`
|
|
40
|
+
- **Linux**: `~/.config/Wappler/extensions/`
|
|
41
|
+
3. Restart Wappler
|
|
42
|
+
|
|
43
|
+
## Usage
|
|
44
|
+
|
|
45
|
+
### Basic Setup
|
|
46
|
+
|
|
47
|
+
1. Open your Wappler project
|
|
48
|
+
2. Add the Responsive Sidebar component from the **Layout** category in the App Connect panel
|
|
49
|
+
3. Customize the slots with your content
|
|
50
|
+
4. Modify `css/responsive-sidebar.css` in your project's public folder to customize styling
|
|
51
|
+
|
|
52
|
+
### Component Structure
|
|
53
|
+
|
|
54
|
+
The sidebar component uses slots for maximum flexibility:
|
|
55
|
+
|
|
56
|
+
```html
|
|
57
|
+
<responsive-sidebar id="sidebar1"
|
|
58
|
+
brand-text="My App"
|
|
59
|
+
brand-url="/"
|
|
60
|
+
sidebar-title="Navigation">
|
|
61
|
+
|
|
62
|
+
<!-- Brand Logo/Content (optional) -->
|
|
63
|
+
<div slot="brand">
|
|
64
|
+
<img src="/logo.png" alt="Logo">
|
|
65
|
+
</div>
|
|
66
|
+
|
|
67
|
+
<!-- Header Right Content (optional) -->
|
|
68
|
+
<div slot="header-right">
|
|
69
|
+
<button class="btn btn-primary">Login</button>
|
|
70
|
+
</div>
|
|
71
|
+
|
|
72
|
+
<!-- Sidebar Menu -->
|
|
73
|
+
<div slot="menu">
|
|
74
|
+
<ul class="list-unstyled">
|
|
75
|
+
<li><a href="/" class="d-block p-2">Dashboard</a></li>
|
|
76
|
+
<li><a href="/products" class="d-block p-2">Products</a></li>
|
|
77
|
+
</ul>
|
|
78
|
+
</div>
|
|
79
|
+
|
|
80
|
+
<!-- Sidebar Footer (optional) -->
|
|
81
|
+
<div slot="footer">
|
|
82
|
+
© 2025 My Company
|
|
83
|
+
</div>
|
|
84
|
+
|
|
85
|
+
<!-- Main Content Area -->
|
|
86
|
+
<div slot="main">
|
|
87
|
+
<!-- Your page content here -->
|
|
88
|
+
</div>
|
|
89
|
+
</responsive-sidebar>
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
### Available Slots
|
|
93
|
+
|
|
94
|
+
| Slot | Description | Required |
|
|
95
|
+
|------|-------------|----------|
|
|
96
|
+
| `brand` | Logo or brand content in header | Optional |
|
|
97
|
+
| `header-right` | Right side of header (buttons, user menu, etc.) | Optional |
|
|
98
|
+
| `menu` | Sidebar navigation menu | Required |
|
|
99
|
+
| `footer` | Sidebar footer content | Optional |
|
|
100
|
+
| `main` | Main page content area | Required |
|
|
101
|
+
|
|
102
|
+
## Properties
|
|
103
|
+
|
|
104
|
+
### Component Attributes
|
|
105
|
+
|
|
106
|
+
| Property | Type | Default | Description |
|
|
107
|
+
|----------|------|---------|-------------|
|
|
108
|
+
| `id` | string | - | Unique component identifier (required) |
|
|
109
|
+
| `brand-text` | string | 'Brand' | Brand text displayed in header |
|
|
110
|
+
| `brand-url` | string | '/' | URL for brand link |
|
|
111
|
+
| `sidebar-title` | string | 'Navigation' | Title shown in mobile offcanvas |
|
|
112
|
+
|
|
113
|
+
### Dynamic Bindings
|
|
114
|
+
|
|
115
|
+
All properties support App Connect data binding:
|
|
116
|
+
|
|
117
|
+
```html
|
|
118
|
+
<responsive-sidebar id="sidebar1"
|
|
119
|
+
dmx-bind:brand-text="appData.brandName"
|
|
120
|
+
dmx-bind:brand-url="appData.homeUrl">
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
## Actions
|
|
124
|
+
|
|
125
|
+
The component provides the following actions for dynamic updates:
|
|
126
|
+
|
|
127
|
+
### setBrandText(text)
|
|
128
|
+
|
|
129
|
+
Dynamically change the brand text:
|
|
130
|
+
|
|
131
|
+
```javascript
|
|
132
|
+
sidebar1.setBrandText('New Brand Name');
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
### setBrandUrl(url)
|
|
136
|
+
|
|
137
|
+
Dynamically change the brand URL:
|
|
138
|
+
|
|
139
|
+
```javascript
|
|
140
|
+
sidebar1.setBrandUrl('/new-home');
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
### setSidebarTitle(title)
|
|
144
|
+
|
|
145
|
+
Dynamically change the sidebar title (mobile view):
|
|
146
|
+
|
|
147
|
+
```javascript
|
|
148
|
+
sidebar1.setSidebarTitle('Menu');
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
## Events
|
|
152
|
+
|
|
153
|
+
| Event | Description |
|
|
154
|
+
|-------|-------------|
|
|
155
|
+
| `rendered` | Fired when the sidebar is initially rendered |
|
|
156
|
+
| `updated` | Fired when the sidebar is updated |
|
|
157
|
+
|
|
158
|
+
### Event Usage
|
|
159
|
+
|
|
160
|
+
```html
|
|
161
|
+
<responsive-sidebar id="sidebar1"
|
|
162
|
+
dmx-on:rendered="console.log('Sidebar rendered')"
|
|
163
|
+
dmx-on:updated="refreshData()">
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
## Styling
|
|
167
|
+
|
|
168
|
+
### Custom CSS
|
|
169
|
+
|
|
170
|
+
All styling is controlled through the `css/responsive-sidebar.css` file in your project's public folder. Simply edit this file to customize:
|
|
171
|
+
|
|
172
|
+
- Header colors and shadows
|
|
173
|
+
- Sidebar colors and width
|
|
174
|
+
- Menu item styling and hover effects
|
|
175
|
+
- Responsive breakpoints
|
|
176
|
+
- Dark mode support
|
|
177
|
+
|
|
178
|
+
**Example customizations:**
|
|
179
|
+
|
|
180
|
+
```css
|
|
181
|
+
/* Change header background color */
|
|
182
|
+
.bd-navbar {
|
|
183
|
+
background-color: #2c3e50 !important;
|
|
184
|
+
color: white;
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
/* Change sidebar background */
|
|
188
|
+
.bd-sidebar,
|
|
189
|
+
.bd-sidebar .offcanvas-lg,
|
|
190
|
+
.bd-sidebar .offcanvas-body {
|
|
191
|
+
background-color: #34495e !important;
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
/* Customize menu links */
|
|
195
|
+
.bd-links a {
|
|
196
|
+
color: #ecf0f1;
|
|
197
|
+
border-radius: 0.25rem;
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
.bd-links a:hover {
|
|
201
|
+
background-color: rgba(255, 255, 255, 0.1);
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
/* Remove header shadow */
|
|
205
|
+
.bd-navbar {
|
|
206
|
+
box-shadow: none;
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
/* Adjust sidebar width */
|
|
210
|
+
@media (min-width: 992px) {
|
|
211
|
+
.bd-sidebar {
|
|
212
|
+
min-width: 16rem;
|
|
213
|
+
max-width: 24rem;
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
```
|
|
217
|
+
|
|
218
|
+
### CSS Class Reference
|
|
219
|
+
|
|
220
|
+
| Class | Description |
|
|
221
|
+
|-------|-------------|
|
|
222
|
+
| `.bd-navbar` | Header navbar |
|
|
223
|
+
| `.bd-sidebar` | Sidebar container |
|
|
224
|
+
| `.bd-links` | Sidebar navigation area |
|
|
225
|
+
| `.bd-main` | Main content area |
|
|
226
|
+
| `.bd-layout` | Grid layout container |
|
|
227
|
+
|
|
228
|
+
## Examples
|
|
229
|
+
|
|
230
|
+
### Example 1: Simple Dashboard Layout
|
|
231
|
+
|
|
232
|
+
```html
|
|
233
|
+
<responsive-sidebar id="dashboard_sidebar"
|
|
234
|
+
brand-text="Dashboard"
|
|
235
|
+
brand-url="/dashboard">
|
|
236
|
+
<div slot="menu">
|
|
237
|
+
<ul class="list-unstyled">
|
|
238
|
+
<li><a href="/dashboard" class="d-block p-2">Home</a></li>
|
|
239
|
+
<li><a href="/analytics" class="d-block p-2">Analytics</a></li>
|
|
240
|
+
<li><a href="/settings" class="d-block p-2">Settings</a></li>
|
|
241
|
+
</ul>
|
|
242
|
+
</div>
|
|
243
|
+
|
|
244
|
+
<div slot="main">
|
|
245
|
+
<h1>Welcome to Dashboard</h1>
|
|
246
|
+
</div>
|
|
247
|
+
</responsive-sidebar>
|
|
248
|
+
```
|
|
249
|
+
|
|
250
|
+
### Example 2: With User Menu
|
|
251
|
+
|
|
252
|
+
```html
|
|
253
|
+
<responsive-sidebar id="app_sidebar" brand-text="My App">
|
|
254
|
+
<div slot="header-right">
|
|
255
|
+
<div class="dropdown">
|
|
256
|
+
<button class="btn btn-link" data-bs-toggle="dropdown">
|
|
257
|
+
<i class="fas fa-user"></i>
|
|
258
|
+
</button>
|
|
259
|
+
<ul class="dropdown-menu">
|
|
260
|
+
<li><a class="dropdown-item" href="/profile">Profile</a></li>
|
|
261
|
+
<li><a class="dropdown-item" href="/logout">Logout</a></li>
|
|
262
|
+
</ul>
|
|
263
|
+
</div>
|
|
264
|
+
</div>
|
|
265
|
+
|
|
266
|
+
<div slot="menu">
|
|
267
|
+
<!-- Navigation items -->
|
|
268
|
+
</div>
|
|
269
|
+
|
|
270
|
+
<div slot="main">
|
|
271
|
+
<!-- Content -->
|
|
272
|
+
</div>
|
|
273
|
+
</responsive-sidebar>
|
|
274
|
+
```
|
|
275
|
+
|
|
276
|
+
### Example 3: Dynamic Menu with App Connect
|
|
277
|
+
|
|
278
|
+
```html
|
|
279
|
+
<responsive-sidebar id="dynamic_sidebar"
|
|
280
|
+
dmx-bind:brand-text="appConfig.name">
|
|
281
|
+
<div slot="menu">
|
|
282
|
+
<ul class="list-unstyled" is="dmx-repeat" dmx-bind:repeat="menuItems.data">
|
|
283
|
+
<li>
|
|
284
|
+
<a dmx-bind:href="url" class="d-block p-2">
|
|
285
|
+
<i dmx-bind:class="icon"></i>
|
|
286
|
+
{{title}}
|
|
287
|
+
</a>
|
|
288
|
+
</li>
|
|
289
|
+
</ul>
|
|
290
|
+
</div>
|
|
291
|
+
|
|
292
|
+
<div slot="main">
|
|
293
|
+
<%- await include(content, locals); %>
|
|
294
|
+
</div>
|
|
295
|
+
</responsive-sidebar>
|
|
296
|
+
```
|
|
297
|
+
|
|
298
|
+
## Requirements
|
|
299
|
+
|
|
300
|
+
- **Wappler** 4.0 or higher
|
|
301
|
+
- **Bootstrap 5** (included in most Wappler projects)
|
|
302
|
+
- **Node.js** 12.0.0 or higher (for npm installation)
|
|
303
|
+
|
|
304
|
+
## Browser Support
|
|
305
|
+
|
|
306
|
+
- Chrome (latest)
|
|
307
|
+
- Firefox (latest)
|
|
308
|
+
- Safari (latest)
|
|
309
|
+
- Edge (latest)
|
|
310
|
+
- Mobile browsers (iOS Safari, Chrome Mobile)
|
|
311
|
+
|
|
312
|
+
## Troubleshooting
|
|
313
|
+
|
|
314
|
+
### Sidebar not appearing
|
|
315
|
+
- Ensure Bootstrap 5 is included in your project
|
|
316
|
+
- Check that the component ID is unique
|
|
317
|
+
- Verify that all required slots are present
|
|
318
|
+
|
|
319
|
+
### Mobile menu not working
|
|
320
|
+
- Ensure Bootstrap 5 JavaScript is loaded
|
|
321
|
+
- Check browser console for JavaScript errors
|
|
322
|
+
|
|
323
|
+
### Styling issues
|
|
324
|
+
- Check `css/responsive-sidebar.css` in your project's public folder
|
|
325
|
+
- Make sure Bootstrap 5 CSS is loaded before the component CSS
|
|
326
|
+
- Use browser DevTools to inspect CSS specificity conflicts
|
|
327
|
+
|
|
328
|
+
## License
|
|
329
|
+
|
|
330
|
+
MIT License - see [LICENSE.md](LICENSE.md) for details
|
|
331
|
+
|
|
332
|
+
Copyright (c) 2025 Ben Pleysier
|
|
333
|
+
|
|
334
|
+
## Support
|
|
335
|
+
|
|
336
|
+
For issues or questions:
|
|
337
|
+
- Check the troubleshooting section above
|
|
338
|
+
- Visit the [Wappler Community Forum](https://community.wappler.io)
|
|
339
|
+
|
|
340
|
+
## Changelog
|
|
341
|
+
|
|
342
|
+
### Version 1.0.0
|
|
343
|
+
- Initial release
|
|
344
|
+
- Responsive sidebar with Bootstrap 5
|
|
345
|
+
- Slot-based architecture
|
|
346
|
+
- App Connect integration
|
|
347
|
+
- Dynamic property binding
|
|
348
|
+
- External CSS file for easy customization
|
|
349
|
+
|
|
350
|
+
---
|
|
351
|
+
|
|
352
|
+
**Made with ❤️ for the Wappler Community**
|
|
@@ -0,0 +1,335 @@
|
|
|
1
|
+
{
|
|
2
|
+
components: [
|
|
3
|
+
{
|
|
4
|
+
type: 'responsive-sidebar',
|
|
5
|
+
selector: 'responsive-sidebar, [is=responsive-sidebar]',
|
|
6
|
+
groupTitle: 'Layout',
|
|
7
|
+
groupIcon: 'fa fa-lg fa-columns',
|
|
8
|
+
title: 'Responsive Sidebar: @@id@@',
|
|
9
|
+
icon: 'fa fa-lg fa-bars',
|
|
10
|
+
state: 'open',
|
|
11
|
+
anyParent: true,
|
|
12
|
+
template: '<responsive-sidebar id="@@id@@" brand-text="Brand" brand-url="/" sidebar-title="Navigation">\n <!-- Brand Logo/Content (optional) -->\n <div slot="brand">\n <span>Your Logo</span>\n </div>\n\n <!-- Header Right Content (optional) -->\n <div slot="header-right">\n <button class="btn btn-primary">Login</button>\n </div>\n\n <!-- Sidebar Menu -->\n <div slot="menu">\n <ul class="list-unstyled">\n <!-- Dashboard Link -->\n <li><a href="/" class="d-block p-2 text-decoration-none">Dashboard</a></li>\n \n <!-- Products Section -->\n <li class="text-uppercase small fw-bold text-muted px-2 mt-3 mb-2">Products</li>\n <li><a href="/products" class="d-block p-2 text-decoration-none">All Products</a></li>\n <li><a href="/products/add" class="d-block p-2 text-decoration-none">Add Product</a></li>\n <li><a href="/products/categories" class="d-block p-2 text-decoration-none">Categories</a></li>\n \n <!-- Employees Section -->\n <li class="text-uppercase small fw-bold text-muted px-2 mt-3 mb-2">Employees</li>\n <li><a href="/employees" class="d-block p-2 text-decoration-none">All Employees</a></li>\n <li><a href="/employees/add" class="d-block p-2 text-decoration-none">Add Employee</a></li>\n <li><a href="/employees/departments" class="d-block p-2 text-decoration-none">Departments</a></li>\n \n <!-- Reports Section -->\n <li class="text-uppercase small fw-bold text-muted px-2 mt-3 mb-2">Reports</li>\n <li><a href="/reports/sales" class="d-block p-2 text-decoration-none">Sales Reports</a></li>\n <li><a href="/reports/analytics" class="d-block p-2 text-decoration-none">Analytics</a></li>\n </ul>\n </div>\n\n <!-- Sidebar Footer (optional) -->\n <div slot="footer">\n © 2026 Your Company\n </div>\n\n <!-- Main Content Area -->\n <div slot="main">\n <%- await include(content, locals); %>\n </div>\n</responsive-sidebar>',
|
|
13
|
+
baseName: 'sidebar',
|
|
14
|
+
help: 'A complete responsive sidebar layout with header, collapsible navigation, and main content area. Customize styles by editing css/responsive-sidebar.css in your project.',
|
|
15
|
+
dataScheme: [
|
|
16
|
+
{name: 'brandText', type: 'text'},
|
|
17
|
+
{name: 'brandUrl', type: 'text'},
|
|
18
|
+
{name: 'sidebarTitle', type: 'text'}
|
|
19
|
+
],
|
|
20
|
+
outputType: 'object',
|
|
21
|
+
dataPick: true,
|
|
22
|
+
properties: [
|
|
23
|
+
{
|
|
24
|
+
group: 'Responsive Sidebar Properties',
|
|
25
|
+
variables: [
|
|
26
|
+
{ name: 'sidebarId', attribute: 'id', title: 'ID', type: 'text', defaultValue: '', required: true },
|
|
27
|
+
{ name: 'brandText', attribute: 'brand-text', title: 'Brand Text', type: 'text', defaultValue: 'Brand', help: 'Text displayed in the header navbar brand area (fallback if no brand slot content)' },
|
|
28
|
+
{ name: 'brandUrl', attribute: 'brand-url', title: 'Brand URL', type: 'text', defaultValue: '/', help: 'URL for the brand link in the header navbar' },
|
|
29
|
+
{ name: 'sidebarTitle', attribute: 'sidebar-title', title: 'Sidebar Title', type: 'text', defaultValue: 'Navigation', help: 'Title displayed in mobile offcanvas header' }
|
|
30
|
+
]
|
|
31
|
+
}
|
|
32
|
+
],
|
|
33
|
+
actionsScheme: [
|
|
34
|
+
{
|
|
35
|
+
addTitle: 'Set Brand Text',
|
|
36
|
+
title: 'Set Brand Text',
|
|
37
|
+
name: 'setBrandText',
|
|
38
|
+
icon: 'fa fa-lg fa-edit',
|
|
39
|
+
state: 'opened',
|
|
40
|
+
help: 'Dynamically change the brand text in the header',
|
|
41
|
+
properties: [
|
|
42
|
+
{
|
|
43
|
+
group: 'Set Brand Text Properties',
|
|
44
|
+
variables: [
|
|
45
|
+
{
|
|
46
|
+
name: '1', optionName: '1', title: 'Brand Text', type: 'text',
|
|
47
|
+
dataBindings: true, defaultValue: '', required: true,
|
|
48
|
+
help: 'New brand text to display'
|
|
49
|
+
}
|
|
50
|
+
]
|
|
51
|
+
}
|
|
52
|
+
]
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
addTitle: 'Set Brand URL',
|
|
56
|
+
title: 'Set Brand URL',
|
|
57
|
+
name: 'setBrandUrl',
|
|
58
|
+
icon: 'fa fa-lg fa-link',
|
|
59
|
+
state: 'opened',
|
|
60
|
+
help: 'Dynamically change the brand URL',
|
|
61
|
+
properties: [
|
|
62
|
+
{
|
|
63
|
+
group: 'Set Brand URL Properties',
|
|
64
|
+
variables: [
|
|
65
|
+
{
|
|
66
|
+
name: '1', optionName: '1', title: 'Brand URL', type: 'text',
|
|
67
|
+
dataBindings: true, defaultValue: '', required: true,
|
|
68
|
+
help: 'New URL for the brand link'
|
|
69
|
+
}
|
|
70
|
+
]
|
|
71
|
+
}
|
|
72
|
+
]
|
|
73
|
+
},
|
|
74
|
+
{
|
|
75
|
+
addTitle: 'Set Sidebar Title',
|
|
76
|
+
title: 'Set Sidebar Title',
|
|
77
|
+
name: 'setSidebarTitle',
|
|
78
|
+
icon: 'fa fa-lg fa-heading',
|
|
79
|
+
state: 'opened',
|
|
80
|
+
help: 'Dynamically change the sidebar title (mobile view)',
|
|
81
|
+
properties: [
|
|
82
|
+
{
|
|
83
|
+
group: 'Set Sidebar Title Properties',
|
|
84
|
+
variables: [
|
|
85
|
+
{
|
|
86
|
+
name: '1', optionName: '1', title: 'Sidebar Title', type: 'text',
|
|
87
|
+
dataBindings: true, defaultValue: '', required: true,
|
|
88
|
+
help: 'New title for the sidebar'
|
|
89
|
+
}
|
|
90
|
+
]
|
|
91
|
+
}
|
|
92
|
+
]
|
|
93
|
+
}
|
|
94
|
+
],
|
|
95
|
+
children: [],
|
|
96
|
+
allowed_children: {},
|
|
97
|
+
copyFiles: [
|
|
98
|
+
{src: 'includes/responsive-sidebar.css', dst: 'css/responsive-sidebar.css'},
|
|
99
|
+
{src: 'includes/responsive-sidebar.js', dst: 'js/responsive-sidebar.js'}
|
|
100
|
+
],
|
|
101
|
+
linkFiles: [
|
|
102
|
+
{src: 'css/responsive-sidebar.css', type: 'css'},
|
|
103
|
+
{src: 'js/responsive-sidebar.js', type: 'js', defer: true}
|
|
104
|
+
],
|
|
105
|
+
cssOrder: [],
|
|
106
|
+
jsOrder: []
|
|
107
|
+
}
|
|
108
|
+
],
|
|
109
|
+
attributes: [
|
|
110
|
+
{
|
|
111
|
+
name: 'responsive-sidebar-brandText',
|
|
112
|
+
attributeStartsWith: 'dmx-bind',
|
|
113
|
+
attribute: 'brand-text',
|
|
114
|
+
title: 'Brand Text',
|
|
115
|
+
type: 'boolean',
|
|
116
|
+
display: 'fieldset',
|
|
117
|
+
icon: 'fa fa-lg fa-chevron-right',
|
|
118
|
+
groupTitle: 'Responsive Sidebar',
|
|
119
|
+
groupIcon: 'fa fa-lg fa-bars',
|
|
120
|
+
defaultValue: false,
|
|
121
|
+
show: ['brandTextValue'],
|
|
122
|
+
noChangeOnHide: true,
|
|
123
|
+
groupEnabler: true,
|
|
124
|
+
children: [
|
|
125
|
+
{
|
|
126
|
+
name: 'brandTextValue',
|
|
127
|
+
attributeStartsWith: 'dmx-bind',
|
|
128
|
+
attribute: 'brand-text',
|
|
129
|
+
isValue: true,
|
|
130
|
+
dataBindings: true,
|
|
131
|
+
title: 'Brand Text:',
|
|
132
|
+
type: 'text',
|
|
133
|
+
help: 'Choose dynamic data binding for brand text.',
|
|
134
|
+
defaultValue: '',
|
|
135
|
+
initDisplay: 'none'
|
|
136
|
+
}
|
|
137
|
+
],
|
|
138
|
+
allowedOn: {
|
|
139
|
+
'responsive-sidebar': true
|
|
140
|
+
}
|
|
141
|
+
},
|
|
142
|
+
{
|
|
143
|
+
name: 'responsive-sidebar-brandUrl',
|
|
144
|
+
attributeStartsWith: 'dmx-bind',
|
|
145
|
+
attribute: 'brand-url',
|
|
146
|
+
title: 'Brand URL',
|
|
147
|
+
type: 'boolean',
|
|
148
|
+
display: 'fieldset',
|
|
149
|
+
icon: 'fa fa-lg fa-chevron-right',
|
|
150
|
+
groupTitle: 'Responsive Sidebar',
|
|
151
|
+
groupIcon: 'fa fa-lg fa-bars',
|
|
152
|
+
defaultValue: false,
|
|
153
|
+
show: ['brandUrlValue'],
|
|
154
|
+
noChangeOnHide: true,
|
|
155
|
+
groupEnabler: true,
|
|
156
|
+
children: [
|
|
157
|
+
{
|
|
158
|
+
name: 'brandUrlValue',
|
|
159
|
+
attributeStartsWith: 'dmx-bind',
|
|
160
|
+
attribute: 'brand-url',
|
|
161
|
+
isValue: true,
|
|
162
|
+
dataBindings: true,
|
|
163
|
+
title: 'Brand URL:',
|
|
164
|
+
type: 'text',
|
|
165
|
+
help: 'Choose dynamic data binding for brand URL.',
|
|
166
|
+
defaultValue: '',
|
|
167
|
+
initDisplay: 'none'
|
|
168
|
+
}
|
|
169
|
+
],
|
|
170
|
+
allowedOn: {
|
|
171
|
+
'responsive-sidebar': true
|
|
172
|
+
}
|
|
173
|
+
},
|
|
174
|
+
{
|
|
175
|
+
name: 'responsive-sidebar-sidebarTitle',
|
|
176
|
+
attributeStartsWith: 'dmx-bind',
|
|
177
|
+
attribute: 'sidebar-title',
|
|
178
|
+
title: 'Sidebar Title',
|
|
179
|
+
type: 'boolean',
|
|
180
|
+
display: 'fieldset',
|
|
181
|
+
icon: 'fa fa-lg fa-chevron-right',
|
|
182
|
+
groupTitle: 'Responsive Sidebar',
|
|
183
|
+
groupIcon: 'fa fa-lg fa-bars',
|
|
184
|
+
defaultValue: false,
|
|
185
|
+
show: ['sidebarTitleValue'],
|
|
186
|
+
noChangeOnHide: true,
|
|
187
|
+
groupEnabler: true,
|
|
188
|
+
children: [
|
|
189
|
+
{
|
|
190
|
+
name: 'sidebarTitleValue',
|
|
191
|
+
attributeStartsWith: 'dmx-bind',
|
|
192
|
+
attribute: 'sidebar-title',
|
|
193
|
+
isValue: true,
|
|
194
|
+
dataBindings: true,
|
|
195
|
+
title: 'Sidebar Title:',
|
|
196
|
+
type: 'text',
|
|
197
|
+
help: 'Choose dynamic data binding for sidebar title.',
|
|
198
|
+
defaultValue: '',
|
|
199
|
+
initDisplay: 'none'
|
|
200
|
+
}
|
|
201
|
+
],
|
|
202
|
+
allowedOn: {
|
|
203
|
+
'responsive-sidebar': true
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
],
|
|
207
|
+
events: [
|
|
208
|
+
{
|
|
209
|
+
name: 'responsive-sidebar-rendered',
|
|
210
|
+
attributeStartsWith: 'dmx-on',
|
|
211
|
+
attribute: 'rendered',
|
|
212
|
+
title: 'Rendered',
|
|
213
|
+
type: 'boolean',
|
|
214
|
+
display: 'fieldset',
|
|
215
|
+
icon: 'fa fa-lg fa-chevron-right',
|
|
216
|
+
groupTitle: 'Responsive Sidebar',
|
|
217
|
+
groupIcon: 'fa fa-lg fa-bars',
|
|
218
|
+
defaultValue: false,
|
|
219
|
+
show: ['renderedValue'],
|
|
220
|
+
noChangeOnHide: true,
|
|
221
|
+
groupEnabler: true,
|
|
222
|
+
children: [
|
|
223
|
+
{
|
|
224
|
+
name: 'renderedValue',
|
|
225
|
+
attributeStartsWith: 'dmx-on',
|
|
226
|
+
attribute: 'rendered',
|
|
227
|
+
isValue: true,
|
|
228
|
+
actionsPicker: true,
|
|
229
|
+
title: 'Action:',
|
|
230
|
+
type: 'text',
|
|
231
|
+
help: 'Choose the action to execute when sidebar is rendered.',
|
|
232
|
+
defaultValue: '',
|
|
233
|
+
initDisplay: 'none'
|
|
234
|
+
}
|
|
235
|
+
],
|
|
236
|
+
allowedOn: {
|
|
237
|
+
'responsive-sidebar': true
|
|
238
|
+
}
|
|
239
|
+
},
|
|
240
|
+
{
|
|
241
|
+
name: 'responsive-sidebar-updated',
|
|
242
|
+
attributeStartsWith: 'dmx-on',
|
|
243
|
+
attribute: 'updated',
|
|
244
|
+
title: 'Updated',
|
|
245
|
+
type: 'boolean',
|
|
246
|
+
display: 'fieldset',
|
|
247
|
+
icon: 'fa fa-lg fa-chevron-right',
|
|
248
|
+
groupTitle: 'Responsive Sidebar',
|
|
249
|
+
groupIcon: 'fa fa-lg fa-bars',
|
|
250
|
+
defaultValue: false,
|
|
251
|
+
show: ['updatedValue'],
|
|
252
|
+
noChangeOnHide: true,
|
|
253
|
+
groupEnabler: true,
|
|
254
|
+
children: [
|
|
255
|
+
{
|
|
256
|
+
name: 'updatedValue',
|
|
257
|
+
attributeStartsWith: 'dmx-on',
|
|
258
|
+
attribute: 'updated',
|
|
259
|
+
isValue: true,
|
|
260
|
+
actionsPicker: true,
|
|
261
|
+
title: 'Action:',
|
|
262
|
+
type: 'text',
|
|
263
|
+
help: 'Choose the action to execute when sidebar is updated.',
|
|
264
|
+
defaultValue: '',
|
|
265
|
+
initDisplay: 'none'
|
|
266
|
+
}
|
|
267
|
+
],
|
|
268
|
+
allowedOn: {
|
|
269
|
+
'responsive-sidebar': true
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
],
|
|
273
|
+
static_events: [
|
|
274
|
+
{
|
|
275
|
+
name: 'responsive-sidebar-rendered',
|
|
276
|
+
attribute: 'onrendered',
|
|
277
|
+
title: 'Rendered',
|
|
278
|
+
type: 'boolean',
|
|
279
|
+
display: 'fieldset',
|
|
280
|
+
icon: 'fa fa-lg fa-check-circle',
|
|
281
|
+
groupTitle: 'Responsive Sidebar',
|
|
282
|
+
groupIcon: 'fa fa-lg fa-bars',
|
|
283
|
+
defaultValue: false,
|
|
284
|
+
show: ['renderedValue'],
|
|
285
|
+
noChangeOnHide: true,
|
|
286
|
+
groupEnabler: true,
|
|
287
|
+
children: [
|
|
288
|
+
{
|
|
289
|
+
name: 'renderedValue',
|
|
290
|
+
attribute: 'onrendered',
|
|
291
|
+
isValue: true,
|
|
292
|
+
behaviorsPicker: true,
|
|
293
|
+
title: 'Action:',
|
|
294
|
+
type: 'text',
|
|
295
|
+
help: 'Choose the action to execute when sidebar is rendered.',
|
|
296
|
+
defaultValue: '',
|
|
297
|
+
initDisplay: 'none'
|
|
298
|
+
}
|
|
299
|
+
],
|
|
300
|
+
allowedOn: {
|
|
301
|
+
'responsive-sidebar': true
|
|
302
|
+
}
|
|
303
|
+
},
|
|
304
|
+
{
|
|
305
|
+
name: 'responsive-sidebar-updated',
|
|
306
|
+
attribute: 'onupdated',
|
|
307
|
+
title: 'Updated',
|
|
308
|
+
type: 'boolean',
|
|
309
|
+
display: 'fieldset',
|
|
310
|
+
icon: 'fa fa-lg fa-sync',
|
|
311
|
+
groupTitle: 'Responsive Sidebar',
|
|
312
|
+
groupIcon: 'fa fa-lg fa-bars',
|
|
313
|
+
defaultValue: false,
|
|
314
|
+
show: ['updatedValue'],
|
|
315
|
+
noChangeOnHide: true,
|
|
316
|
+
groupEnabler: true,
|
|
317
|
+
children: [
|
|
318
|
+
{
|
|
319
|
+
name: 'updatedValue',
|
|
320
|
+
attribute: 'onupdated',
|
|
321
|
+
isValue: true,
|
|
322
|
+
behaviorsPicker: true,
|
|
323
|
+
title: 'Action:',
|
|
324
|
+
type: 'text',
|
|
325
|
+
help: 'Choose the action to execute when sidebar is updated.',
|
|
326
|
+
defaultValue: '',
|
|
327
|
+
initDisplay: 'none'
|
|
328
|
+
}
|
|
329
|
+
],
|
|
330
|
+
allowedOn: {
|
|
331
|
+
'responsive-sidebar': true
|
|
332
|
+
}
|
|
333
|
+
}
|
|
334
|
+
]
|
|
335
|
+
}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Responsive Sidebar Styles
|
|
3
|
+
* Wappler Extension Component
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/* Header Navbar */
|
|
7
|
+
.bd-navbar {
|
|
8
|
+
box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15), inset 0 -1px rgba(255, 255, 255, 0.15);
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
.bd-navbar.no-shadow {
|
|
12
|
+
box-shadow: none;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
/* Layout Grid */
|
|
16
|
+
@media (min-width: 992px) {
|
|
17
|
+
.bd-layout {
|
|
18
|
+
display: grid;
|
|
19
|
+
grid-template-areas: "sidebar main";
|
|
20
|
+
grid-template-columns: 1fr 5fr;
|
|
21
|
+
flex: 1;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
.bd-main {
|
|
26
|
+
grid-area: main;
|
|
27
|
+
display: flex;
|
|
28
|
+
flex-direction: column;
|
|
29
|
+
min-height: 0;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/* Sidebar */
|
|
33
|
+
.bd-sidebar {
|
|
34
|
+
grid-area: sidebar;
|
|
35
|
+
background-color: var(--bs-secondary-bg);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
@media (min-width: 992px) {
|
|
39
|
+
.bd-sidebar {
|
|
40
|
+
position: sticky;
|
|
41
|
+
top: 3.5rem;
|
|
42
|
+
display: block !important;
|
|
43
|
+
height: calc(100vh - 3.5rem);
|
|
44
|
+
overflow-y: auto;
|
|
45
|
+
min-width: 13rem;
|
|
46
|
+
max-width: 20rem;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
.bd-sidebar .offcanvas-lg {
|
|
50
|
+
height: 100%;
|
|
51
|
+
display: flex !important;
|
|
52
|
+
flex-direction: column;
|
|
53
|
+
background-color: var(--bs-secondary-bg);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
.bd-sidebar .offcanvas-body {
|
|
57
|
+
flex: 1;
|
|
58
|
+
display: flex;
|
|
59
|
+
flex-direction: column;
|
|
60
|
+
background-color: var(--bs-secondary-bg);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
.bd-sidebar .bd-links {
|
|
64
|
+
padding-top: 1.5rem !important;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
@media (max-width: 991.98px) {
|
|
69
|
+
.bd-sidebar .offcanvas-lg {
|
|
70
|
+
border-right-color: var(--bs-border-color);
|
|
71
|
+
box-shadow: var(--bs-box-shadow-lg);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/* Make the component wrapper transparent */
|
|
76
|
+
responsive-sidebar {
|
|
77
|
+
display: contents;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
/* Sidebar menu styling helpers */
|
|
81
|
+
.bd-links a {
|
|
82
|
+
transition: background-color 0.15s ease-in-out;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
.bd-links a:hover {
|
|
86
|
+
background-color: rgba(0, 0, 0, 0.05);
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/* Dark mode support */
|
|
90
|
+
@media (prefers-color-scheme: dark) {
|
|
91
|
+
.bd-links a:hover {
|
|
92
|
+
background-color: rgba(255, 255, 255, 0.1);
|
|
93
|
+
}
|
|
94
|
+
}
|
|
@@ -0,0 +1,264 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Responsive Sidebar - Wappler Extension
|
|
3
|
+
* Complete layout with header + sidebar
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
// First, define the native Web Component for proper DOM handling
|
|
7
|
+
class ResponsiveSidebar extends HTMLElement {
|
|
8
|
+
connectedCallback() {
|
|
9
|
+
// Use a microtask to ensure children are parsed
|
|
10
|
+
Promise.resolve().then(() => {
|
|
11
|
+
this.render();
|
|
12
|
+
});
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
render() {
|
|
16
|
+
// Get slotted content (preserve the actual DOM nodes)
|
|
17
|
+
const menuContent = this.querySelector('[slot="menu"]');
|
|
18
|
+
const footerContent = this.querySelector('[slot="footer"]');
|
|
19
|
+
const mainContent = this.querySelector('[slot="main"]');
|
|
20
|
+
const headerRightContent = this.querySelector('[slot="header-right"]');
|
|
21
|
+
const brandContent = this.querySelector('[slot="brand"]');
|
|
22
|
+
|
|
23
|
+
// If no content yet, try again later
|
|
24
|
+
if (!menuContent && !mainContent) {
|
|
25
|
+
setTimeout(() => this.render(), 0);
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
// Get attributes for fallback
|
|
30
|
+
const brandUrl = this.getAttribute('brand-url') || '/';
|
|
31
|
+
const sidebarTitle = this.getAttribute('sidebar-title') || 'Navigation';
|
|
32
|
+
|
|
33
|
+
// Create the header structure
|
|
34
|
+
const header = document.createElement('header');
|
|
35
|
+
header.className = 'navbar navbar-expand-lg bd-navbar sticky-top bg-body-secondary';
|
|
36
|
+
|
|
37
|
+
const nav = document.createElement('nav');
|
|
38
|
+
nav.className = 'container-fluid';
|
|
39
|
+
|
|
40
|
+
// Left side: toggler + brand
|
|
41
|
+
const leftDiv = document.createElement('div');
|
|
42
|
+
leftDiv.className = 'd-flex align-items-center';
|
|
43
|
+
|
|
44
|
+
const togglerBtn = document.createElement('button');
|
|
45
|
+
togglerBtn.className = 'navbar-toggler';
|
|
46
|
+
togglerBtn.type = 'button';
|
|
47
|
+
togglerBtn.setAttribute('data-bs-toggle', 'offcanvas');
|
|
48
|
+
togglerBtn.setAttribute('data-bs-target', '#bdSidebar');
|
|
49
|
+
togglerBtn.innerHTML = '<span class="navbar-toggler-icon"></span>';
|
|
50
|
+
|
|
51
|
+
const brandLink = document.createElement('a');
|
|
52
|
+
brandLink.className = 'navbar-brand ps-1 mb-0';
|
|
53
|
+
brandLink.href = brandUrl;
|
|
54
|
+
|
|
55
|
+
// Use brand slot if provided, otherwise fallback to attribute
|
|
56
|
+
if (brandContent) {
|
|
57
|
+
while (brandContent.firstChild) {
|
|
58
|
+
brandLink.appendChild(brandContent.firstChild);
|
|
59
|
+
}
|
|
60
|
+
} else {
|
|
61
|
+
const brandText = this.getAttribute('brand-text') || 'Brand';
|
|
62
|
+
brandLink.textContent = brandText;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
leftDiv.appendChild(togglerBtn);
|
|
66
|
+
leftDiv.appendChild(brandLink);
|
|
67
|
+
nav.appendChild(leftDiv);
|
|
68
|
+
|
|
69
|
+
// Right side: custom content slot
|
|
70
|
+
if (headerRightContent) {
|
|
71
|
+
const rightDiv = document.createElement('div');
|
|
72
|
+
rightDiv.className = 'ms-auto d-flex align-items-center';
|
|
73
|
+
while (headerRightContent.firstChild) {
|
|
74
|
+
rightDiv.appendChild(headerRightContent.firstChild);
|
|
75
|
+
}
|
|
76
|
+
nav.appendChild(rightDiv);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
header.appendChild(nav);
|
|
80
|
+
|
|
81
|
+
// Create bd-layout container
|
|
82
|
+
const layout = document.createElement('div');
|
|
83
|
+
layout.className = 'bd-layout container-fluid px-0';
|
|
84
|
+
|
|
85
|
+
// Create sidebar
|
|
86
|
+
const sidebar = document.createElement('aside');
|
|
87
|
+
sidebar.className = 'bd-sidebar';
|
|
88
|
+
|
|
89
|
+
const offcanvas = document.createElement('div');
|
|
90
|
+
offcanvas.className = 'offcanvas-lg offcanvas-start bg-body-secondary';
|
|
91
|
+
offcanvas.tabIndex = -1;
|
|
92
|
+
offcanvas.id = 'bdSidebar';
|
|
93
|
+
offcanvas.setAttribute('aria-labelledby', 'bdSidebarOffcanvasLabel');
|
|
94
|
+
|
|
95
|
+
const offcanvasHeader = document.createElement('div');
|
|
96
|
+
offcanvasHeader.className = 'offcanvas-header border-bottom d-lg-none';
|
|
97
|
+
offcanvasHeader.innerHTML = `
|
|
98
|
+
<h5 class="offcanvas-title" id="bdSidebarOffcanvasLabel">${sidebarTitle}</h5>
|
|
99
|
+
<button type="button" class="btn-close" data-bs-dismiss="offcanvas" aria-label="Close" data-bs-target="#bdSidebar"></button>
|
|
100
|
+
`;
|
|
101
|
+
|
|
102
|
+
const offcanvasBody = document.createElement('div');
|
|
103
|
+
offcanvasBody.className = 'offcanvas-body d-flex flex-column p-0';
|
|
104
|
+
|
|
105
|
+
const sidebarNav = document.createElement('nav');
|
|
106
|
+
sidebarNav.className = 'bd-links w-100 p-3 ps-lg-3';
|
|
107
|
+
sidebarNav.id = 'bd-docs-nav';
|
|
108
|
+
sidebarNav.setAttribute('aria-label', 'Sidebar navigation');
|
|
109
|
+
|
|
110
|
+
// Move menu content into nav (preserve DOM nodes)
|
|
111
|
+
if (menuContent) {
|
|
112
|
+
while (menuContent.firstChild) {
|
|
113
|
+
sidebarNav.appendChild(menuContent.firstChild);
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
offcanvasBody.appendChild(sidebarNav);
|
|
118
|
+
|
|
119
|
+
// Add footer if exists
|
|
120
|
+
if (footerContent) {
|
|
121
|
+
const footer = document.createElement('div');
|
|
122
|
+
footer.className = 'text-muted small text-center mt-auto p-3';
|
|
123
|
+
while (footerContent.firstChild) {
|
|
124
|
+
footer.appendChild(footerContent.firstChild);
|
|
125
|
+
}
|
|
126
|
+
offcanvasBody.appendChild(footer);
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
offcanvas.appendChild(offcanvasHeader);
|
|
130
|
+
offcanvas.appendChild(offcanvasBody);
|
|
131
|
+
sidebar.appendChild(offcanvas);
|
|
132
|
+
|
|
133
|
+
// Create main content area
|
|
134
|
+
const main = document.createElement('main');
|
|
135
|
+
main.className = 'bd-main my-3 order-1';
|
|
136
|
+
|
|
137
|
+
// Move main content (preserve DOM nodes and App Connect components)
|
|
138
|
+
if (mainContent) {
|
|
139
|
+
while (mainContent.firstChild) {
|
|
140
|
+
main.appendChild(mainContent.firstChild);
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
// Assemble the structure
|
|
145
|
+
layout.appendChild(sidebar);
|
|
146
|
+
layout.appendChild(main);
|
|
147
|
+
|
|
148
|
+
// Clear and append
|
|
149
|
+
this.innerHTML = '';
|
|
150
|
+
this.appendChild(header);
|
|
151
|
+
this.appendChild(layout);
|
|
152
|
+
|
|
153
|
+
// Dispatch a custom event when rendering is complete
|
|
154
|
+
this.dispatchEvent(new CustomEvent('rendered', { bubbles: true }));
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
// Method to update brand text dynamically
|
|
158
|
+
setBrandText(text) {
|
|
159
|
+
this.setAttribute('brand-text', text);
|
|
160
|
+
this.render();
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
// Method to update brand URL dynamically
|
|
164
|
+
setBrandUrl(url) {
|
|
165
|
+
this.setAttribute('brand-url', url);
|
|
166
|
+
this.render();
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
// Method to update sidebar title dynamically
|
|
170
|
+
setSidebarTitle(title) {
|
|
171
|
+
this.setAttribute('sidebar-title', title);
|
|
172
|
+
this.render();
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
// Observe attribute changes
|
|
176
|
+
static get observedAttributes() {
|
|
177
|
+
return ['brand-text', 'brand-url', 'sidebar-title'];
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
attributeChangedCallback(name, oldValue, newValue) {
|
|
181
|
+
if (oldValue !== newValue && this.isConnected) {
|
|
182
|
+
this.render();
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
// Register the custom element
|
|
188
|
+
customElements.define('responsive-sidebar', ResponsiveSidebar);
|
|
189
|
+
|
|
190
|
+
// Now wrap it as a Wappler component for better IDE integration
|
|
191
|
+
dmx.Component('responsive-sidebar', {
|
|
192
|
+
initialData: {
|
|
193
|
+
brandText: null,
|
|
194
|
+
brandUrl: null,
|
|
195
|
+
sidebarTitle: null
|
|
196
|
+
},
|
|
197
|
+
|
|
198
|
+
attributes: {
|
|
199
|
+
brandText: {
|
|
200
|
+
type: String,
|
|
201
|
+
default: 'Brand'
|
|
202
|
+
},
|
|
203
|
+
brandUrl: {
|
|
204
|
+
type: String,
|
|
205
|
+
default: '/'
|
|
206
|
+
},
|
|
207
|
+
sidebarTitle: {
|
|
208
|
+
type: String,
|
|
209
|
+
default: 'Navigation'
|
|
210
|
+
}
|
|
211
|
+
},
|
|
212
|
+
|
|
213
|
+
methods: {
|
|
214
|
+
setBrandText: function (text) {
|
|
215
|
+
this.$node.setBrandText(text);
|
|
216
|
+
this.set('brandText', text);
|
|
217
|
+
this.dispatchEvent('updated');
|
|
218
|
+
},
|
|
219
|
+
|
|
220
|
+
setBrandUrl: function (url) {
|
|
221
|
+
this.$node.setBrandUrl(url);
|
|
222
|
+
this.set('brandUrl', url);
|
|
223
|
+
this.dispatchEvent('updated');
|
|
224
|
+
},
|
|
225
|
+
|
|
226
|
+
setSidebarTitle: function (title) {
|
|
227
|
+
this.$node.setSidebarTitle(title);
|
|
228
|
+
this.set('sidebarTitle', title);
|
|
229
|
+
this.dispatchEvent('updated');
|
|
230
|
+
}
|
|
231
|
+
},
|
|
232
|
+
|
|
233
|
+
events: {
|
|
234
|
+
rendered: Event,
|
|
235
|
+
updated: Event
|
|
236
|
+
},
|
|
237
|
+
|
|
238
|
+
render: function () {
|
|
239
|
+
// Store initial attribute values in data
|
|
240
|
+
if (this.props.brandText) {
|
|
241
|
+
this.set('brandText', this.props.brandText);
|
|
242
|
+
}
|
|
243
|
+
if (this.props.brandUrl) {
|
|
244
|
+
this.set('brandUrl', this.props.brandUrl);
|
|
245
|
+
}
|
|
246
|
+
if (this.props.sidebarTitle) {
|
|
247
|
+
this.set('sidebarTitle', this.props.sidebarTitle);
|
|
248
|
+
}
|
|
249
|
+
},
|
|
250
|
+
|
|
251
|
+
update: function (props, fields) {
|
|
252
|
+
// The Web Component handles attribute changes automatically
|
|
253
|
+
// Just update our internal data
|
|
254
|
+
if (fields.has('brandText')) {
|
|
255
|
+
this.set('brandText', this.props.brandText);
|
|
256
|
+
}
|
|
257
|
+
if (fields.has('brandUrl')) {
|
|
258
|
+
this.set('brandUrl', this.props.brandUrl);
|
|
259
|
+
}
|
|
260
|
+
if (fields.has('sidebarTitle')) {
|
|
261
|
+
this.set('sidebarTitle', this.props.sidebarTitle);
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
});
|
package/package.json
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@benpley/wappler-responsive-sidebar",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "A responsive sidebar component extension for Wappler",
|
|
5
|
+
"author": {
|
|
6
|
+
"name": "Ben Pleysier"
|
|
7
|
+
},
|
|
8
|
+
"license": "MIT",
|
|
9
|
+
"keywords": [
|
|
10
|
+
"wappler-extension",
|
|
11
|
+
"appconnect",
|
|
12
|
+
"wappler",
|
|
13
|
+
"sidebar",
|
|
14
|
+
"responsive",
|
|
15
|
+
"navigation",
|
|
16
|
+
"component"
|
|
17
|
+
],
|
|
18
|
+
"engines": {
|
|
19
|
+
"node": ">=12.0.0"
|
|
20
|
+
},
|
|
21
|
+
"publishConfig": {
|
|
22
|
+
"access": "public"
|
|
23
|
+
},
|
|
24
|
+
"files": [
|
|
25
|
+
"app_connect/",
|
|
26
|
+
"includes/",
|
|
27
|
+
"README.md",
|
|
28
|
+
"LICENSE.md"
|
|
29
|
+
]
|
|
30
|
+
}
|