Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add startViewTransition support #10916

Merged
merged 43 commits into from
Oct 11, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
0d5dd29
POC support for startViewTransition
brophdawg11 Mar 9, 2023
069b77f
Add example using startViwTransition
brophdawg11 Jul 14, 2023
9d6f330
Update dep
brophdawg11 Aug 22, 2023
cbd6aad
Update approach and add future flags
brophdawg11 Aug 29, 2023
b774db3
Rename future flag
brophdawg11 Aug 29, 2023
dbac4b1
Updates
brophdawg11 Aug 30, 2023
560a894
Switch to useViewTransition hook
brophdawg11 Sep 19, 2023
d4087e9
Add more updates - proxy through Link
brophdawg11 Sep 20, 2023
c383e8f
Add unstable prefix
brophdawg11 Sep 20, 2023
48303d0
Revert "Add unstable prefix"
brophdawg11 Sep 20, 2023
449d51e
Remove viewTransition API from router.navigate
brophdawg11 Sep 20, 2023
c1dee37
Rename useViewTransitions
brophdawg11 Sep 20, 2023
f516ded
Allow return false
brophdawg11 Sep 20, 2023
f800892
POC
brophdawg11 Sep 22, 2023
adf0b78
Get POP navigations working
brophdawg11 Sep 25, 2023
d8bafcd
Lift viewTransition function execution up to router
brophdawg11 Sep 25, 2023
18cc33b
Handle forward pops
brophdawg11 Sep 25, 2023
27f65c1
Updates
brophdawg11 Sep 26, 2023
9fcf8df
Update approch to use prop and hook together
brophdawg11 Sep 28, 2023
7d6a724
Remove currentLocation from ViewTransitionContext
brophdawg11 Sep 28, 2023
5768b76
Fix image freeze on detail->home
brophdawg11 Sep 28, 2023
e43453e
Remove defer value param
brophdawg11 Sep 28, 2023
f456698
Remove usage of fallbackOnDeferRevalidation
brophdawg11 Sep 28, 2023
2359232
Remove fallbackOnDeferRevalidation flag
brophdawg11 Sep 28, 2023
360206f
Remove debug logs
brophdawg11 Sep 28, 2023
15961e1
Clean ups
brophdawg11 Sep 28, 2023
2f716d3
Revert "Remove debug logs"
brophdawg11 Sep 28, 2023
dda9693
Add interruption handling
brophdawg11 Sep 29, 2023
7263d4a
Remove debug logs
brophdawg11 Sep 29, 2023
098efb7
Remove unused flushSync
brophdawg11 Sep 29, 2023
b9f0c8a
Persist applied transitions to sessionStorage
brophdawg11 Sep 29, 2023
3912731
Add docs
brophdawg11 Oct 2, 2023
4a8a492
Handle basename and PUSH navs that reverse a transition
brophdawg11 Oct 4, 2023
7383054
Udpate docs with example
brophdawg11 Oct 4, 2023
d5e1a89
Udpate docs with example
brophdawg11 Oct 4, 2023
35c4680
Add changeset
brophdawg11 Oct 4, 2023
1e8dcaa
Only leverage useViewTransitionState in DataRouter NavLink usages
brophdawg11 Oct 5, 2023
6ddc868
Fix tests
brophdawg11 Oct 11, 2023
04857aa
Unit tests
brophdawg11 Oct 11, 2023
e687cac
Bump bundle
brophdawg11 Oct 11, 2023
34ace81
Bump bundle
brophdawg11 Oct 11, 2023
54298be
Update changeset
brophdawg11 Oct 11, 2023
f3db06f
Rename viewTransitionOpts -> unstable_viewTransitionOpts
brophdawg11 Oct 11, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add unstable prefix
  • Loading branch information
brophdawg11 committed Sep 28, 2023
commit c383e8f25f3f860e6c42be0bf27a7721744f48ef
2 changes: 1 addition & 1 deletion packages/react-router-dom/dom.ts
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ export interface SubmitOptions {
/**
* Allow submissions to enable view transitions
*/
viewTransition?: boolean | ViewTransitionFunction;
unstable_viewTransition?: boolean | ViewTransitionFunction;
}

