|
| 1 | +'use client' |
| 2 | + |
| 3 | +import { useState } from 'react' |
| 4 | + |
| 5 | +export function DiffControlsDemo() { |
| 6 | + const [rejectHover, setRejectHover] = useState(false) |
| 7 | + const [acceptHover, setAcceptHover] = useState(false) |
| 8 | + |
| 9 | + return ( |
| 10 | + <div style={{ display: 'flex', justifyContent: 'center', margin: '24px 0' }}> |
| 11 | + <div |
| 12 | + style={{ |
| 13 | + position: 'relative', |
| 14 | + display: 'flex', |
| 15 | + height: '30px', |
| 16 | + overflow: 'hidden', |
| 17 | + borderRadius: '4px', |
| 18 | + isolation: 'isolate', |
| 19 | + }} |
| 20 | + > |
| 21 | + {/* Reject button */} |
| 22 | + <button |
| 23 | + onClick={() => {}} |
| 24 | + onMouseEnter={() => setRejectHover(true)} |
| 25 | + onMouseLeave={() => setRejectHover(false)} |
| 26 | + title='Reject changes' |
| 27 | + style={{ |
| 28 | + position: 'relative', |
| 29 | + display: 'flex', |
| 30 | + height: '100%', |
| 31 | + alignItems: 'center', |
| 32 | + border: '1px solid #e0e0e0', |
| 33 | + backgroundColor: rejectHover ? '#f0f0f0' : '#f5f5f5', |
| 34 | + paddingRight: '20px', |
| 35 | + paddingLeft: '12px', |
| 36 | + fontWeight: 500, |
| 37 | + fontSize: '13px', |
| 38 | + color: rejectHover ? '#2d2d2d' : '#404040', |
| 39 | + clipPath: 'polygon(0 0, calc(100% + 10px) 0, 100% 100%, 0 100%)', |
| 40 | + borderRadius: '4px 0 0 4px', |
| 41 | + cursor: 'default', |
| 42 | + transition: 'color 150ms, background-color 150ms, border-color 150ms', |
| 43 | + }} |
| 44 | + > |
| 45 | + Reject |
| 46 | + </button> |
| 47 | + {/* Slanted divider - split gray/green */} |
| 48 | + <div |
| 49 | + style={{ |
| 50 | + pointerEvents: 'none', |
| 51 | + position: 'absolute', |
| 52 | + top: 0, |
| 53 | + bottom: 0, |
| 54 | + left: '66px', |
| 55 | + width: '2px', |
| 56 | + transform: 'skewX(-18.4deg)', |
| 57 | + background: 'linear-gradient(to right, #e0e0e0 50%, #238458 50%)', |
| 58 | + zIndex: 10, |
| 59 | + }} |
| 60 | + /> |
| 61 | + {/* Accept button */} |
| 62 | + <button |
| 63 | + onClick={() => {}} |
| 64 | + onMouseEnter={() => setAcceptHover(true)} |
| 65 | + onMouseLeave={() => setAcceptHover(false)} |
| 66 | + title='Accept changes (⇧⌘⏎)' |
| 67 | + style={{ |
| 68 | + position: 'relative', |
| 69 | + display: 'flex', |
| 70 | + height: '100%', |
| 71 | + alignItems: 'center', |
| 72 | + border: '1px solid rgba(0, 0, 0, 0.15)', |
| 73 | + backgroundColor: '#32bd7e', |
| 74 | + paddingRight: '12px', |
| 75 | + paddingLeft: '20px', |
| 76 | + fontWeight: 500, |
| 77 | + fontSize: '13px', |
| 78 | + color: '#ffffff', |
| 79 | + clipPath: 'polygon(10px 0, 100% 0, 100% 100%, 0 100%)', |
| 80 | + borderRadius: '0 4px 4px 0', |
| 81 | + marginLeft: '-10px', |
| 82 | + cursor: 'default', |
| 83 | + filter: acceptHover ? 'brightness(1.1)' : undefined, |
| 84 | + transition: 'background-color 150ms, border-color 150ms', |
| 85 | + }} |
| 86 | + > |
| 87 | + Accept |
| 88 | + <kbd |
| 89 | + style={{ |
| 90 | + marginLeft: '8px', |
| 91 | + borderRadius: '4px', |
| 92 | + border: '1px solid rgba(255, 255, 255, 0.2)', |
| 93 | + backgroundColor: 'rgba(255, 255, 255, 0.1)', |
| 94 | + paddingLeft: '6px', |
| 95 | + paddingRight: '6px', |
| 96 | + paddingTop: '2px', |
| 97 | + paddingBottom: '2px', |
| 98 | + fontWeight: 500, |
| 99 | + fontFamily: |
| 100 | + 'ui-sans-serif, system-ui, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji"', |
| 101 | + fontSize: '10px', |
| 102 | + color: '#ffffff', |
| 103 | + }} |
| 104 | + > |
| 105 | + ⇧⌘<span style={{ display: 'inline-block', transform: 'translateY(-1px)' }}>⏎</span> |
| 106 | + </kbd> |
| 107 | + </button> |
| 108 | + </div> |
| 109 | + </div> |
| 110 | + ) |
| 111 | +} |
0 commit comments