docs: fix client error for learning path (#10102)

This commit is contained in:
Shahed Nasser
2024-11-14 16:53:24 +02:00
committed by GitHub
parent 2e5fd9fd71
commit 273960f6e3
7 changed files with 83 additions and 82 deletions
@@ -84,7 +84,12 @@ const Section = ({ title, links }: SectionProps) => {
<div className="flex flex-col gap-0.5 flex-1"> <div className="flex flex-col gap-0.5 flex-1">
<h3 className="text-h3 text-medusa-fg-base">{title}</h3> <h3 className="text-h3 text-medusa-fg-base">{title}</h3>
{links.map((link, index) => ( {links.map((link, index) => (
<Link key={index} className="text-compact-small-plus" href={link.href}> <Link
key={index}
className="text-compact-small-plus"
href={link.href}
prefetch={false}
>
{link.text} {link.text}
</Link> </Link>
))} ))}
+1 -1
View File
@@ -32,7 +32,7 @@ const Providers = ({ children }: ProvidersProps) => {
<HooksLoader <HooksLoader
options={{ options={{
pageScrollManager: true, pageScrollManager: true,
currentLearningPath: true, currentLearningPath: false,
}} }}
> >
{children} {children}
@@ -68,6 +68,7 @@ export const CardDefaultLayout = ({
<Link <Link
href={href} href={href}
className="absolute left-0 top-0 h-full w-full rounded" className="absolute left-0 top-0 h-full w-full rounded"
prefetch={false}
/> />
)} )}
</div> </div>
@@ -61,6 +61,7 @@ export const CardLargeLayout = ({
<Link <Link
href={href} href={href}
className="absolute left-0 top-0 h-full w-full rounded" className="absolute left-0 top-0 h-full w-full rounded"
prefetch={false}
/> />
)} )}
</div> </div>
@@ -89,7 +89,11 @@ export const CardLayoutMini = ({
{isExternal ? <ArrowUpRightOnBox /> : <TriangleRightMini />} {isExternal ? <ArrowUpRightOnBox /> : <TriangleRightMini />}
</span> </span>
{href && ( {href && (
<Link href={href} className="absolute left-0 top-0 w-full h-full" /> <Link
href={href}
className="absolute left-0 top-0 w-full h-full"
prefetch={false}
/>
)} )}
</div> </div>
</div> </div>
@@ -1,6 +1,10 @@
"use client"
import clsx from "clsx" import clsx from "clsx"
import React, { Children, ReactElement } from "react" import React, { Children, ReactElement, useRef } from "react"
import { NotificationItemLayoutDefault } from "./Layout/Default" import { NotificationItemLayoutDefault } from "./Layout/Default"
// @ts-expect-error can't install the types package because it doesn't support React v19
import { CSSTransition } from "react-transition-group"
export type NotificationItemProps = { export type NotificationItemProps = {
layout?: "default" | "empty" layout?: "default" | "empty"
@@ -16,17 +20,14 @@ export type NotificationItemProps = {
setShow?: (value: boolean) => void setShow?: (value: boolean) => void
onClose?: () => void onClose?: () => void
closeButtonText?: string closeButtonText?: string
passRef?: React.RefObject<HTMLDivElement>
} & React.HTMLAttributes<HTMLDivElement> } & React.HTMLAttributes<HTMLDivElement>
type EmptyLayoutProps = { type EmptyLayoutProps = {
onClose?: () => void onClose?: () => void
} }
export const NotificationItem = React.forwardRef< export const NotificationItem = ({
HTMLDivElement,
NotificationItemProps
>(function NotificationItem(
{
className = "", className = "",
placement = "bottom", placement = "bottom",
show = true, show = true,
@@ -35,15 +36,22 @@ export const NotificationItem = React.forwardRef<
onClose, onClose,
children, children,
...rest ...rest
}, }: NotificationItemProps) => {
ref const ref = useRef<HTMLDivElement>(null)
) {
const handleClose = () => { const handleClose = () => {
setShow?.(false) setShow?.(false)
onClose?.() onClose?.()
} }
return ( return (
<CSSTransition
timeout={200}
classNames={{
enter: "animate-slideInRight animate-fast",
exit: "animate-slideOutRight animate-fast",
}}
nodeRef={ref}
>
<div <div
className={clsx( className={clsx(
"md:max-w-[320px] md:w-[320px] w-full", "md:max-w-[320px] md:w-[320px] w-full",
@@ -76,5 +84,6 @@ export const NotificationItem = React.forwardRef<
} }
})} })}
</div> </div>
</CSSTransition>
) )
}) }
@@ -5,25 +5,16 @@ import {
NotificationItemType, NotificationItemType,
useNotifications, useNotifications,
} from "@/providers" } from "@/providers"
import React, { useEffect, useRef } from "react" import React from "react"
import { NotificationItem } from "./Item" import { NotificationItem } from "./Item"
// @ts-expect-error can't install the types package because it doesn't support React v19 // @ts-expect-error can't install the types package because it doesn't support React v19
import { CSSTransition, TransitionGroup } from "react-transition-group" import { TransitionGroup } from "react-transition-group"
import clsx from "clsx" import clsx from "clsx"
export const NotificationContainer = () => { export const NotificationContainer = () => {
const { notifications, removeNotification } = const { notifications, removeNotification } =
useNotifications() as NotificationContextType useNotifications() as NotificationContextType
const notificationRefs = useRef([])
useEffect(() => {
notificationRefs.current = notificationRefs.current.slice(
0,
notifications.length
)
}, [notifications])
const handleClose = (notification: NotificationItemType) => { const handleClose = (notification: NotificationItemType) => {
notification.onClose?.() notification.onClose?.()
if (notification.id) { if (notification.id) {
@@ -45,26 +36,16 @@ export const NotificationContainer = () => {
className className
)} )}
> >
{notifications.filter(condition).map((notification, index) => ( {notifications.filter(condition).map((notification) => (
<CSSTransition
key={notification.id}
timeout={200}
classNames={{
enter: "animate-slideInRight animate-fast",
exit: "animate-slideOutRight animate-fast",
}}
nodeRef={notificationRefs.current[index]}
>
<NotificationItem <NotificationItem
{...notification} {...notification}
onClose={() => handleClose(notification)} onClose={() => handleClose(notification)}
ref={notificationRefs.current[index]}
className={clsx( className={clsx(
notification.className, notification.className,
"!relative !top-0 !bottom-0 !right-0" "!relative !top-0 !bottom-0 !right-0"
)} )}
key={notification.id}
/> />
</CSSTransition>
))} ))}
</TransitionGroup> </TransitionGroup>
) )