docs: redesign footer (#8651)

This commit is contained in:
Shahed Nasser
2024-08-20 14:47:53 +02:00
committed by GitHub
parent b8ba020cd5
commit 43202dde0f
17 changed files with 150 additions and 64 deletions
+10
View File
@@ -24,6 +24,8 @@ All API Routes are prefixed with `/admin`. So, during development, the API Route
}} }}
reportLink={formatReportLink("admin", "Introduction")} reportLink={formatReportLink("admin", "Introduction")}
pathName="/api/admin" pathName="/api/admin"
question="Was this section helpful?"
vertical={true}
/> />
</SectionContainer> </SectionContainer>
@@ -166,6 +168,8 @@ fetch(`<BACKEND_URL>/admin/products`, {
}} }}
reportLink={formatReportLink("admin", "Authentication - Cookie Session ID")} reportLink={formatReportLink("admin", "Authentication - Cookie Session ID")}
pathName="/api/admin" pathName="/api/admin"
question="Was this section helpful?"
vertical={true}
/> />
</SectionContainer> </SectionContainer>
@@ -190,6 +194,8 @@ x-no-compression: true
}} }}
reportLink={formatReportLink("admin", "Authentication - Cookie Session ID")} reportLink={formatReportLink("admin", "Authentication - Cookie Session ID")}
pathName="/api/admin" pathName="/api/admin"
question="Was this section helpful?"
vertical={true}
/> />
</SectionContainer> </SectionContainer>
@@ -394,6 +400,8 @@ curl -g "http://localhost:9000/admin/products?created_at[$lt]=2023-02-17&created
}} }}
reportLink={formatReportLink("admin", "Query Parameter Types")} reportLink={formatReportLink("admin", "Query Parameter Types")}
pathName="/api/admin" pathName="/api/admin"
question="Was this section helpful?"
vertical={true}
/> />
</SectionContainer> </SectionContainer>
@@ -472,6 +480,8 @@ This sorts the products by their `created_at` field in the descending order.
}} }}
reportLink={formatReportLink("admin", "Pagination")} reportLink={formatReportLink("admin", "Pagination")}
pathName="/api/admin" pathName="/api/admin"
question="Was this section helpful?"
vertical={true}
/> />
</SectionContainer> </SectionContainer>
+14
View File
@@ -25,6 +25,8 @@ All API Routes are prefixed with `/store`. So, during development, the API Route
}} }}
reportLink={formatReportLink("store", "Introduction")} reportLink={formatReportLink("store", "Introduction")}
pathName="/api/store" pathName="/api/store"
question="Was this section helpful?"
vertical={true}
/> />
</SectionContainer> </SectionContainer>
@@ -136,6 +138,8 @@ fetch(`<BACKEND_URL>/store/products`, {
}} }}
reportLink={formatReportLink("store", "Authentication - Cookie Session ID")} reportLink={formatReportLink("store", "Authentication - Cookie Session ID")}
pathName="/api/store" pathName="/api/store"
question="Was this section helpful?"
vertical={true}
/> />
</SectionContainer> </SectionContainer>
@@ -180,6 +184,8 @@ x-publishable-api-key: {your_publishable_api_key}
}} }}
reportLink={formatReportLink("store", "Publishable API Key")} reportLink={formatReportLink("store", "Publishable API Key")}
pathName="/api/store" pathName="/api/store"
question="Was this section helpful?"
vertical={true}
/> />
</SectionContainer> </SectionContainer>
@@ -204,6 +210,8 @@ x-no-compression: true
}} }}
reportLink={formatReportLink("store", "HTTP Compression")} reportLink={formatReportLink("store", "HTTP Compression")}
pathName="/api/store" pathName="/api/store"
question="Was this section helpful?"
vertical={true}
/> />
</SectionContainer> </SectionContainer>
@@ -266,6 +274,8 @@ This returns the variants of each product, but the variants only have their `id`
}} }}
reportLink={formatReportLink("store", "Selecting Fields")} reportLink={formatReportLink("store", "Selecting Fields")}
pathName="/api/store" pathName="/api/store"
question="Was this section helpful?"
vertical={true}
/> />
</SectionContainer> </SectionContainer>
@@ -407,6 +417,8 @@ curl -g "http://localhost:9000/store/products?created_at[$lt]=2023-02-17&created
}} }}
reportLink={formatReportLink("store", "Query Parameter Types")} reportLink={formatReportLink("store", "Query Parameter Types")}
pathName="/api/store" pathName="/api/store"
question="Was this section helpful?"
vertical={true}
/> />
</SectionContainer> </SectionContainer>
@@ -483,6 +495,8 @@ This sorts the products by their `created_at` field in the descending order.
}} }}
reportLink={formatReportLink("store", "Pagination")} reportLink={formatReportLink("store", "Pagination")}
pathName="/api/store" pathName="/api/store"
question="Was this section helpful?"
vertical={true}
/> />
</SectionContainer> </SectionContainer>
+2 -2
View File
@@ -43,10 +43,10 @@ export default function RootLayout({
}} }}
showPagination={true} showPagination={true}
bodyClassName={clsx(inter.variable, robotoMono.variable)} bodyClassName={clsx(inter.variable, robotoMono.variable)}
feedbackComponent={<Feedback className="my-2" />}
editComponent={<EditButton />}
> >
{children} {children}
<Feedback className="my-2" />
<EditButton />
</TightLayout> </TightLayout>
) )
} }
+3 -3
View File
@@ -2,7 +2,7 @@ import type { Metadata } from "next"
import { Inter, Roboto_Mono } from "next/font/google" import { Inter, Roboto_Mono } from "next/font/google"
import Providers from "@/providers" import Providers from "@/providers"
import "./globals.css" import "./globals.css"
import { Breadcrumbs, TightLayout } from "docs-ui" import { TightLayout } from "docs-ui"
import { config } from "@/config" import { config } from "@/config"
import clsx from "clsx" import clsx from "clsx"
import { Feedback } from "@/components/Feedback" import { Feedback } from "@/components/Feedback"
@@ -43,10 +43,10 @@ export default function RootLayout({
expandItems: true, expandItems: true,
}} }}
bodyClassName={clsx(inter.variable, robotoMono.variable)} bodyClassName={clsx(inter.variable, robotoMono.variable)}
feedbackComponent={<Feedback className="my-2" />}
editComponent={<EditButton />}
> >
{children} {children}
<Feedback className="my-2" />
<EditButton />
</TightLayout> </TightLayout>
) )
} }
@@ -0,0 +1,26 @@
"use client"
import clsx from "clsx"
import React from "react"
export type DottedSeparatorProps = {
wrapperClassName?: string
className?: string
}
export const DottedSeparator = ({
className,
wrapperClassName,
}: DottedSeparatorProps) => {
return (
<div className={clsx("px-docs_0.75 my-docs_0.75", wrapperClassName)}>
<span
className={clsx(
"block w-full h-px relative bg-border-dotted",
"bg-[length:4px_1px] bg-repeat-x bg-bottom",
className
)}
></span>
</div>
)
}
@@ -1,5 +1,7 @@
import React from "react" import React from "react"
import { Button } from "../.." import Link from "next/link"
import clsx from "clsx"
import { ArrowUpRightOnBox } from "@medusajs/icons"
type EditButtonProps = { type EditButtonProps = {
filePath: string filePath: string
@@ -7,10 +9,15 @@ type EditButtonProps = {
export const EditButton = ({ filePath }: EditButtonProps) => { export const EditButton = ({ filePath }: EditButtonProps) => {
return ( return (
<Button variant="secondary" className="mb-docs_1"> <Link
<a href={`https://github.com/medusajs/medusa/edit/develop${filePath}`}> href={`https://github.com/medusajs/medusa/edit/develop${filePath}`}
Edit this page className={clsx(
</a> "flex w-fit gap-docs_0.25 my-docs_2 items-center",
</Button> "text-medusa-fg-muted hover:text-medusa-fg-subtle"
)}
>
<span>Edit this page</span>
<ArrowUpRightOnBox />
</Link>
) )
} }
@@ -5,7 +5,16 @@ import { CSSTransition, SwitchTransition } from "react-transition-group"
import { Solutions } from "./Solutions" import { Solutions } from "./Solutions"
import { ExtraData, useAnalytics } from "@/providers/Analytics" import { ExtraData, useAnalytics } from "@/providers/Analytics"
import clsx from "clsx" import clsx from "clsx"
import { Button, TextArea, Label, Details, InputText } from "@/components" import {
Button,
TextArea,
Label,
Details,
InputText,
DottedSeparator,
} from "@/components"
import { ChatBubbleLeftRight, ThumbDown, ThumbUp } from "@medusajs/icons"
import Link from "next/link"
export type FeedbackProps = { export type FeedbackProps = {
event: string event: string
@@ -29,9 +38,9 @@ export const Feedback = ({
event, event,
pathName, pathName,
reportLink, reportLink,
question = "Was this section helpful?", question = "Was this page helpful?",
positiveBtn = "Yes", positiveBtn = "It was helpful",
negativeBtn = "No", negativeBtn = "It wasn't helpful",
positiveQuestion = "What was most helpful?", positiveQuestion = "What was most helpful?",
negativeQuestion = "What can we improve?", negativeQuestion = "What can we improve?",
submitBtn = "Submit", submitBtn = "Submit",
@@ -111,7 +120,8 @@ export const Feedback = ({
} }
return ( return (
<div className={clsx("mt-docs_3", className)}> <div className={clsx(className)}>
<DottedSeparator wrapperClassName="!px-0 !my-docs_2" />
<SwitchTransition mode="out-in"> <SwitchTransition mode="out-in">
<CSSTransition <CSSTransition
key={ key={
@@ -135,33 +145,62 @@ export const Feedback = ({
{!showForm && !submittedFeedback && ( {!showForm && !submittedFeedback && (
<div <div
className={clsx( className={clsx(
"flex", "flex gap-docs_0.5",
!vertical && "flex-row items-center", !vertical && "flex-col md:flex-row md:items-center",
vertical && "flex-col justify-center gap-docs_1" vertical && "flex-col justify-center"
)} )}
ref={inlineFeedbackRef} ref={inlineFeedbackRef}
> >
<Label className="mr-docs_1.5">{question}</Label> <Label>{question}</Label>
<div <div
className={clsx("flex flex-row items-center gap-docs_0.5")} className={clsx(
"flex gap-docs_0.5",
"flex-col md:flex-row md:items-center"
)}
> >
<Button <Button
onClick={handleFeedback} onClick={handleFeedback}
className="positive w-fit" className={clsx(
variant="secondary" "positive gap-[6px] !justify-start md:!justify-center",
"!px-docs_0.5 !py-docs_0.25"
)}
variant="transparent-clear"
> >
{positiveBtn} <ThumbUp className="text-medusa-fg-subtle" />
<span className="text-medusa-fg-base text-compact-small-plus flex-1">
{positiveBtn}
</span>
</Button> </Button>
<Button <Button
onClick={handleFeedback} onClick={handleFeedback}
className="w-fit" className={clsx(
variant="secondary" "gap-[6px] !justify-start md:!justify-center",
"!px-docs_0.5 !py-docs_0.25"
)}
variant="transparent-clear"
> >
{negativeBtn} <ThumbDown className="text-medusa-fg-subtle" />
<span className="text-medusa-fg-base text-compact-small-plus flex-1">
{negativeBtn}
</span>
</Button> </Button>
{reportLink && ( {reportLink && (
<Button variant="secondary"> <Button
<a href={reportLink}>Report Issue</a> variant="transparent-clear"
className={clsx(
"gap-[6px] relative",
"!px-docs_0.5 !py-docs_0.25",
"!justify-start md:!justify-center"
)}
>
<ChatBubbleLeftRight className="text-medusa-fg-subtle" />
<span className="text-medusa-fg-base text-compact-small-plus flex-1">
Report Issue
</span>
<Link
href={reportLink}
className="absolute left-0 top-0 w-full h-full"
></Link>
</Button> </Button>
)} )}
</div> </div>
@@ -259,6 +298,7 @@ export const Feedback = ({
</> </>
</CSSTransition> </CSSTransition>
</SwitchTransition> </SwitchTransition>
<DottedSeparator wrapperClassName="!px-0 !my-docs_2" />
</div> </div>
) )
} }
@@ -6,7 +6,7 @@ import Link from "next/link"
import clsx from "clsx" import clsx from "clsx"
import { EllipseMiniSolid } from "@medusajs/icons" import { EllipseMiniSolid } from "@medusajs/icons"
import { MainNavigationDropdownIcon } from "../../Icon" import { MainNavigationDropdownIcon } from "../../Icon"
import { SidebarSeparator } from "../../../../Sidebar/Separator" import { DottedSeparator } from "../../../.."
export type MainNavigationDropdownMenuItemProps = { export type MainNavigationDropdownMenuItemProps = {
item: NavigationDropdownItem item: NavigationDropdownItem
@@ -19,7 +19,7 @@ export const MainNavigationDropdownMenuItem = ({
}: MainNavigationDropdownMenuItemProps) => { }: MainNavigationDropdownMenuItemProps) => {
switch (item.type) { switch (item.type) {
case "divider": case "divider":
return <SidebarSeparator className="my-docs_0.25" /> return <DottedSeparator className="my-docs_0.25" />
case "link": case "link":
return ( return (
<Link <Link
@@ -5,7 +5,7 @@ import { SidebarItem as SidebarItemType } from "types"
import { SidebarItemCategory } from "./Category" import { SidebarItemCategory } from "./Category"
import { SidebarItemLink } from "./Link" import { SidebarItemLink } from "./Link"
import { SidebarItemSubCategory } from "./SubCategory" import { SidebarItemSubCategory } from "./SubCategory"
import { SidebarSeparator } from "../Separator" import { DottedSeparator } from "../.."
export type SidebarItemProps = { export type SidebarItemProps = {
item: SidebarItemType item: SidebarItemType
@@ -24,7 +24,7 @@ export const SidebarItem = ({
return ( return (
<> <>
<SidebarItemCategory item={item} {...props} /> <SidebarItemCategory item={item} {...props} />
{hasNextItems && <SidebarSeparator />} {hasNextItems && <DottedSeparator />}
</> </>
) )
case "sub-category": case "sub-category":
@@ -32,6 +32,6 @@ export const SidebarItem = ({
case "link": case "link":
return <SidebarItemLink item={item} {...props} /> return <SidebarItemLink item={item} {...props} />
case "separator": case "separator":
return <SidebarSeparator /> return <DottedSeparator />
} }
} }
@@ -1,22 +0,0 @@
"use client"
import clsx from "clsx"
import React from "react"
export type SidebarSeparatorProps = {
className?: string
}
export const SidebarSeparator = ({ className }: SidebarSeparatorProps) => {
return (
<div className="px-docs_0.75">
<span
className={clsx(
"block w-full h-px relative my-docs_0.75 bg-border-dotted",
"bg-[length:4px_1px] bg-repeat-x bg-bottom",
className
)}
></span>
</div>
)
}
@@ -3,9 +3,9 @@
import React from "react" import React from "react"
import { SidebarChild } from "../Child" import { SidebarChild } from "../Child"
import { InteractiveSidebarItem } from "types" import { InteractiveSidebarItem } from "types"
import { SidebarSeparator } from "../Separator"
import { SidebarTopMobileClose } from "./MobileClose" import { SidebarTopMobileClose } from "./MobileClose"
import { SidebarTopMedusaMenu } from "./MedusaMenu" import { SidebarTopMedusaMenu } from "./MedusaMenu"
import { DottedSeparator } from "../../.."
export type SidebarTopProps = { export type SidebarTopProps = {
parentItem?: InteractiveSidebarItem parentItem?: InteractiveSidebarItem
@@ -20,11 +20,11 @@ export const SidebarTop = React.forwardRef<HTMLDivElement, SidebarTopProps>(
<SidebarTopMedusaMenu /> <SidebarTopMedusaMenu />
{parentItem && ( {parentItem && (
<> <>
<SidebarSeparator /> <DottedSeparator />
<SidebarChild item={parentItem} /> <SidebarChild item={parentItem} />
</> </>
)} )}
<SidebarSeparator className="!my-0" /> <DottedSeparator className="!my-0" />
</div> </div>
</div> </div>
) )
@@ -3,12 +3,11 @@
import React, { useMemo, useRef } from "react" import React, { useMemo, useRef } from "react"
import { useSidebar } from "@/providers" import { useSidebar } from "@/providers"
import clsx from "clsx" import clsx from "clsx"
import { Loading } from "@/components" import { DottedSeparator, Loading } from "@/components"
import { SidebarItem } from "./Item" import { SidebarItem } from "./Item"
import { CSSTransition, SwitchTransition } from "react-transition-group" import { CSSTransition, SwitchTransition } from "react-transition-group"
import { SidebarTop, SidebarTopProps } from "./Top" import { SidebarTop, SidebarTopProps } from "./Top"
import useResizeObserver from "@react-hook/resize-observer" import useResizeObserver from "@react-hook/resize-observer"
import { SidebarSeparator } from "./Separator"
import { useClickOutside, useKeyboardShortcut } from "@/hooks" import { useClickOutside, useKeyboardShortcut } from "@/hooks"
export type SidebarProps = { export type SidebarProps = {
@@ -131,7 +130,7 @@ export const Sidebar = ({
hasNextItems={index !== sidebarItems.default.length - 1} hasNextItems={index !== sidebarItems.default.length - 1}
/> />
))} ))}
<SidebarSeparator /> <DottedSeparator />
</div> </div>
{/* DESKTOP SIDEBAR */} {/* DESKTOP SIDEBAR */}
<div className="mt-docs_0.75 lg:mt-0"> <div className="mt-docs_0.75 lg:mt-0">
@@ -18,6 +18,7 @@ export * from "./CopyButton"
export * from "./Details" export * from "./Details"
export * from "./Details/Summary" export * from "./Details/Summary"
export * from "./DetailsList" export * from "./DetailsList"
export * from "./DottedSeparator"
export * from "./EditButton" export * from "./EditButton"
export * from "./ExpandableNotice" export * from "./ExpandableNotice"
export * from "./FeatureFlagNotice" export * from "./FeatureFlagNotice"
@@ -12,6 +12,8 @@ export type RootLayoutProps = {
htmlClassName?: string htmlClassName?: string
bodyClassName?: string bodyClassName?: string
showPagination?: boolean showPagination?: boolean
feedbackComponent?: React.ReactNode
editComponent?: React.ReactNode
} & MainContentLayoutProps } & MainContentLayoutProps
export const RootLayout = ({ export const RootLayout = ({
@@ -6,6 +6,8 @@ import { Pagination } from ".."
export const TightLayout = ({ export const TightLayout = ({
children, children,
showPagination, showPagination,
feedbackComponent,
editComponent,
...props ...props
}: RootLayoutProps) => { }: RootLayoutProps) => {
return ( return (
@@ -19,7 +21,9 @@ export const TightLayout = ({
)} )}
> >
{children} {children}
{feedbackComponent}
{showPagination && <Pagination />} {showPagination && <Pagination />}
{editComponent}
</div> </div>
</RootLayout> </RootLayout>
) )
+5 -1
View File
@@ -6,6 +6,8 @@ import { Pagination } from ".."
export const WideLayout = ({ export const WideLayout = ({
children, children,
showPagination, showPagination,
feedbackComponent,
editComponent,
...props ...props
}: RootLayoutProps) => { }: RootLayoutProps) => {
return ( return (
@@ -16,11 +18,13 @@ export const WideLayout = ({
<main <main
className={clsx( className={clsx(
"max-w-inner-content-xs sm:max-w-inner-content-sm md:max-w-inner-content-md", "max-w-inner-content-xs sm:max-w-inner-content-sm md:max-w-inner-content-md",
"lg:max-w-wide-content relative mt-4 w-full flex-1 lg:mt-7" "lg:max-w-lg-wide-content xl:max-w-xl-wide-content relative mt-4 w-full flex-1 lg:mt-7"
)} )}
> >
{children} {children}
{feedbackComponent}
{showPagination && <Pagination />} {showPagination && <Pagination />}
{editComponent}
</main> </main>
</RootLayout> </RootLayout>
) )
@@ -309,7 +309,8 @@ module.exports = {
"inner-content-xxl": "640px", "inner-content-xxl": "640px",
"inner-content-xxxl": "640px", "inner-content-xxxl": "640px",
// wide layout // wide layout
"wide-content": "1112px", "xl-wide-content": "1112px",
"lg-wide-content": "800px",
}, },
minWidth: { minWidth: {
xl: "1419px", xl: "1419px",