@salesforcedevs/docs-components 1.17.0-hack-alpha3 → 1.17.0-hack-alpha5

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@salesforcedevs/docs-components",
3
- "version": "1.17.0-hack-alpha3",
3
+ "version": "1.17.0-hack-alpha5",
4
4
  "description": "Docs Lightning web components for DSC",
5
5
  "license": "MIT",
6
6
  "main": "index.js",
@@ -0,0 +1,212 @@
1
+ # Comment Popup Component - Local Storage Implementation
2
+
3
+ This component provides a commenting system that uses browser localStorage for data persistence while the backend API is being developed.
4
+
5
+ ## Features
6
+
7
+ - ✅ **Local Storage**: Comments are stored in browser localStorage
8
+ - ✅ **API-Ready**: Code structure prepared for backend integration
9
+ - ✅ **Development Tools**: Helper utilities for managing comments
10
+ - ✅ **Export/Import**: Ability to export comments to JSON files
11
+ - ✅ **Migration Ready**: Tools to convert data for backend migration
12
+
13
+ ## How It Works
14
+
15
+ ### Storage Structure
16
+
17
+ Comments are stored in localStorage under the key `dsc_comments` with the following structure:
18
+
19
+ ```json
20
+ {
21
+ "branch_filepath_headingtitle": [
22
+ {
23
+ "email": "user@example.com",
24
+ "comment_text": "This is a comment",
25
+ "timestamp": "2024-01-15T10:30:00Z"
26
+ }
27
+ ]
28
+ }
29
+ ```
30
+
31
+ ### API Payload Format
32
+
33
+ When posting comments, the component uses this exact format (ready for backend):
34
+
35
+ ```json
36
+ {
37
+ "branch": "feature/documentation-updates",
38
+ "file_path": "docs/installation.md",
39
+ "heading_title": "Installation Guide",
40
+ "comment": {
41
+ "comment_text": "This installation guide is very helpful for new users.",
42
+ "email": "john.doe@example.com",
43
+ "timestamp": "2024-01-15T10:30:00Z"
44
+ }
45
+ }
46
+ ```
47
+
48
+ ## Development Tools
49
+
50
+ ### Console Commands
51
+
52
+ When the component is loaded, you can access these functions in the browser console:
53
+
54
+ ```javascript
55
+ // Export all comments to a JSON file
56
+ CommentDevHelper.exportCommentsToFile();
57
+
58
+ // Clear all comments from localStorage
59
+ CommentDevHelper.clearAllComments();
60
+
61
+ // Get statistics about stored comments
62
+ CommentDevHelper.getCommentsStats();
63
+
64
+ // Convert comments to API format (for backend migration)
65
+ CommentDevHelper.convertToApiFormat();
66
+
67
+ // Add a sample comment for testing
68
+ CommentDevHelper.addSampleComment();
69
+
70
+ // Show all comments in console
71
+ CommentDevHelper.showAllComments();
72
+ ```
73
+
74
+ ### Development UI
75
+
76
+ In development mode (localhost), a floating UI will appear in the top-right corner with buttons to:
77
+
78
+ - Export comments
79
+ - Clear all comments
80
+ - View statistics
81
+ - Show API format
82
+
83
+ ## Migration to Backend
84
+
85
+ When the backend is ready, follow these steps:
86
+
87
+ ### 1. Export Current Comments
88
+
89
+ ```javascript
90
+ // Export all comments to JSON file
91
+ CommentDevHelper.exportCommentsToFile();
92
+ ```
93
+
94
+ ### 2. Convert to API Format
95
+
96
+ ```javascript
97
+ // Get comments in API format
98
+ const apiFormat = CommentDevHelper.convertToApiFormat();
99
+ console.log(apiFormat);
100
+ ```
101
+
102
+ ### 3. Uncomment API Code
103
+
104
+ In `commentPopup.ts`, uncomment the API implementation sections:
105
+
106
+ ```typescript
107
+ // Remove the localStorage implementation and uncomment:
108
+ /*
109
+ const response = await fetch('/post-comment', {
110
+ method: 'POST',
111
+ headers: {
112
+ 'Content-Type': 'application/json'
113
+ },
114
+ body: JSON.stringify(payload)
115
+ });
116
+ */
117
+ ```
118
+
119
+ ### 4. Update Endpoints
120
+
121
+ Update the API endpoints in the component:
122
+
123
+ - POST: `/post-comment` (for adding comments)
124
+ - GET: `/api/comments` (for fetching comments)
125
+
126
+ ## File Structure
127
+
128
+ ```
129
+ commentPopup/
130
+ ├── commentPopup.ts # Main component
131
+ ├── commentPopup.html # Template
132
+ ├── commentPopup.css # Styles
133
+ ├── commentUtils.ts # Utility functions
134
+ ├── commentDevHelper.ts # Development tools
135
+ └── README.md # This file
136
+ ```
137
+
138
+ ## Usage
139
+
140
+ ### Basic Usage
141
+
142
+ ```html
143
+ <c-comment-popup
144
+ heading-title="Installation Guide"
145
+ file-path="docs/installation.md"
146
+ current-branch="main"
147
+ >
148
+ </c-comment-popup>
149
+ ```
150
+
151
+ ### Required Properties
152
+
153
+ - `heading-title`: The title of the section being commented on
154
+ - `file-path`: The file path where the comment is located
155
+ - `current-branch`: The current git branch
156
+
157
+ ### Optional Properties
158
+
159
+ - `start-line`: Starting line number (for future line-specific comments)
160
+ - `end-line`: Ending line number (for future line-specific comments)
161
+ - `open`: Boolean to control popup visibility
162
+
163
+ ## Events
164
+
165
+ The component dispatches these events:
166
+
167
+ ```javascript
168
+ // When a comment is added
169
+ element.addEventListener("commentadded", (event) => {
170
+ console.log("New comment:", event.detail);
171
+ });
172
+ ```
173
+
174
+ ## Browser Compatibility
175
+
176
+ - Modern browsers with localStorage support
177
+ - IE10+ (with polyfills if needed)
178
+
179
+ ## Storage Limits
180
+
181
+ - localStorage typically has a 5-10MB limit
182
+ - Comments are stored as JSON strings
183
+ - Monitor storage usage with `CommentDevHelper.getCommentsStats()`
184
+
185
+ ## Troubleshooting
186
+
187
+ ### Comments Not Appearing
188
+
189
+ 1. Check browser console for errors
190
+ 2. Verify localStorage is enabled
191
+ 3. Check if the comment key matches: `branch_filepath_headingtitle`
192
+
193
+ ### Storage Issues
194
+
195
+ 1. Clear localStorage: `CommentDevHelper.clearAllComments()`
196
+ 2. Export existing comments before clearing
197
+ 3. Check browser storage limits
198
+
199
+ ### Development UI Not Showing
200
+
201
+ 1. Ensure you're on localhost
202
+ 2. Check if the UI was manually closed
203
+ 3. Refresh the page to recreate the UI
204
+
205
+ ## Future Enhancements
206
+
207
+ - [ ] Line-specific comments
208
+ - [ ] Comment threading/replies
209
+ - [ ] Comment moderation
210
+ - [ ] User authentication integration
211
+ - [ ] Real-time comment updates
212
+ - [ ] Comment search and filtering
@@ -0,0 +1,152 @@
1
+ // Development Helper for Comment Management
2
+ // This file provides a simple interface to manage comments during development
3
+ // You can use this in the browser console or create a simple UI for it
4
+
5
+ import {
6
+ exportCommentsToFile,
7
+ importCommentsFromFile,
8
+ getAllComments,
9
+ clearAllComments,
10
+ getCommentsStats,
11
+ convertToApiFormat,
12
+ addComment
13
+ } from "./commentUtils";
14
+
15
+ // Make functions available globally for console access
16
+ if (typeof window !== "undefined") {
17
+ (window as any).CommentDevHelper = {
18
+ exportCommentsToFile,
19
+ importCommentsFromFile,
20
+ getAllComments,
21
+ clearAllComments,
22
+ getCommentsStats,
23
+ convertToApiFormat,
24
+ addComment
25
+ };
26
+ }
27
+
28
+ /**
29
+ * Create a simple UI for managing comments during development
30
+ */
31
+ export function createDevUI(): void {
32
+ if (typeof document === "undefined") {
33
+ return;
34
+ }
35
+
36
+ // Check if UI already exists
37
+ if (document.getElementById("comment-dev-ui")) {
38
+ return;
39
+ }
40
+
41
+ const ui = document.createElement("div");
42
+ ui.id = "comment-dev-ui";
43
+ ui.style.cssText = `
44
+ position: fixed;
45
+ top: 20px;
46
+ right: 20px;
47
+ width: 300px;
48
+ background: white;
49
+ border: 2px solid #007bff;
50
+ border-radius: 8px;
51
+ padding: 16px;
52
+ font-family: Arial, sans-serif;
53
+ font-size: 14px;
54
+ z-index: 10000;
55
+ box-shadow: 0 4px 12px rgba(0,0,0,0.15);
56
+ `;
57
+
58
+ const stats = getCommentsStats();
59
+
60
+ ui.innerHTML = `
61
+ <div style="display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px;">
62
+ <h3 style="margin: 0; color: #007bff;">Comment Dev Helper</h3>
63
+ <button onclick="document.getElementById('comment-dev-ui').remove()" style="background: none; border: none; font-size: 18px; cursor: pointer;">×</button>
64
+ </div>
65
+
66
+ <div style="margin-bottom: 12px;">
67
+ <strong>Stats:</strong><br>
68
+ Locations: ${stats.totalLocations}<br>
69
+ Total Comments: ${stats.totalComments}
70
+ </div>
71
+
72
+ <div style="display: flex; flex-direction: column; gap: 8px;">
73
+ <button onclick="CommentDevHelper.exportCommentsToFile()" style="padding: 8px; background: #28a745; color: white; border: none; border-radius: 4px; cursor: pointer;">
74
+ Export Comments
75
+ </button>
76
+
77
+ <button onclick="CommentDevHelper.clearAllComments()" style="padding: 8px; background: #dc3545; color: white; border: none; border-radius: 4px; cursor: pointer;">
78
+ Clear All Comments
79
+ </button>
80
+
81
+ <button onclick="CommentDevHelper.getCommentsStats()" style="padding: 8px; background: #17a2b8; color: white; border: none; border-radius: 4px; cursor: pointer;">
82
+ Show Stats in Console
83
+ </button>
84
+
85
+ <button onclick="console.log(CommentDevHelper.convertToApiFormat())" style="padding: 8px; background: #6f42c1; color: white; border: none; border-radius: 4px; cursor: pointer;">
86
+ Show API Format in Console
87
+ </button>
88
+ </div>
89
+
90
+ <div style="margin-top: 12px; font-size: 12px; color: #666;">
91
+ <strong>Console Commands:</strong><br>
92
+ CommentDevHelper.exportCommentsToFile()<br>
93
+ CommentDevHelper.clearAllComments()<br>
94
+ CommentDevHelper.getCommentsStats()<br>
95
+ CommentDevHelper.convertToApiFormat()
96
+ </div>
97
+ `;
98
+
99
+ document.body.appendChild(ui);
100
+ }
101
+
102
+ /**
103
+ * Remove the development UI
104
+ */
105
+ export function removeDevUI(): void {
106
+ const ui = document.getElementById("comment-dev-ui");
107
+ if (ui) {
108
+ ui.remove();
109
+ }
110
+ }
111
+
112
+ /**
113
+ * Add a sample comment for testing
114
+ */
115
+ export function addSampleComment(): void {
116
+ const samplePayload = {
117
+ branch: "feature/documentation-updates",
118
+ file_path: "docs/installation.md",
119
+ heading_title: "Installation Guide",
120
+ start_line: "10",
121
+ end_line: "25",
122
+ comment: {
123
+ comment_text: "This is a sample comment for testing purposes.",
124
+ email: "test@example.com",
125
+ timestamp: new Date().toISOString()
126
+ }
127
+ };
128
+
129
+ addComment(samplePayload);
130
+ console.log("Sample comment added:", samplePayload);
131
+ }
132
+
133
+ /**
134
+ * Show all comments in a formatted way in the console
135
+ */
136
+ export function showAllComments(): void {
137
+ const allComments = getAllComments();
138
+ console.log("=== ALL COMMENTS ===");
139
+ console.table(allComments);
140
+
141
+ const stats = getCommentsStats();
142
+ console.log("=== STATISTICS ===");
143
+ console.table(stats.locations);
144
+ }
145
+
146
+ // Auto-create UI when this module is imported (in development)
147
+ if (typeof window !== "undefined" && window.location.hostname === "localhost") {
148
+ // Only auto-create in development environment
149
+ setTimeout(() => {
150
+ createDevUI();
151
+ }, 1000);
152
+ }
@@ -133,6 +133,72 @@
133
133
  padding: 0 24px 24px;
