docs: redesign pagination (#8614)
This commit is contained in:
@@ -4,14 +4,16 @@ import clsx from "clsx"
|
|||||||
import React from "react"
|
import React from "react"
|
||||||
import { MainNavigationDropdown } from "./NavigationDropdown"
|
import { MainNavigationDropdown } from "./NavigationDropdown"
|
||||||
import { MainNavBreadcrumbs } from "./Breadcrumb"
|
import { MainNavBreadcrumbs } from "./Breadcrumb"
|
||||||
import { SearchModalOpener, useMainNav } from "../.."
|
import { Button, SearchModalOpener, useMainNav, useSidebar } from "../.."
|
||||||
import { MainNavColorMode } from "./ColorMode"
|
import { MainNavColorMode } from "./ColorMode"
|
||||||
import Link from "next/link"
|
import Link from "next/link"
|
||||||
import { MainNavDivider } from "./Divider"
|
import { MainNavDivider } from "./Divider"
|
||||||
import { MainNavSidebarOpener } from "./SidebarOpener"
|
import { MainNavSidebarOpener } from "./SidebarOpener"
|
||||||
|
import { SidebarLeftIcon } from "../Icons/SidebarLeft"
|
||||||
|
|
||||||
export const MainNav = () => {
|
export const MainNav = () => {
|
||||||
const { reportIssueLink } = useMainNav()
|
const { reportIssueLink } = useMainNav()
|
||||||
|
const { setMobileSidebarOpen } = useSidebar()
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
className={clsx(
|
className={clsx(
|
||||||
@@ -21,6 +23,13 @@ export const MainNav = () => {
|
|||||||
)}
|
)}
|
||||||
>
|
>
|
||||||
<div className="flex items-center gap-docs_0.25">
|
<div className="flex items-center gap-docs_0.25">
|
||||||
|
<Button
|
||||||
|
className="lg:hidden"
|
||||||
|
variant="transparent-clear"
|
||||||
|
onClick={() => setMobileSidebarOpen(true)}
|
||||||
|
>
|
||||||
|
<SidebarLeftIcon />
|
||||||
|
</Button>
|
||||||
<MainNavSidebarOpener />
|
<MainNavSidebarOpener />
|
||||||
<MainNavigationDropdown />
|
<MainNavigationDropdown />
|
||||||
<MainNavBreadcrumbs />
|
<MainNavBreadcrumbs />
|
||||||
|
|||||||
@@ -0,0 +1,57 @@
|
|||||||
|
import { TriangleLeftMini, TriangleRightMini } from "@medusajs/icons"
|
||||||
|
import clsx from "clsx"
|
||||||
|
import Link from "next/link"
|
||||||
|
import React from "react"
|
||||||
|
|
||||||
|
type PaginationCardProps = {
|
||||||
|
type: "previous" | "next"
|
||||||
|
title: string
|
||||||
|
parentTitle?: string
|
||||||
|
link: string
|
||||||
|
className?: string
|
||||||
|
}
|
||||||
|
|
||||||
|
export const PaginationCard = ({
|
||||||
|
type,
|
||||||
|
title,
|
||||||
|
parentTitle,
|
||||||
|
link,
|
||||||
|
className,
|
||||||
|
}: PaginationCardProps) => {
|
||||||
|
return (
|
||||||
|
<div
|
||||||
|
className={clsx(
|
||||||
|
"relative flex flex-1 gap-docs_0.75 items-center",
|
||||||
|
"py-docs_0.5 px-docs_0.75 rounded",
|
||||||
|
"bg-medusa-bg-component hover:bg-medusa-bg-component-hover",
|
||||||
|
"shadow-elevation-card-rest dark:shadow-elevation-card-rest-dark",
|
||||||
|
"hover:shadow-elevation-card-hover dark:shadow-elevation-card-hover-dark",
|
||||||
|
className
|
||||||
|
)}
|
||||||
|
>
|
||||||
|
<Link href={link} className="absolute top-0 left-0 w-full h-full" />
|
||||||
|
{type === "previous" && (
|
||||||
|
<TriangleLeftMini className="text-medusa-fg-muted" />
|
||||||
|
)}
|
||||||
|
<div
|
||||||
|
className={clsx(
|
||||||
|
"flex-1",
|
||||||
|
type === "previous" && "text-left",
|
||||||
|
type === "next" && "text-right"
|
||||||
|
)}
|
||||||
|
>
|
||||||
|
{parentTitle && (
|
||||||
|
<span className="block text-compact-small text-medusa-fg-subtle">
|
||||||
|
{parentTitle}
|
||||||
|
</span>
|
||||||
|
)}
|
||||||
|
<span className="block text-compact-small-plus text-medusa-fg-base">
|
||||||
|
{title}
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
{type === "next" && (
|
||||||
|
<TriangleRightMini className="text-medusa-fg-muted" />
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
@@ -2,9 +2,8 @@
|
|||||||
|
|
||||||
import React from "react"
|
import React from "react"
|
||||||
import { usePagination } from "../../providers"
|
import { usePagination } from "../../providers"
|
||||||
import { Card } from "../Card"
|
|
||||||
import { ChevronLeft, ChevronRight } from "@medusajs/icons"
|
|
||||||
import clsx from "clsx"
|
import clsx from "clsx"
|
||||||
|
import { PaginationCard } from "./Card"
|
||||||
|
|
||||||
export const Pagination = () => {
|
export const Pagination = () => {
|
||||||
const { previousPage, nextPage } = usePagination()
|
const { previousPage, nextPage } = usePagination()
|
||||||
@@ -13,27 +12,23 @@ export const Pagination = () => {
|
|||||||
<div
|
<div
|
||||||
className={clsx(
|
className={clsx(
|
||||||
"flex justify-between",
|
"flex justify-between",
|
||||||
"flex-col sm:flex-row gap-docs_1 sm:gap-0"
|
"flex-col sm:flex-row gap-docs_0.75"
|
||||||
)}
|
)}
|
||||||
>
|
>
|
||||||
{previousPage && (
|
{previousPage && (
|
||||||
<Card
|
<PaginationCard
|
||||||
|
type="previous"
|
||||||
title={previousPage.title}
|
title={previousPage.title}
|
||||||
text={previousPage.parentTitle}
|
parentTitle={previousPage.parentTitle}
|
||||||
startIcon={<ChevronLeft />}
|
link={previousPage.link}
|
||||||
showLinkIcon={false}
|
|
||||||
href={previousPage.link}
|
|
||||||
className={clsx("ml-0 mr-auto items-center", "w-full sm:max-w-[45%]")}
|
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
{nextPage && (
|
{nextPage && (
|
||||||
<Card
|
<PaginationCard
|
||||||
|
type="next"
|
||||||
title={nextPage.title}
|
title={nextPage.title}
|
||||||
text={nextPage.parentTitle}
|
parentTitle={nextPage.parentTitle}
|
||||||
endIcon={<ChevronRight />}
|
link={nextPage.link}
|
||||||
showLinkIcon={false}
|
|
||||||
href={nextPage.link}
|
|
||||||
className={clsx("mr-0 ml-auto items-center", "w-full sm:max-w-[45%]")}
|
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user