Skip to content

Commit

Permalink
feat: added prefetch to links
Browse files Browse the repository at this point in the history
  • Loading branch information
jacob-ebey committed Jan 6, 2022
1 parent b3847b0 commit b626326
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 16 deletions.
2 changes: 1 addition & 1 deletion app/components/cta-banner.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export function CtaBanner({
<div className="flex-1 mt-3 lg:ml-8">
<p className="text-xl font-light mb-4">{description}</p>
<p>
<Link className="group inline-flex items-center" to={ctaTo}>
<Link className="group inline-flex items-center" prefetch="intent" to={ctaTo}>
<span className="text-xl font-semibold group-focus:underline group-hover:underline focus:underline hover:underline">
{ctaText}
</span>
Expand Down
2 changes: 1 addition & 1 deletion app/components/footer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export function Footer({
<li key={page.id}>
<Link
className="focus:text-gray-300 hover:text-gray-300"
to={page.to}
prefetch="intent" to={page.to}
>
{page.title}
</Link>
Expand Down
10 changes: 5 additions & 5 deletions app/components/navbar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export function Navbar({
<nav className="p-4 lg:px-6 border-b border-zinc-700">
<div className="flex">
<div className="flex items-center flex-1">
<Link to={`/${lang}`}>
<Link prefetch="intent" to={`/${lang}`}>
{translations ? (
<span className="sr-only">{translations.Home}</span>
) : null}
Expand Down Expand Up @@ -80,7 +80,7 @@ export function Navbar({
<li key={category.name + "|" + i} className="mx-2">
<Link
className="whitespace-nowrap hover:text-gray-300"
to={category.to}
prefetch="intent" to={category.to}
>
{category.name}
</Link>
Expand All @@ -100,7 +100,7 @@ export function Navbar({
</div>
<div className="flex items-center">
<Link
to={`/${lang}/cart`}
prefetch="intent" to={`/${lang}/cart`}
className="group relative inline-block hover:text-gray-300 ml-4"
onClick={(event) => {
event.preventDefault();
Expand All @@ -121,7 +121,7 @@ export function Navbar({
)}
</Link>
<Link
to={`/${lang}/wishlist`}
prefetch="intent" to={`/${lang}/wishlist`}
className="hover:text-gray-300 ml-4"
onClick={(event) => {
event.preventDefault();
Expand Down Expand Up @@ -182,7 +182,7 @@ export function Navbar({
<Link
onClick={() => close()}
className="text-xl text-blue-400 hover:text-blue-500"
to={category.to}
prefetch="intent" to={category.to}
>
{category.name}
</Link>
Expand Down
6 changes: 3 additions & 3 deletions app/components/scrolling-product-list.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ function ScrollingProductItem({
return (
<li className="lg:pr-12 relative">
<Link
to={to}
prefetch="intent" to={to}
className="group block aspect-square overflow-hidden w-screen max-w-sm"
tabIndex={disabled ? -1 : undefined}
>
Expand Down Expand Up @@ -65,7 +65,7 @@ export function ScrollingProductList({
key={product.id}
image={product.image}
title={product.title}
to={product.to}
prefetch="intent" to={product.to}
/>
)),
[products]
Expand All @@ -80,7 +80,7 @@ export function ScrollingProductList({
key={product.id}
image={product.image}
title={product.title}
to={product.to}
prefetch="intent" to={product.to}
disabled
/>
)),
Expand Down
4 changes: 2 additions & 2 deletions app/components/three-product-grid.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ function ThreeProductGridItem({
backgroundColor
)}
>
<Link className="block group" to={product.to} aria-labelledby={id}>
<Link className="block group" prefetch="intent" to={product.to} aria-labelledby={id}>
<OptimizedImage
className="object-cover w-full h-full transform transition duration-500 motion-safe:group-focus:scale-110 motion-safe:group-hover:scale-110"
src={product.image}
Expand Down Expand Up @@ -87,7 +87,7 @@ function ThreeProductGridItem({
<div className="absolute top-0 left-0 right-0">
<div className="flex">
<Link
to={product.to}
prefetch="intent" to={product.to}
className="group-tpgi block flex-1"
tabIndex={-1}
id={id}
Expand Down
8 changes: 4 additions & 4 deletions app/containers/cdp/cdp.component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ function ThreeProductGridItem({ product }: { product: CDPProduct }) {
return (
<li key={product.id}>
<div className="group block relative aspect-square overflow-hidden bg-zinc-800">
<Link className="block group" to={product.to} aria-labelledby={id}>
<Link className="block group" prefetch="intent" to={product.to} aria-labelledby={id}>
<OptimizedImage
className="object-cover w-full h-full transform transition duration-500 motion-safe:group-focus:scale-110 motion-safe:group-hover:scale-110"
src={product.image}
Expand All @@ -40,7 +40,7 @@ function ThreeProductGridItem({ product }: { product: CDPProduct }) {
<div className="absolute top-0 left-0 right-0">
<div className="flex">
<Link
to={product.to}
prefetch="intent" to={product.to}
className="group-tpgi block flex-1"
tabIndex={-1}
id={id}
Expand Down Expand Up @@ -105,7 +105,7 @@ export default function CDP() {
<Link
aria-selected={cat.slug !== category}
className="focus:underline hover:underline whitespace-nowrap"
to={(() => {
prefetch="intent" to={(() => {
let params = new URLSearchParams(location.search);
params.delete("q");
params.set("category", cat.slug);
Expand All @@ -131,7 +131,7 @@ export default function CDP() {
<Link
aria-selected={sortBy.value !== sort}
className="focus:underline hover:underline whitespace-nowrap"
to={(() => {
prefetch="intent" to={(() => {
let params = new URLSearchParams(location.search);
params.set("sort", sortBy.value);
return location.pathname + "?" + params.toString();
Expand Down

0 comments on commit b626326

Please sign in to comment.