-
Notifications
You must be signed in to change notification settings - Fork 40
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'dev' into feat/price-changes
- Loading branch information
Showing
147 changed files
with
3,067 additions
and
1,743 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"@talismn/balances": patch | ||
--- | ||
|
||
rename "direct staking" => "delegated staking" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"@talismn/util": patch | ||
--- | ||
|
||
added formatTokenDecimals util fn |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"@talismn/chaindata-provider": patch | ||
--- | ||
|
||
Update init data |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
111 changes: 111 additions & 0 deletions
111
apps/extension/src/@talisman/components/ScrollContainerDraggableHorizontal.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,111 @@ | ||
import { classNames } from "@talismn/util" | ||
import React, { MouseEvent, TouchEvent, useEffect, useRef, useState } from "react" | ||
|
||
type ScrollContainerDraggableHorizontalProps = { | ||
children?: React.ReactNode | ||
className?: string | ||
} | ||
|
||
export const ScrollContainerDraggableHorizontal = ({ | ||
children, | ||
className, | ||
}: ScrollContainerDraggableHorizontalProps) => { | ||
const containerRef = useRef<HTMLDivElement>(null) | ||
|
||
// State to track dragging | ||
const [isDragging, setIsDragging] = useState<boolean>(false) | ||
const [startPosition, setStartPosition] = useState<number>(0) | ||
const [scrollLeft, setScrollLeft] = useState<number>(0) | ||
|
||
// State to track if there's more content to the left or right | ||
const [more, setMore] = useState<{ left: boolean; right: boolean }>({ | ||
left: false, | ||
right: false, | ||
}) | ||
|
||
useEffect(() => { | ||
const scrollable = containerRef.current | ||
if (!scrollable) return | ||
|
||
const handleDetectScroll = () => { | ||
setMore({ | ||
left: scrollable.scrollLeft > 0, | ||
right: scrollable.scrollWidth - scrollable.scrollLeft > scrollable.clientWidth, | ||
}) | ||
} | ||
|
||
// Attach event listeners | ||
scrollable.addEventListener("scroll", handleDetectScroll) | ||
window.addEventListener("resize", handleDetectScroll) | ||
|
||
// Initial detection | ||
handleDetectScroll() | ||
|
||
// Fix for initial load when scrollWidth might not be calculated yet | ||
setTimeout(handleDetectScroll, 50) | ||
|
||
// Cleanup | ||
return () => { | ||
scrollable.removeEventListener("scroll", handleDetectScroll) | ||
window.removeEventListener("resize", handleDetectScroll) | ||
} | ||
}, []) | ||
|
||
const handleDragStart = (e: MouseEvent<HTMLDivElement> | TouchEvent<HTMLDivElement>) => { | ||
e.preventDefault() | ||
setIsDragging(true) | ||
containerRef.current?.classList.add("cursor-grabbing") | ||
const pageX = "touches" in e ? e.touches[0].pageX : e.pageX | ||
setStartPosition(pageX) | ||
setScrollLeft(containerRef.current?.scrollLeft || 0) | ||
} | ||
|
||
const handleDragEnd = () => { | ||
setIsDragging(false) | ||
containerRef.current?.classList.remove("cursor-grabbing") | ||
} | ||
|
||
const handleDragMove = (e: MouseEvent<HTMLDivElement> | TouchEvent<HTMLDivElement>) => { | ||
if (!isDragging) return | ||
e.preventDefault() | ||
const pageX = "touches" in e ? e.touches[0].pageX : e.pageX | ||
const distance = pageX - startPosition | ||
if (containerRef.current) { | ||
containerRef.current.scrollLeft = scrollLeft - distance | ||
} | ||
} | ||
|
||
return ( | ||
<div className="relative z-0 overflow-hidden"> | ||
{/* eslint-disable-next-line jsx-a11y/no-static-element-interactions */} | ||
<div | ||
ref={containerRef} | ||
className={classNames( | ||
"no-scrollbar flex cursor-grab select-none overflow-x-auto", | ||
className, | ||
)} | ||
onMouseDown={handleDragStart} | ||
onMouseUp={handleDragEnd} | ||
onMouseLeave={handleDragEnd} | ||
onMouseMove={handleDragMove} | ||
onTouchStart={handleDragStart} | ||
onTouchEnd={handleDragEnd} | ||
onTouchMove={handleDragMove} | ||
> | ||
{children} | ||
</div> | ||
{/* Left gradient overlay */} | ||
<div | ||
className={`pointer-events-none absolute left-0 top-0 h-full w-12 bg-gradient-to-r from-black to-transparent transition-opacity duration-300 ${ | ||
more.left ? "opacity-100" : "opacity-0" | ||
}`} | ||
></div> | ||
{/* Right gradient overlay */} | ||
<div | ||
className={`pointer-events-none absolute right-0 top-0 h-full w-12 bg-gradient-to-l from-black to-transparent transition-opacity duration-300 ${ | ||
more.right ? "opacity-100" : "opacity-0" | ||
}`} | ||
></div> | ||
</div> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.