Skip to content

Commit

Permalink
Merge branch 'develop' of https://github.com/CrocSwap/ambient-ts-app
Browse files Browse the repository at this point in the history
…into add-theme-switching
  • Loading branch information
emilydrakesmith committed Sep 30, 2024
2 parents c3dd01b + 2729fce commit a1ddbfe
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 15 deletions.
2 changes: 1 addition & 1 deletion src/pages/Chart/ChartSettings/ChartSettings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -702,7 +702,7 @@ export default function ChartSettings(props: ContextMenuIF) {
? 'var(--accent1)'
: 'var(--text1)'
}
width={'98px'}
width={'auto'}
onClick={() =>
handleApplyDefaults(defaultChartSettings)
}
Expand Down
6 changes: 3 additions & 3 deletions src/pages/Chart/ChartSettings/ChartSettingsCss.ts
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,7 @@ const FooterButtons = styled.div<{
gap: 10px;
border-radius: ${({ isFuta }) => (isFuta ? '0px' : '50px')};
max-width: 110px;
width: ${({ width }) => width};
height: 27px;
Expand All @@ -201,12 +202,11 @@ const FooterButtons = styled.div<{
`;

const FooterContextText = styled.div`
font-family: Lexend Deca;
font-size: 12px;
font-weight: 300;
font-size: var(--body-size);
line-height: 15px;
letter-spacing: -0.02em;
text-align: center;
text-wrap: nowrap;
`;

const Icon = styled.svg`
Expand Down
42 changes: 33 additions & 9 deletions src/pages/platformAmbient/Chart/Chart.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5520,15 +5520,39 @@ export default function Chart(props: propsIF) {
renderSubchartCrCanvas();
}, [crosshairActive]);

const setCrossHairDataFunc = (nearestTime: number, offsetY: number) => {
setCrosshairActive('chart');
const setCrossHairDataFunc = (
nearestTime: number,
offsetX: number,
offsetY: number,
) => {
if (scaleData) {
const snapDiff =
scaleData?.xScale.invert(offsetX) % (period * 1000);

const snappedTime =
scaleData?.xScale.invert(offsetX) -
(snapDiff > period * 1000 - snapDiff
? -1 * (period * 1000 - snapDiff)
: snapDiff);

const crTime =
snappedTime <= lastCandleData.time * 1000 &&
snappedTime >= firstCandleData.time * 1000 &&
nearestTime
? nearestTime * 1000
: snappedTime;

setCrosshairActive('chart');

setCrosshairData([
{
x: crTime,
y: scaleData?.yScale.invert(offsetY),
},
]);

setCrosshairData([
{
x: nearestTime,
y: scaleData?.yScale.invert(offsetY),
},
]);
return crTime;
}
};

const mousemove = (event: MouseEvent<HTMLDivElement>) => {
Expand All @@ -5543,7 +5567,7 @@ export default function Chart(props: propsIF) {
const { isHoverCandleOrVolumeData, nearest } =
candleOrVolumeDataHoverStatus(offsetX, offsetY);

setCrossHairDataFunc(nearest?.time * 1000, offsetY);
setCrossHairDataFunc(nearest?.time, offsetX, offsetY);

let isOrderHistorySelected = undefined;
if (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -582,7 +582,7 @@ export default function DragCanvas(props: DragCanvasProps) {
? valueX > scaleData.xScale.invert(offsetX)
: valueX < scaleData.xScale.invert(offsetX);

setCrossHairDataFunc(valueX, offsetY);
setCrossHairDataFunc(valueX,offsetX,offsetY);

if (
hoveredDrawnShape &&
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -507,7 +507,7 @@ function DrawCanvas(props: DrawCanvasProps) {
offsetY,
);

setCrossHairDataFunc(valueX, offsetY);
setCrossHairDataFunc(valueX / 1000, offsetX, offsetY);

if (!isDrawing || activeDrawingType === 'Ray') return;

Expand Down

0 comments on commit a1ddbfe

Please sign in to comment.