Commit 56b4ef4
Add ct-copy-button component (commontoolsinc#2081)
* Fix: Use derive instead of lift for reactive mentionable tracking
Issue: backlinks-index used lift() which computes once at initialization.
When allCharms was empty initially, mentionable stayed empty even after
charms were added.
Fix: Use derive(allCharms, ...) which reactively tracks when allCharms
changes and recomputes mentionable automatically.
This fixes the bug where [[ dropdown is empty until page refresh.
Fixes timing issue reported by Berni where fresh spaces need refresh for
mentions to work.
* Add ct-copy-button component
Implements a reusable copy-to-clipboard button component that:
- Composes ct-button internally for consistent styling
- Accepts text via the `text` attribute (supports Cell bindings)
- Provides automatic visual feedback (icon swap for 2 seconds)
- Fires ct-copy-success and ct-copy-error events
- Follows security model: patterns provide text, component handles DOM API
Component supports:
- All ct-button variants (primary, secondary, ghost, etc.)
- All ct-button sizes (sm, md, lg, icon, default)
- Icon-only mode for compact UIs
- Configurable feedback duration
- Full TypeScript type definitions
Usage:
```tsx
<ct-copy-button
text={ingredientListText}
variant="secondary"
size="sm"
icon-only
/>
```
🤖 Generated with [Claude Code](https://claude.com/claude-code)
via [Happy](https://happy.engineering)
Co-Authored-By: Claude <[email protected]>
Co-Authored-By: Happy <[email protected]>
* Fix ct-copy-button to properly handle Cell<string> bindings
The component now checks if text is a Cell and unwraps it using .get()
to avoid copying '[object Object]' when Cell bindings are passed.
- Import isCell and Cell type from @commontools/runner
- Add _getTextValue() helper to unwrap Cell values
- Update type declaration to accept string | Cell<string>
- Use _getTextValue() in _handleClick to get actual text value
Fixes cubic-dev-ai review comment on PR commontoolsinc#2081
Generated with [Claude Code](https://claude.ai/code)
via [Happy](https://happy.engineering)
Co-Authored-By: Claude <[email protected]>
Co-Authored-By: Happy <[email protected]>
* Action PR feedback
* Use `ct-copy-button` in `ct-chat-message`
* Lint + format
* Fix copy-button aspect ratio
* Remove reference to cell
* Format
---------
Co-authored-by: Claude <[email protected]>
Co-authored-by: Happy <[email protected]>
Co-authored-by: Ben Follington <[email protected]>1 parent d0f6527 commit 56b4ef4
File tree
7 files changed
+242
-104
lines changed- packages
- html/src
- patterns
- ui/src/v2
- components
- ct-chat-message
- ct-copy-button
7 files changed
+242
-104
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2875 | 2875 | | |
2876 | 2876 | | |
2877 | 2877 | | |
| 2878 | + | |
2878 | 2879 | | |
2879 | 2880 | | |
2880 | 2881 | | |
| |||
3075 | 3076 | | |
3076 | 3077 | | |
3077 | 3078 | | |
| 3079 | + | |
| 3080 | + | |
| 3081 | + | |
| 3082 | + | |
| 3083 | + | |
| 3084 | + | |
| 3085 | + | |
| 3086 | + | |
| 3087 | + | |
| 3088 | + | |
| 3089 | + | |
| 3090 | + | |
| 3091 | + | |
| 3092 | + | |
| 3093 | + | |
| 3094 | + | |
3078 | 3095 | | |
3079 | 3096 | | |
3080 | 3097 | | |
| |||
3759 | 3776 | | |
3760 | 3777 | | |
3761 | 3778 | | |
| 3779 | + | |
| 3780 | + | |
| 3781 | + | |
| 3782 | + | |
3762 | 3783 | | |
3763 | 3784 | | |
3764 | 3785 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | | - | |
| 2 | + | |
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
| |||
63 | 63 | | |
64 | 64 | | |
65 | 65 | | |
66 | | - | |
67 | | - | |
68 | | - | |
69 | | - | |
70 | | - | |
71 | | - | |
72 | | - | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
73 | 69 | | |
74 | 70 | | |
75 | 71 | | |
| |||
90 | 86 | | |
91 | 87 | | |
92 | 88 | | |
93 | | - | |
| 89 | + | |
94 | 90 | | |
95 | 91 | | |
96 | 92 | | |
| |||
Lines changed: 9 additions & 95 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
| 9 | + | |
9 | 10 | | |
10 | 11 | | |
11 | 12 | | |
| |||
373 | 374 | | |
374 | 375 | | |
375 | 376 | | |
376 | | - | |
377 | | - | |
378 | | - | |
379 | | - | |
380 | | - | |
381 | 377 | | |
382 | 378 | | |
383 | 379 | | |
| |||
407 | 403 | | |
408 | 404 | | |
409 | 405 | | |
410 | | - | |
411 | 406 | | |
412 | 407 | | |
413 | 408 | | |
414 | 409 | | |
415 | 410 | | |
416 | | - | |
| 411 | + | |
417 | 412 | | |
| 413 | + | |
418 | 414 | | |
419 | 415 | | |
420 | | - | |
421 | | - | |
422 | | - | |
423 | | - | |
424 | | - | |
425 | | - | |
| 416 | + | |
| 417 | + | |
426 | 418 | | |
427 | 419 | | |
428 | 420 | | |
| |||
443 | 435 | | |
444 | 436 | | |
445 | 437 | | |
446 | | - | |
447 | | - | |
448 | | - | |
449 | | - | |
450 | | - | |
451 | | - | |
452 | | - | |
453 | | - | |
454 | | - | |
455 | | - | |
456 | | - | |
457 | | - | |
458 | | - | |
459 | | - | |
460 | | - | |
461 | | - | |
462 | | - | |
463 | | - | |
464 | | - | |
465 | | - | |
466 | | - | |
467 | | - | |
468 | | - | |
469 | | - | |
470 | | - | |
471 | | - | |
472 | | - | |
473 | | - | |
474 | | - | |
475 | | - | |
476 | | - | |
477 | | - | |
478 | | - | |
479 | | - | |
480 | | - | |
481 | | - | |
482 | | - | |
483 | | - | |
484 | | - | |
485 | | - | |
486 | | - | |
487 | | - | |
488 | | - | |
489 | | - | |
490 | | - | |
491 | | - | |
492 | | - | |
493 | | - | |
494 | | - | |
495 | | - | |
496 | | - | |
497 | | - | |
498 | | - | |
499 | | - | |
500 | | - | |
501 | 438 | | |
502 | 439 | | |
503 | 440 | | |
| |||
579 | 516 | | |
580 | 517 | | |
581 | 518 | | |
582 | | - | |
| 519 | + | |
| 520 | + | |
583 | 521 | | |
584 | 522 | | |
585 | | - | |
586 | | - | |
587 | | - | |
588 | | - | |
589 | | - | |
| 523 | + | |
| 524 | + | |
590 | 525 | | |
591 | 526 | | |
592 | 527 | | |
| |||
610 | 545 | | |
611 | 546 | | |
612 | 547 | | |
613 | | - | |
614 | | - | |
615 | | - | |
616 | | - | |
617 | | - | |
618 | 548 | | |
619 | 549 | | |
620 | 550 | | |
621 | 551 | | |
622 | 552 | | |
623 | 553 | | |
624 | 554 | | |
625 | | - | |
626 | | - | |
627 | | - | |
628 | | - | |
629 | | - | |
630 | | - | |
631 | | - | |
632 | | - | |
633 | | - | |
634 | | - | |
635 | | - | |
636 | | - | |
637 | | - | |
638 | | - | |
639 | | - | |
640 | | - | |
641 | 555 | | |
642 | 556 | | |
643 | 557 | | |
| |||
Lines changed: 31 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
0 commit comments