const supportedFormEncTypes: Set<FormEncType> = new Set([
Expand Down
23 changes: 11 additions & 12 deletions packages/react-router-dom/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -503,7 +503,7 @@ export interface LinkProps
preventScrollReset?: boolean;
relative?: RelativeRoutingType;
to: To;
viewTransition?: boolean | ViewTransitionFunction;
unstable_viewTransition?: boolean | ViewTransitionFunction;
}

const isBrowser =
Expand All @@ -527,7 +527,7 @@ export const Link = React.forwardRef<HTMLAnchorElement, LinkProps>(
target,
to,
preventScrollReset,
viewTransition,
unstable_viewTransition,
...rest
},
ref
Expand Down Expand Up @@ -577,7 +577,7 @@ export const Link = React.forwardRef<HTMLAnchorElement, LinkProps>(
target,
preventScrollReset,
relative,
viewTransition,
unstable_viewTransition,
});
function handleClick(
event: React.MouseEvent<HTMLAnchorElement, MouseEvent>
Expand Down Expand Up @@ -787,7 +787,7 @@ export interface FormProps extends FetcherFormProps {
/**
* Boolean/function to enable/disable view transitions
*/
viewTransition?: boolean | ViewTransitionFunction;
unstable_viewTransition?: boolean | ViewTransitionFunction;
}

/**
Expand Down Expand Up @@ -831,7 +831,7 @@ const FormImpl = React.forwardRef<HTMLFormElement, FormImplProps>(
submit,
relative,
preventScrollReset,
viewTransition,
unstable_viewTransition,
...props
},
forwardedRef
Expand All @@ -857,7 +857,7 @@ const FormImpl = React.forwardRef<HTMLFormElement, FormImplProps>(
state,
relative,
preventScrollReset,
viewTransition,
unstable_viewTransition,
});
};

Expand Down Expand Up @@ -947,14 +947,14 @@ export function useLinkClickHandler<E extends Element = HTMLAnchorElement>(
state,
preventScrollReset,
relative,
viewTransition,
unstable_viewTransition,
}: {
target?: React.HTMLAttributeAnchorTarget;
replace?: boolean;
state?: any;
preventScrollReset?: boolean;
relative?: RelativeRoutingType;
viewTransition?: boolean | ViewTransitionFunction;
unstable_viewTransition?: boolean | ViewTransitionFunction;
} = {}
): (event: React.MouseEvent<E, MouseEvent>) => void {
let navigate = useNavigate();
Expand All @@ -973,13 +973,12 @@ export function useLinkClickHandler<E extends Element = HTMLAnchorElement>(
? replaceProp
: createPath(location) === createPath(path);

debugger;
navigate(to, {
replace,
state,
preventScrollReset,
relative,
viewTransition,
unstable_viewTransition,
});
}
},
Expand All @@ -993,7 +992,7 @@ export function useLinkClickHandler<E extends Element = HTMLAnchorElement>(
to,
preventScrollReset,
relative,
viewTransition,
unstable_viewTransition,
]
);
}
Expand Down Expand Up @@ -1118,7 +1117,7 @@ export function useSubmit(): SubmitFunction {

router.navigate(options.action || action, {
preventScrollReset: options.preventScrollReset,
viewTransition: options.viewTransition,
unstable_viewTransition: options.unstable_viewTransition,
formData,
body,
formMethod: options.method || (method as HTMLFormMethod),
Expand Down
2 changes: 1 addition & 1 deletion packages/react-router/lib/context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ export interface NavigateOptions {
state?: any;
preventScrollReset?: boolean;
relative?: RelativeRoutingType;
viewTransition?: boolean | ViewTransitionFunction;
unstable_viewTransition?: boolean | ViewTransitionFunction;
}

/**
Expand Down
1 change: 0 additions & 1 deletion packages/react-router/lib/hooks.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import type {
RevalidationState,
To,
UIMatch,
ViewTransitionFunction,
} from "@remix-run/router";
import {
IDLE_BLOCKER,
Expand Down
12 changes: 6 additions & 6 deletions packages/router/router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,7 @@ export interface RouterInit {
mapRouteProperties?: MapRoutePropertiesFunction;
future?: Partial<FutureConfig>;
hydrationData?: HydrationState;
viewTransition?: ViewTransitionFunction;
unstable_viewTransition?: ViewTransitionFunction;
window?: Window;
}

Expand Down Expand Up @@ -454,7 +454,7 @@ type BaseNavigateOptions = BaseNavigateOrFetchOptions & {
replace?: boolean;
state?: any;
fromRouteId?: string;
viewTransition?: boolean | ViewTransitionFunction;
unstable_viewTransition?: boolean | ViewTransitionFunction;
};

// Only allowed for submission navigations
Expand Down Expand Up @@ -1244,7 +1244,7 @@ export function createRouter(init: RouterInit): Router {
pendingError: error,
preventScrollReset,
replace: opts && opts.replace,
viewTransition: opts && opts.viewTransition,
unstable_viewTransition: opts && opts.unstable_viewTransition,
});
}

Expand Down Expand Up @@ -1294,7 +1294,7 @@ export function createRouter(init: RouterInit): Router {
pendingError?: ErrorResponseImpl;
startUninterruptedRevalidation?: boolean;
preventScrollReset?: boolean;
viewTransition?: boolean | ViewTransitionFunction;
unstable_viewTransition?: boolean | ViewTransitionFunction;
replace?: boolean;
}
): Promise<void> {
Expand All @@ -1313,8 +1313,8 @@ export function createRouter(init: RouterInit): Router {
pendingPreventScrollReset = (opts && opts.preventScrollReset) === true;

pendingNavigationViewTransition =
opts && typeof opts.viewTransition !== "undefined"
? opts?.viewTransition
opts && opts.unstable_viewTransition != null
? opts.unstable_viewTransition
: null;

let routesToUse = inFlightDataRoutes || dataRoutes;
Expand Down