134
134
  }
135
135
 
136
+ /* Success Message */
137
+ .success-message {
138
+ display: flex;
139
+ align-items: center;
140
+ gap: 8px;
141
+ background: #e8f5e8;
142
+ color: #2e7d32;
143
+ padding: 12px 16px;
144
+ border-radius: 8px;
145
+ margin-bottom: 16px;
146
+ border-left: 4px solid #4caf50;
147
+ font-size: 14px;
148
+ }
149
+
150
+ .success-message dx-icon {
151
+ --sds-c-icon-color-foreground: #4caf50;
152
+ }
153
+
154
+ /* API Error Message */
155
+ .api-error {
156
+ display: flex;
157
+ align-items: center;
158
+ gap: 8px;
159
+ background: #ffebee;
160
+ color: #c62828;
161
+ padding: 12px 16px;
162
+ border-radius: 8px;
163
+ margin-bottom: 16px;
164
+ border-left: 4px solid #f44336;
165
+ font-size: 14px;
166
+ }
167
+
168
+ .api-error dx-icon {
169
+ --sds-c-icon-color-foreground: #f44336;
170
+ }
171
+
172
+ /* Loading Message */
173
+ .loading-message {
174
+ display: flex;
175
+ align-items: center;
176
+ gap: 8px;
177
+ background: #e3f2fd;
178
+ color: #1565c0;
179
+ padding: 12px 16px;
180
+ border-radius: 8px;
181
+ margin-bottom: 16px;
182
+ border-left: 4px solid #2196f3;
183
+ font-size: 14px;
184
+ }
185
+
186
+ .loading-message dx-icon {
187
+ --sds-c-icon-color-foreground: #2196f3;
188
+
189
+ animation: spin 1s linear infinite;
190
+ }
191
+
192
+ @keyframes spin {
193
+ from {
194
+ transform: rotate(0deg);
195
+ }
196
+
197
+ to {
198
+ transform: rotate(360deg);
199
+ }
200
+ }
201
+
136
202
  /* Comment Form */
