Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master' into revert-axis
Browse files Browse the repository at this point in the history
  • Loading branch information
alexfauquette committed Aug 29, 2024
2 parents 20fa35f + 113a612 commit 5789f2b
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 18 deletions.
2 changes: 1 addition & 1 deletion packages/x-charts/src/LineChart/MarkElement.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ function MarkElement(props: MarkElementProps) {
});
const { axis } = React.useContext(InteractionContext);

const position = useSpring({ x, y, immediate: skipAnimation });
const position = useSpring({ to: { x, y }, immediate: skipAnimation });
const ownerState = {
id,
classes: innerClasses,
Expand Down
45 changes: 29 additions & 16 deletions packages/x-charts/src/internals/useAnimatedPath.ts
Original file line number Diff line number Diff line change
@@ -1,29 +1,42 @@
import * as React from 'react';
import { interpolateString } from '@mui/x-charts-vendor/d3-interpolate';
import { useSpring, to } from '@react-spring/web';
import { useSpring } from '@react-spring/web';

function usePrevious<T>(value: T) {
const ref = React.useRef<T | null>(null);
React.useEffect(() => {
ref.current = value;
}, [value]);
const ref = React.useRef<{ currentPath: T; previousPath?: T }>({
currentPath: value,
previousPath: undefined,
});
if (ref.current.currentPath !== value) {
ref.current = {
currentPath: value,
previousPath: ref.current.currentPath,
};
}

return ref.current;
}

// Taken from Nivo
export const useAnimatedPath = (path: string, skipAnimation?: boolean) => {
const previousPath = usePrevious(path);
const memoryRef = usePrevious(path);

const interpolator = React.useMemo(
() => (previousPath ? interpolateString(previousPath, path) : () => path),
[previousPath, path],
() =>
memoryRef.previousPath
? interpolateString(memoryRef.previousPath, memoryRef.currentPath)
: () => memoryRef.currentPath,
[memoryRef.currentPath, memoryRef.previousPath],
);

const { value } = useSpring({
from: { value: 0 },
to: { value: 1 },
reset: true,
immediate: skipAnimation,
});
const [{ value }] = useSpring(
{
from: { value: 0 },
to: { value: 1 },
reset: true,
immediate: skipAnimation,
},
[memoryRef.currentPath],
);

return to([value], interpolator);
return value.to(interpolator);
};
6 changes: 5 additions & 1 deletion scripts/githubActions/orderIdValidation.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,15 @@ module.exports = async ({ core, context, github }) => {
} else {
const order = await fetch(`${orderApi}${orderId}`, {
headers: {
Authorization: orderApiToken,
Authorization: `Basic ${orderApiToken}`,
'User-Agent': 'MUI-Tools-Private/X-Orders-Inspector v1',
},
});

if (!order.ok) {
core.info(`Request to ${orderApi} failed. Response status code: ${order.status}.`);
}

const orderDetails = await order.json();

core.debug(`>>> Order Items: ${orderDetails.line_items?.join(',')}`);
Expand Down

0 comments on commit 5789f2b

Please sign in to comment.