diff --git a/src/components/TableOfContents/ItemsList.tsx b/src/components/TableOfContents/ItemsList.tsx index 31ee666204f..6368a9c3e5e 100644 --- a/src/components/TableOfContents/ItemsList.tsx +++ b/src/components/TableOfContents/ItemsList.tsx @@ -28,15 +28,7 @@ const ItemsList = ({ {items && ( - + ( + + + + ), + ], +} satisfies Meta + +export default meta + +type Story = StoryObj + +export const Default: Story = { + render: () => , +} diff --git a/src/components/TableOfContents/TableOfContentsLink.tsx b/src/components/TableOfContents/TableOfContentsLink.tsx index 8b7d6d3ecc2..8568e64ba7e 100644 --- a/src/components/TableOfContents/TableOfContentsLink.tsx +++ b/src/components/TableOfContents/TableOfContentsLink.tsx @@ -4,8 +4,6 @@ import type { ToCItem } from "@/lib/types" import { BaseLink } from "@/components/Link" -import { useRtlFlip } from "@/hooks/useRtlFlip" - export type TableOfContentsLinkProps = { depth: number item: ToCItem @@ -17,7 +15,6 @@ const Link = ({ item: { title, url }, activeHash, }: TableOfContentsLinkProps) => { - const { flipForRtl } = useRtlFlip() const isActive = activeHash === url const isNested = depth === 2 @@ -29,16 +26,20 @@ const Link = ({ const $dotBg = cssVar("dot-bg") const hoverOrActiveStyle: SystemStyleObject = { - color: "primary.base", + color: $dotBg.reference, _after: { content: `""`, - background: $dotBg.reference, + backgroundColor: "background.base", border: "1px", - borderColor: "primary.base", + borderColor: $dotBg.reference, borderRadius: "50%", boxSize: 2, position: "absolute", - insetInlineStart: "-1.29rem", + // 16px is the initial list padding + // 8px is the padding for each nested list + // 4px is half of the width of the dot + // 1px for the border + "inset-inline-start": `calc(-16px - 8px * ${depth} - 4px - 1px)`, top: "50%", mt: -1, }, @@ -51,35 +52,19 @@ const Link = ({ textDecoration="none" display="inline-block" position="relative" - color="textTableOfContents" - fontWeight="normal" - mb="0.5rem !important" + color="body.medium" width={{ base: "100%", lg: "auto" }} _hover={{ ...hoverOrActiveStyle, }} + p="2" + ps="0" sx={{ - [$dotBg.variable]: "colors.background", + [$dotBg.variable]: "var(--eth-colors-primary-hover)", "&.active": { - [$dotBg.variable]: "colors.primary", + [$dotBg.variable]: "var(--eth-colors-primary-visited)", ...hoverOrActiveStyle, }, - "&.nested": { - _before: { - content: `"⌞"`, - opacity: 0.5, - display: "inline-flex", - position: "absolute", - insetInlineStart: -3.5, - top: -1, - transform: flipForRtl, - }, - "&.active, &:hover": { - _after: { - insetInlineStart: "-2.29rem", - }, - }, - }, }} > {title} diff --git a/src/components/TableOfContents/index.tsx b/src/components/TableOfContents/index.tsx index 6f8beaaae10..de3eced42e0 100644 --- a/src/components/TableOfContents/index.tsx +++ b/src/components/TableOfContents/index.tsx @@ -4,9 +4,9 @@ import { Box, BoxProps, calc, + Flex, Icon, List, - ListItem, useToken, } from "@chakra-ui/react" @@ -65,7 +65,10 @@ const TableOfContents = ({ } return ( - - - {!hideEditButton && editPath && ( - - } - href={editPath} - variant="outline" - > - {t("edit-page")} - - - )} - - - {t("on-this-page")} - - - - - + {!hideEditButton && editPath && ( + } + href={editPath} + variant="outline" + > + {t("edit-page")} + + )} + + {t("on-this-page")} + + + - + ) } diff --git a/src/lib/utils/toc.ts b/src/lib/utils/toc.ts index 4073d4f1383..81cd59b8e97 100644 --- a/src/lib/utils/toc.ts +++ b/src/lib/utils/toc.ts @@ -31,16 +31,14 @@ export const parseHeadingId = (heading: string): string => { */ export const outerListProps: ListProps = { borderStart: "1px solid", - borderStartColor: "dropdownBorder", + borderStartColor: "body.medium", borderTop: 0, fontSize: "sm", - lineHeight: 1.6, - fontWeight: 400, + spacing: "2", m: 0, mt: 2, mb: 2, ps: 4, - pe: 1, pt: 0, sx: { // TODO: Flip to object syntax with `lg` token after completion of Chakra migration