@memori.ai/memori-react 8.8.3 → 8.8.4

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.
@@ -3,7 +3,7 @@
3
3
  padding: 1rem;
4
4
  grid-auto-flow: dense;
5
5
  grid-gap: 1rem;
6
- grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
6
+ grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
7
7
  }
8
8
 
9
9
  /* Allineamento media per messaggi dell'utente */
@@ -119,8 +119,8 @@ a.memori-media-item--link {
119
119
  }
120
120
 
121
121
  .memori-media-item--modal .memori-modal--panel {
122
- width: 75vw;
123
- height: 85vh;
122
+ max-width: 75vw;
123
+ max-height: 85vh;
124
124
  -webkit-backdrop-filter: blur(var(--memori-blur-background, 10px));
125
125
  backdrop-filter: blur(var(--memori-blur-background, 10px));
126
126
  background: rgba(0, 0, 0, 0.25);
@@ -165,18 +165,16 @@ a.memori-media-item--link {
165
165
  }
166
166
 
167
167
  .memori-media-item-preview--content {
168
- min-height: 50vh;
169
- max-height: 50vh;
170
- padding: 1rem;
171
- border: 1px solid var(--memori-border);
172
- border-radius: 0.5rem;
173
- background-color: var(--memori-background-color, #fff);
174
- box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
175
- overflow-y: auto;
176
- }
177
-
178
- .memori-media-item--snippet{
179
- min-width: 450px;
168
+ display: flex;
169
+ overflow: hidden;
170
+ min-height: 60vh;
171
+ max-height: 80vh;
172
+ flex-direction: column;
173
+ padding: 0;
174
+ border: none;
175
+ border-radius: 0.75rem;
176
+ background-color: var(--memori-background-color, #fff);
177
+ box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
180
178
  }
181
179
 
182
180
  .memori-media-item-preview--text {
@@ -266,29 +264,208 @@ a.memori-media-item--link {
266
264
  text-decoration: none;
267
265
  }
268
266
 
267
+ .memori-media-item--snippet {
268
+ min-width: 450px;
269
+ max-width: 100%;
270
+ }
271
+
272
+ .memori-media-item--snippet-direct {
273
+ display: flex;
274
+ width: 100%;
275
+ margin-bottom: 1rem;
276
+ }
277
+
278
+ /* Enhanced snippet grid layout */
279
+ .memori-media-items--grid .memori-media-item--snippet-direct {
280
+ max-width: none;
281
+ grid-column: 1 / -1;
282
+ }
283
+
284
+ .memori-media-items--grid .memori-media-item--snippet {
285
+ min-width: 100%;
286
+ max-width: 100%;
287
+ }
288
+
289
+ .memori-media-item--snippet-direct .memori-media-item--snippet {
290
+ overflow: hidden;
291
+ width: 100%;
292
+ min-width: auto;
293
+ border: 1px solid var(--memori-border, #e5e7eb);
294
+ border-radius: 0.75rem;
295
+ box-shadow: 0 2px 4px -1px rgba(0, 0, 0, 0.1);
296
+ transition: all 0.2s ease;
297
+ }
298
+
299
+ .memori-media-item--snippet-direct .memori-media-item--snippet:hover {
300
+ box-shadow: 0 4px 8px -2px rgba(0, 0, 0, 0.15);
301
+ transform: translateY(-1px);
302
+ }
303
+
304
+ .memori-media-item--snippet-direct .memori-snippet {
305
+ border-radius: 0.75rem;
306
+ background: #f8fafc;
307
+ }
308
+
309
+ .memori-media-item--snippet-direct .memori-snippet pre {
310
+ padding: 1rem;
311
+ border: none;
312
+ margin: 0;
313
+ background: #f8fafc;
314
+ font-size: 0.875rem;
315
+ line-height: 1.6;
316
+ overflow-x: auto;
317
+ }
318
+
319
+ .memori-media-item--snippet-direct .memori-snippet code {
320
+ padding: 0;
321
+ border-radius: 0;
322
+ background: transparent;
323
+ color: #374151;
324
+ font-family: 'Fira Code', 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
325
+ }
326
+
327
+ .memori-media-item--snippet-direct .memori-snippet--copy-button {
328
+ border: 1px solid rgba(0, 0, 0, 0.1);
329
+ background: rgba(0, 0, 0, 0.05);
330
+ transition: all 0.2s ease;
331
+ }
332
+
333
+
334
+ .memori-media-item--snippet-direct .memori-snippet--copy-button svg {
335
+ width: 14px;
336
+ height: 14px;
337
+ color: #6b7280;
338
+ }
339
+
340
+ .memori-media-item--snippet-direct .memori-snippet--caption {
341
+ padding: 0.75rem 1rem;
342
+ border-top: 1px solid rgba(0, 0, 0, 0.05);
343
+ background: rgba(0, 0, 0, 0.02);
344
+ color: #6b7280;
345
+ font-size: 0.8rem;
346
+ font-weight: 500;
347
+ }
348
+
349
+ /* Enhanced snippet styles for modal */
350
+ .memori-media-item-preview--content .memori-snippet {
351
+ display: flex;
352
+ overflow: hidden;
353
+ height: 100%;
354
+ flex-direction: column;
355
+ border-radius: 0.75rem;
356
+ background: #1e1e1e;
357
+ }
358
+
359
+ .memori-media-item-preview--content .memori-snippet--content {
360
+ display: flex;
361
+ overflow: hidden;
362
+ flex: 1;
363
+ flex-direction: column;
364
+ }
365
+
366
+ .memori-media-item-preview--content .memori-snippet pre {
367
+ overflow: auto;
368
+ flex: 1;
369
+ padding: 1.5rem;
370
+ border: none;
371
+ border-radius: 0;
372
+ margin: 0;
373
+ background: #1e1e1e;
374
+ font-size: 0.875rem;
375
+ line-height: 1.6;
376
+ }
377
+
378
+ .memori-media-item-preview--content .memori-snippet code {
379
+ padding: 0;
380
+ border-radius: 0;
381
+ background: transparent;
382
+ font-family: 'Fira Code', 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
383
+ }
384
+
385
+ .memori-media-item-preview--content .memori-snippet--copy-button {
386
+ position: absolute;
387
+ z-index: 10;
388
+ top: 1rem;
389
+ right: 1rem;
390
+ border: 1px solid rgba(255, 255, 255, 0.2);
391
+ backdrop-filter: blur(10px);
392
+ background: rgba(255, 255, 255, 0.1);
393
+ transition: all 0.2s ease;
394
+ }
395
+
396
+
397
+ .memori-media-item-preview--content .memori-snippet--copy-button:hover {
398
+ border-color: rgba(255, 255, 255, 0.3);
399
+ background: rgba(255, 255, 255, 0.2);
400
+ transform: scale(1.05);
401
+ }
402
+
403
+ .memori-media-item-preview--content .memori-snippet--copy-button svg {
404
+ width: 16px;
405
+ height: 16px;
406
+ color: #fff;
407
+ }
408
+
409
+ .memori-media-item-preview--content .memori-snippet--caption {
410
+ padding: 1rem 1.5rem;
411
+ border-top: 1px solid rgba(255, 255, 255, 0.1);
412
+ background: rgba(0, 0, 0, 0.1);
413
+ color: #ccc;
414
+ font-size: 0.875rem;
415
+ font-weight: 500;
416
+ }
417
+
269
418
  /* Responsive design */
270
419
  @media (max-width: 768px) {
271
- .memori-media-items--grid {
272
- padding: 0.75rem;
273
- grid-gap: 0.75rem;
274
- grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
275
- }
276
-
277
- .memori-media-item--figure-caption {
278
- padding: 0.375rem 0.5rem;
279
- font-size: 0.65rem;
280
- line-height: 1.2;
281
- }
282
-
283
- .memori-media-item-preview--text {
284
- font-size: 0.8rem;
285
- }
286
-
287
- .memori-media-item-preview--text pre {
288
- padding: 0.75rem;
289
- }
290
-
291
- .memori-media-item-preview--content {
292
- max-height: 40vh;
293
- }
294
- }
420
+ .memori-media-items--grid {
421
+ padding: 0.75rem;
422
+ grid-gap: 0.75rem;
423
+ grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
424
+ }
425
+
426
+ .memori-media-item--figure-caption {
427
+ padding: 0.375rem 0.5rem;
428
+ font-size: 0.65rem;
429
+ line-height: 1.2;
430
+ }
431
+
432
+ .memori-media-item-preview--text {
433
+ font-size: 0.8rem;
434
+ }
435
+
436
+ .memori-media-item-preview--text pre {
437
+ padding: 0.75rem;
438
+ }
439
+
440
+ .memori-media-item-preview--content {
441
+ min-height: 40vh;
442
+ max-height: 50vh;
443
+ }
444
+
445
+ /* Mobile snippet improvements */
446
+ .memori-media-item--snippet-direct {
447
+ margin-bottom: 0.75rem;
448
+ }
449
+
450
+ .memori-media-item--snippet-direct .memori-snippet pre {
451
+ padding: 0.75rem;
452
+ font-size: 0.8rem;
453
+ }
454
+
455
+ .memori-media-item--snippet-direct .memori-snippet--copy-button {
456
+ top: 0.5rem;
457
+ right: 0.5rem;
458
+ width: 28px !important;
459
+ height: 28px !important;
460
+ }
461
+
462
+ .memori-media-item--snippet-direct .memori-snippet--copy-button svg {
463
+ width: 12px;
464
+ height: 12px;
465
+ }
466
+
467
+ .memori-media-item-preview--content .memori-snippet pre {
468
+ padding: 1rem;
469
+ font-size: 0.8rem;
470
+ }
471
+ }
@@ -113,73 +113,160 @@ JavaScript.args = {
113
113
  mediumID: '65ca4a6d-f20b-402e-9d79-5e470f247928',
114
114
  mimeType: 'text/javascript',
115
115
  title: 'JavaScript',
116
- content: `[
117
- {
118
- "name": "France",
119
- "capital": "Paris",
120
- "population": 67364357,
121
- "area": 551695,
122
- "currency": "Euro",
123
- "languages": [
124
- "French"
125
- ],
126
- "region": "Europe",
127
- "subregion": "Western Europe",
128
- "flag": "https://upload.wikimedia.org/wikipedia/commons/c/c3/Flag_of_France.svg"
129
- },
130
- {
131
- "name": "Germany",
132
- "capital": "Berlin",
133
- "population": 83240525,
134
- "area": 357022,
135
- "currency": "Euro",
136
- "languages": [
137
- "German"
138
- ],
139
- "region": "Europe",
140
- "subregion": "Western Europe",
141
- "flag": "https://upload.wikimedia.org/wikipedia/commons/b/ba/Flag_of_Germany.svg"
142
- },
143
- {
144
- "name": "United States",
145
- "capital": "Washington, D.C.",
146
- "population": 331893745,
147
- "area": 9833517,
148
- "currency": "USD",
149
- "languages": [
150
- "English"
151
- ],
152
- "region": "Americas",
153
- "subregion": "Northern America",
154
- "flag": "https://upload.wikimedia.org/wikipedia/commons/a/a4/Flag_of_the_United_States.svg"
155
- },
156
- {
157
- "name": "Belgium",
158
- "capital": "Brussels",
159
- "population": 11589623,
160
- "area": 30528,
161
- "currency": "Euro",
162
- "languages": [
163
- "Flemish",
164
- "French",
165
- "German"
166
- ],
167
- "region": "Europe",
168
- "subregion": "Western Europe",
169
- "flag": "https://upload.wikimedia.org/wikipedia/commons/6/65/Flag_of_Belgium.svg"
170
- ]`,
116
+ content: `{
117
+ "name": "John Doe",
118
+ "age": 43,
119
+ "city": "New York",
120
+ "items": [
121
+ {
122
+ "name": "Item 1",
123
+ "price": 10
124
+ },
125
+ {
126
+ "name": "Item 2",
127
+ "price": 20
128
+ }
129
+ ]
130
+ }
131
+ `,
132
+ },
133
+ ],
134
+ };
135
+
136
+ export const ShortCodeSnippets = Template.bind({});
137
+ ShortCodeSnippets.args = {
138
+ items: [
139
+ {
140
+ mediumID: 'short-js-1',
141
+ mimeType: 'text/javascript',
142
+ title: 'Short JS Function',
143
+ content: 'function greet() {\n return "Hello World!";\n}',
144
+ },
145
+ {
146
+ mediumID: 'short-python-1',
147
+ mimeType: 'text/python',
148
+ title: 'Python Print',
149
+ content: 'print("Hello, World!")',
150
+ },
151
+ {
152
+ mediumID: 'short-css-1',
153
+ mimeType: 'text/css',
154
+ title: 'CSS Rule',
155
+ content: 'body {\n background: #f0f0f0;\n color: #333;\n}',
156
+ },
157
+ ],
158
+ };
159
+
160
+ export const LongCodeSnippets = Template.bind({});
161
+ LongCodeSnippets.args = {
162
+ items: [
163
+ {
164
+ mediumID: 'long-js-1',
165
+ mimeType: 'text/javascript',
166
+ title: 'Long JavaScript Function',
167
+ content: `function processData(data) {
168
+ // Validate input
169
+ if (!data || typeof data !== 'object') {
170
+ throw new Error('Invalid data provided');
171
+ }
172
+
173
+ // Process each item
174
+ return data.map(item => {
175
+ const processed = {
176
+ id: item.id,
177
+ name: item.name.toUpperCase(),
178
+ value: item.value * 2,
179
+ timestamp: new Date().toISOString()
180
+ };
181
+
182
+ return processed;
183
+ });
184
+ }`,
185
+ },
186
+ {
187
+ mediumID: 'long-python-1',
188
+ mimeType: 'text/python',
189
+ title: 'Python Class',
190
+ content: `class DataProcessor:
191
+ def __init__(self, config):
192
+ self.config = config
193
+ self.cache = {}
194
+
195
+ def process(self, data):
196
+ if data in self.cache:
197
+ return self.cache[data]
198
+
199
+ result = self._transform(data)
200
+ self.cache[data] = result
201
+ return result
202
+
203
+ def _transform(self, data):
204
+ # Complex transformation logic
205
+ return data.upper()`,
206
+ },
207
+ ],
208
+ };
209
+
210
+ export const MixedSnippets = Template.bind({});
211
+ MixedSnippets.args = {
212
+ items: [
213
+ {
214
+ mediumID: 'short-1',
215
+ mimeType: 'text/javascript',
216
+ title: 'Quick Function',
217
+ content: 'const add = (a, b) => a + b;',
218
+ },
219
+ {
220
+ mediumID: 'long-1',
221
+ mimeType: 'text/javascript',
222
+ title: 'Complex Component',
223
+ content: `import React, { useState, useEffect } from 'react';
224
+
225
+ const MyComponent = ({ data, onUpdate }) => {
226
+ const [loading, setLoading] = useState(false);
227
+ const [error, setError] = useState(null);
228
+
229
+ useEffect(() => {
230
+ if (data) {
231
+ setLoading(true);
232
+ processData(data)
233
+ .then(result => {
234
+ onUpdate(result);
235
+ setLoading(false);
236
+ })
237
+ .catch(err => {
238
+ setError(err.message);
239
+ setLoading(false);
240
+ });
241
+ }
242
+ }, [data, onUpdate]);
243
+
244
+ if (loading) return <div>Loading...</div>;
245
+ if (error) return <div>Error: {error}</div>;
246
+
247
+ return <div>Data processed successfully</div>;
248
+ };
249
+
250
+ export default MyComponent;`,
251
+ },
252
+ {
253
+ mediumID: 'short-2',
254
+ mimeType: 'text/css',
255
+ title: 'Simple Style',
256
+ content: '.button {\n padding: 10px;\n background: blue;\n}',
171
257
  },
172
258
  ],
173
259
  };
174
260
 
175
- export const longTXT = Template.bind({});
176
- longTXT.args = {
261
+ export const LongTXT = Template.bind({});
262
+ LongTXT.args = {
177
263
  items: [
178
264
  {
179
265
  mediumID: '65ca4a6d-f20b-402e-9d79-5e470f247928',
180
266
  mimeType: 'text/plain',
181
267
  title: 'Long Text',
182
- content: 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed non risus. Suspendisse lectus tortor, dignissim sit amet, adipiscing nec, ultricies sed, dolor. Cras elementum ultrices diam. Maecenas ligula massa, varius a, semper congue, euismod non, mi.',
268
+ content:
269
+ 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed non risus. Suspendisse lectus tortor, dignissim sit amet, adipiscing nec, ultricies sed, dolor. Cras elementum ultrices diam. Maecenas ligula massa, varius a, semper congue, euismod non, mi.',
183
270
  },
184
271
  ],
185
272
  };
@@ -187,7 +187,7 @@ export const RenderMediaItem = ({
187
187
  widthMd="90%"
188
188
  >
189
189
  <div className="memori-media-item-preview--content">
190
- <Snippet medium={item} showCopyButton={true} />
190
+ <Snippet medium={item} showCopyButton={true} />
191
191
  </div>
192
192
  </Modal>
193
193
  </>
@@ -368,6 +368,12 @@ export const RenderMediaItem = ({
368
368
  }
369
369
  };
370
370
 
371
+ // Helper function to count lines in content
372
+ const countLines = (content: string | undefined): number => {
373
+ if (!content) return 0;
374
+ return content.split('\n').length;
375
+ };
376
+
371
377
  export const RenderSnippetItem = ({
372
378
  item,
373
379
  sessionID: _sessionID,
@@ -383,6 +389,23 @@ export const RenderSnippetItem = ({
383
389
  apiURL?: string;
384
390
  onClick?: (mediumID: string) => void;
385
391
  }) => {
392
+ const lineCount = countLines(item.content);
393
+ const isShortSnippet = lineCount <= 5;
394
+
395
+ // For short snippets, show them directly without the clickable link
396
+ if (isShortSnippet) {
397
+ return (
398
+ <div className="memori-media-item--snippet-direct">
399
+ <Card className="memori-media-item--card memori-media-item--snippet">
400
+ <div className="memori-media-item--snippet-preview">
401
+ <Snippet showCopyButton={true} preview={false} medium={item} />
402
+ </div>
403
+ </Card>
404
+ </div>
405
+ );
406
+ }
407
+
408
+ // For longer snippets, show preview with click to open modal
386
409
  return (
387
410
  <>
388
411
  <a
@@ -25,13 +25,11 @@ exports[`renders MediaItemWidget unchanged with css snippet to show 1`] = `
25
25
  <div
26
26
  class="memori-media-item ease-out duration-500 delay-0 opacity-0 scale-95"
27
27
  >
28
- <a
29
- class="memori-media-item--link"
30
- href="#"
31
- title="Snippet"
28
+ <div
29
+ class="memori-media-item--snippet-direct"
32
30
  >
33
31
  <div
34
- class="memori-card memori-media-item--card memori-media-item--snippet memori-card--hoverable"
32
+ class="memori-card memori-media-item--card memori-media-item--snippet"
35
33
  >
36
34
  <div
37
35
  class="memori-spin"
@@ -57,12 +55,46 @@ exports[`renders MediaItemWidget unchanged with css snippet to show 1`] = `
57
55
  >
58
56
  <code
59
57
  class="language-scss"
58
+ data-language="scss"
60
59
  >
61
60
  body{
62
61
  background-color: #f00;
63
62
  }
64
63
  </code>
65
64
  </pre>
65
+ <button
66
+ class="memori-button memori-button--ghost memori-button--rounded memori-button--icon-only memori-snippet--copy-button"
67
+ title="copy"
68
+ >
69
+ <span
70
+ class="memori-button--icon"
71
+ >
72
+ <svg
73
+ aria-hidden="true"
74
+ fill="none"
75
+ focusable="false"
76
+ role="img"
77
+ stroke="currentColor"
78
+ stroke-linecap="round"
79
+ stroke-linejoin="round"
80
+ stroke-width="1.5"
81
+ viewBox="0 0 24 24"
82
+ xmlns="http://www.w3.org/2000/svg"
83
+ >
84
+ <rect
85
+ height="14"
86
+ rx="2"
87
+ ry="2"
88
+ width="14"
89
+ x="8"
90
+ y="8"
91
+ />
92
+ <path
93
+ d="M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2"
94
+ />
95
+ </svg>
96
+ </span>
97
+ </button>
66
98
  </div>
67
99
  <p
68
100
  class="memori-snippet--caption"
@@ -92,7 +124,7 @@ exports[`renders MediaItemWidget unchanged with css snippet to show 1`] = `
92
124
  </div>
93
125
  </div>
94
126
  </div>
95
- </a>
127
+ </div>
96
128
  </div>
97
129
  </div>
98
130
  </div>
@@ -280,13 +312,11 @@ exports[`renders MediaItemWidget unchanged with js snippet to show 1`] = `
280
312
  <div
281
313
  class="memori-media-item ease-out duration-500 delay-0 opacity-0 scale-95"
282
314
  >
283
- <a
284
- class="memori-media-item--link"
285
- href="#"
286
- title="Snippet"
315
+ <div
316
+ class="memori-media-item--snippet-direct"
287
317
  >
288
318
  <div
289
- class="memori-card memori-media-item--card memori-media-item--snippet memori-card--hoverable"
319
+ class="memori-card memori-media-item--card memori-media-item--snippet"
290
320
  >
291
321
  <div
292
322
  class="memori-spin"
@@ -312,10 +342,44 @@ exports[`renders MediaItemWidget unchanged with js snippet to show 1`] = `
312
342
  >
313
343
  <code
314
344
  class="language-jsx"
345
+ data-language="jsx"
315
346
  >
316
347
  console.log("Hello World!");
317
348
  </code>
318
349
  </pre>
350
+ <button
351
+ class="memori-button memori-button--ghost memori-button--rounded memori-button--icon-only memori-snippet--copy-button"
352
+ title="copy"
353
+ >
354
+ <span
355
+ class="memori-button--icon"
356
+ >
357
+ <svg
358
+ aria-hidden="true"
359
+ fill="none"
360
+ focusable="false"
361
+ role="img"
362
+ stroke="currentColor"
363
+ stroke-linecap="round"
364
+ stroke-linejoin="round"
365
+ stroke-width="1.5"
366
+ viewBox="0 0 24 24"
367
+ xmlns="http://www.w3.org/2000/svg"
368
+ >
369
+ <rect
370
+ height="14"
371
+ rx="2"
372
+ ry="2"
373
+ width="14"
374
+ x="8"
375
+ y="8"
376
+ />
377
+ <path
378
+ d="M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2"
379
+ />
380
+ </svg>
381
+ </span>
382
+ </button>
319
383
  </div>
320
384
  <p
321
385
  class="memori-snippet--caption"
@@ -345,7 +409,7 @@ exports[`renders MediaItemWidget unchanged with js snippet to show 1`] = `
345
409
  </div>
346
410
  </div>
347
411
  </div>
348
- </a>
412
+ </div>
349
413
  </div>
350
414
  </div>
351
415
  </div>