forked from blockworks-foundation/mango-ui-v3
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into tradingview-order-lines
- Loading branch information
Showing
63 changed files
with
3,685 additions
and
1,735 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
import { FunctionComponent } from 'react' | ||
|
||
interface ButtonGroupProps { | ||
activeValue: string | ||
className?: string | ||
onChange: (x) => void | ||
unit?: string | ||
values: Array<string> | ||
} | ||
|
||
const ButtonGroup: FunctionComponent<ButtonGroupProps> = ({ | ||
activeValue, | ||
className, | ||
unit, | ||
values, | ||
onChange, | ||
}) => { | ||
return ( | ||
<div className="bg-th-bkg-3 rounded-md"> | ||
<div className="flex relative"> | ||
{activeValue ? ( | ||
<div | ||
className={`absolute bg-th-bkg-4 default-transition h-full left-0 top-0 rounded-md transform`} | ||
style={{ | ||
transform: `translateX(${ | ||
values.findIndex((v) => v === activeValue) * 100 | ||
}%)`, | ||
width: `${100 / values.length}%`, | ||
}} | ||
/> | ||
) : null} | ||
{values.map((v, i) => ( | ||
<button | ||
className={`${className} cursor-pointer default-transition font-normal px-2 py-1.5 relative rounded-md text-center text-xs w-1/2 | ||
${ | ||
v === activeValue | ||
? `text-th-primary` | ||
: `text-th-fgd-1 opacity-70 hover:opacity-100` | ||
} | ||
`} | ||
key={`${v}${i}`} | ||
onClick={() => onChange(v)} | ||
style={{ | ||
width: `${100 / values.length}%`, | ||
}} | ||
> | ||
{v} | ||
{unit} | ||
</button> | ||
))} | ||
</div> | ||
</div> | ||
) | ||
} | ||
|
||
export default ButtonGroup |
Oops, something went wrong.