137
203
  .comment-form {
138
204
  margin-bottom: 24px;
@@ -277,6 +343,13 @@
277
343
  padding: 0 16px 16px;
278
344
  }
279
345
 
346
+ .success-message,
347
+ .api-error,
348
+ .loading-message {
349
+ padding: 10px 12px;
350
+ font-size: 13px;
351
+ }
352
+
280
353
  .comments-section {
281
354
  padding-top: 16px;
282
355
  }
@@ -297,6 +370,24 @@
297
370
  border-bottom-color: #424242;
298
371
  }
299
372
 
373
+ .success-message {
374
+ background: #1b5e20;
375
+ color: #a5d6a7;
376
+ border-left-color: #4caf50;
377
+ }
378
+
379
+ .api-error {
380
+ background: #b71c1c;
381
+ color: #ef9a9a;
382
+ border-left-color: #f44336;
383
+ }
384
+
385
+ .loading-message {
386
+ background: #0d47a1;
387
+ color: #90caf9;
388
+ border-left-color: #2196f3;
389
+ }
390
+
300
391
  .form-label {
301
392
  color: #e0e0e0;
302
393
  }
@@ -35,8 +35,27 @@
35
35
  ></dx-button>
36
36
  </div>
37
37
 
38
- <!-- Comment Form -->
38
+ <!-- Popup Content -->
39
39
  <div class="popup-content">
40
+ <!-- Success Message -->
41
+ <div if:true={submitSuccess} class="success-message">
42
+ <dx-icon icon-symbol="success" icon-size="small"></dx-icon>
43
+ <span>Comment posted successfully!</span>
44
+ </div>
45
+
46
+ <!-- API Error Message -->
47
+ <div if:true={apiError} class="error-message api-error">
48
+ <dx-icon icon-symbol="error" icon-size="small"></dx-icon>
49
+ <span>{apiError}</span>
50
+ </div>
51
+
52
+ <!-- Loading State -->
53
+ <div if:true={isLoading} class="loading-message">
54
+ <dx-icon icon-symbol="spinner" icon-size="small"></dx-icon>
55
+ <span>Loading comments...</span>
56
+ </div>
57
+
58
+ <!-- Comment Form -->
40
59
  <form class="comment-form" onsubmit={handleSubmit}>
41
60
  <div class="form-group">
42
61
  <label for="email-input" class="form-label">