Skip to content

Commit 2a86ad8

Browse files
committed
feat: alter capture list loader
1 parent d258204 commit 2a86ad8

File tree

1 file changed

+126
-15
lines changed

1 file changed

+126
-15
lines changed

src/components/browser/BrowserWindow.tsx

Lines changed: 126 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ export const BrowserWindow = () => {
166166
const [viewportInfo, setViewportInfo] = useState<ViewportInfo>({ width: browserWidth, height: browserHeight });
167167
const [isLoading, setIsLoading] = useState(false);
168168
const [cachedChildSelectors, setCachedChildSelectors] = useState<string[]>([]);
169-
169+
const [processingGroupCoordinates, setProcessingGroupCoordinates] = useState<Array<{ element: HTMLElement; rect: DOMRect }>>([]);
170170
const [listSelector, setListSelector] = useState<string | null>(null);
171171
const [fields, setFields] = useState<Record<string, TextStep>>({});
172172
const [paginationSelector, setPaginationSelector] = useState<string>('');
@@ -787,6 +787,15 @@ export const BrowserWindow = () => {
787787
!listSelector &&
788788
highlighterData.groupInfo?.isGroupElement
789789
) {
790+
if (highlighterData?.groupInfo.groupElements) {
791+
setProcessingGroupCoordinates(
792+
highlighterData.groupInfo.groupElements.map((element) => ({
793+
element,
794+
rect: element.getBoundingClientRect(),
795+
}))
796+
);
797+
}
798+
790799
let cleanedSelector = highlighterData.selector;
791800

792801
setListSelector(cleanedSelector);
@@ -1503,6 +1512,8 @@ export const BrowserWindow = () => {
15031512

15041513
{/* Loading overlay positioned specifically over DOM content */}
15051514
{isCachingChildSelectors && (
1515+
<>
1516+
{/* Background overlay */}
15061517
<div
15071518
style={{
15081519
position: "absolute",
@@ -1511,26 +1522,126 @@ export const BrowserWindow = () => {
15111522
width: "100%",
15121523
height: "100%",
15131524
background: "rgba(255, 255, 255, 0.8)",
1514-
display: "flex",
1515-
alignItems: "center",
1516-
justifyContent: "center",
15171525
zIndex: 9999,
15181526
pointerEvents: "none",
1519-
borderRadius: "0px 0px 5px 5px", // Match the DOM renderer border radius
1527+
borderRadius: "0px 0px 5px 5px",
15201528
}}
1521-
>
1529+
/>
1530+
1531+
{/* Use processing coordinates captured before listSelector was set */}
1532+
{processingGroupCoordinates.map((groupElement, index) => (
1533+
<React.Fragment key={`group-highlight-${index}`}>
1534+
{/* Original highlight box */}
1535+
<div
1536+
style={{
1537+
position: "absolute",
1538+
left: groupElement.rect.x,
1539+
top: groupElement.rect.y,
1540+
width: groupElement.rect.width,
1541+
height: groupElement.rect.height,
1542+
background: "rgba(255, 0, 195, 0.15)",
1543+
border: "2px dashed #ff00c3",
1544+
borderRadius: "3px",
1545+
pointerEvents: "none",
1546+
zIndex: 10000,
1547+
boxShadow: "0 0 0 1px rgba(255, 255, 255, 0.8)",
1548+
transition: "all 0.1s ease-out",
1549+
}}
1550+
/>
1551+
1552+
{/* Label */}
1553+
<div
1554+
style={{
1555+
position: "absolute",
1556+
left: groupElement.rect.x,
1557+
top: groupElement.rect.y - 20,
1558+
background: "#ff00c3",
1559+
color: "white",
1560+
padding: "2px 6px",
1561+
fontSize: "10px",
1562+
fontWeight: "bold",
1563+
borderRadius: "2px",
1564+
pointerEvents: "none",
1565+
zIndex: 10001,
1566+
whiteSpace: "nowrap",
1567+
}}
1568+
>
1569+
List item {index + 1}
1570+
</div>
1571+
1572+
{/* Scanning animation */}
1573+
<div
1574+
style={{
1575+
position: "absolute",
1576+
left: groupElement.rect.x,
1577+
top: groupElement.rect.y,
1578+
width: groupElement.rect.width,
1579+
height: groupElement.rect.height,
1580+
overflow: "hidden",
1581+
zIndex: 10002,
1582+
pointerEvents: "none",
1583+
borderRadius: "3px",
1584+
}}
1585+
>
1586+
<div
1587+
style={{
1588+
position: "absolute",
1589+
left: 0,
1590+
width: "100%",
1591+
height: "8px",
1592+
background:
1593+
"linear-gradient(90deg, transparent 0%, rgba(255, 0, 195, 0.6) 50%, transparent 100%)",
1594+
animation: `scanDown-${index} 2s ease-in-out infinite`,
1595+
willChange: "transform",
1596+
}}
1597+
/>
1598+
</div>
1599+
1600+
<style>{`
1601+
@keyframes scanDown-${index} {
1602+
0% {
1603+
transform: translateY(-8px);
1604+
}
1605+
100% {
1606+
transform: translateY(${groupElement.rect.height}px);
1607+
}
1608+
}
1609+
`}</style>
1610+
</React.Fragment>
1611+
))}
1612+
1613+
{/* Fallback loader */}
1614+
{processingGroupCoordinates.length === 0 && (
15221615
<div
15231616
style={{
1524-
width: "40px",
1525-
height: "40px",
1526-
border: "4px solid #f3f3f3",
1527-
borderTop: "4px solid #ff00c3",
1528-
borderRadius: "50%",
1529-
animation: "spin 1s linear infinite",
1617+
position: "absolute",
1618+
top: 0,
1619+
left: 0,
1620+
width: "100%",
1621+
height: "100%",
1622+
background: "rgba(255, 255, 255, 0.8)",
1623+
display: "flex",
1624+
alignItems: "center",
1625+
justifyContent: "center",
1626+
zIndex: 9999,
1627+
pointerEvents: "none",
1628+
borderRadius: "0px 0px 5px 5px",
15301629
}}
1531-
/>
1532-
</div>
1533-
)}
1630+
>
1631+
<div
1632+
style={{
1633+
width: "40px",
1634+
height: "40px",
1635+
border: "4px solid #f3f3f3",
1636+
borderTop: "4px solid #ff00c3",
1637+
borderRadius: "50%",
1638+
animation: "spin 1s linear infinite",
1639+
}}
1640+
/>
1641+
</div>
1642+
)}
1643+
</>
1644+
)}
15341645
</div>
15351646
) : (
15361647
/* Screenshot mode canvas */

0 commit comments

Comments
 (0)