-
Notifications
You must be signed in to change notification settings - Fork 73
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(ohlc): create toggle for ohlc on trade chart (#853)
- Loading branch information
1 parent
b4d9824
commit fa7e2b4
Showing
11 changed files
with
146 additions
and
48 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,8 @@ | ||
import { TOOLTIP_STRING_KEYS, type TooltipStrings } from '@/constants/localization'; | ||
|
||
export const tradeChartTooltips: TooltipStrings = { | ||
ohlc: ({ stringGetter }) => ({ | ||
title: stringGetter({ key: TOOLTIP_STRING_KEYS.OHLC_TITLE }), | ||
body: stringGetter({ key: TOOLTIP_STRING_KEYS.OHLC_BODY }), | ||
}), | ||
} as const; |
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,34 @@ | ||
import { useEffect, useState } from 'react'; | ||
|
||
/** | ||
* @description Hook to handle drawing candles with OHLC or orderbook price | ||
*/ | ||
|
||
export const useOhlcCandles = ({ | ||
ohlcToggle, | ||
isChartReady, | ||
}: { | ||
ohlcToggle: HTMLElement | null; | ||
isChartReady: boolean; | ||
}) => { | ||
const [useOhlc, setUseOhlc] = useState(true); | ||
|
||
useEffect(() => { | ||
// Initialize onClick for ohlc toggle | ||
if (isChartReady && ohlcToggle) { | ||
ohlcToggle.onclick = () => setUseOhlc((prev) => !prev); | ||
} | ||
}, [isChartReady, ohlcToggle]); | ||
|
||
useEffect( | ||
// Update ohlc button on toggle | ||
() => { | ||
if (useOhlc) { | ||
ohlcToggle?.classList?.add('ohlc-active'); | ||
} else { | ||
ohlcToggle?.classList?.remove('ohlc-active'); | ||
} | ||
}, | ||
[useOhlc, ohlcToggle?.classList] | ||
); | ||
}; |
Oops, something went wrong.