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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
|
---
interface Props {
class?: string;
}
const { class: className } = Astro.props;
---
<figure class:list={['diff relative grid w-full overflow-hidden select-none', className]} tabindex="0">
<div class="relative col-start-1 row-start-1 overflow-hidden border-r-2 z-1 border-r-white diff-item-1">
<slot name="item-1" />
</div>
<div class="relative col-start-1 row-start-1 diff-item-2" tabindex="0">
<slot name="item-2" />
</div>
<div class="relative h-2 col-start-1 row-start-1 overflow-hidden opacity-0 resize-x diff-resizer z-1 min-w-4 cursor-ew-resize top-1/2"></div>
</figure>
<style>
.diff {
direction: ltr;
container-type: inline-size;
grid-template-columns: auto 1fr;
&:focus-visible,
&:has(.diff-item-1:focus),
&:has(.diff-item-2:focus) {
outline: 2px solid var(--color-gray-400);
outline-offset: 1px;
}
&:focus-visible {
.diff-resizer {
min-width: 80cqi;
max-width: 80cqi;
}
}
&:has(.diff-item-2:focus) {
.diff-resizer {
min-width: 20cqi;
max-width: 20cqi;
}
}
}
.diff-resizer {
width: 50cqi;
max-width: calc(100cqi - 1rem);
transform: scaleY(3) translate(0.35rem, 0.08rem);
transform-origin: 100% 100%;
clip-path: inset(calc(100% - 0.75rem) 0 0 calc(100% - 0.75rem));
transition:
min-width 0.3s ease-out,
max-width 0.3s ease-out;
}
.diff-item-2 {
&:after {
content: '';
width: 1.25rem;
height: 1.875rem;
position: absolute;
top: 50%;
right: 1px;
bottom: 0;
translate: 50% -50%;
background: color-mix(in oklab, var(--color-white) 50%, transparent);
border-radius: 9999px;
border: 2px solid var(--color-white);
backdrop-filter: blur(8px);
pointer-events: none;
z-index: 2;
box-shadow:
inset 0 0 0 1px color-mix(in oklab, var(--color-gray-900) 5%, transparent),
0 1px 3px 0 color-mix(in oklab, var(--color-gray-900) 20%, transparent);
}
@supports (-webkit-overflow-scrolling: touch) and (overflow: -webkit-paged-x) {
&:after {
content: none;
}
}
}
.diff-item-1,
.diff-item-2 {
> * {
height: 100%;
width: 100cqi;
position: absolute;
top: 0;
left: 0;
pointer-events: none;
}
}
</style>
|