Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions sidebars.js
Original file line number Diff line number Diff line change
Expand Up @@ -195,11 +195,12 @@ const sidebars = {
{
type: 'category',
label: 'Tutorials',
link: {
type: 'doc',
id: 'tutorials/index',
},
items: [
{
type: 'doc',
id: 'tutorials/index',
label: 'Overview',
},
{
type: 'category',
label: 'Prediction market',
Expand Down
18 changes: 9 additions & 9 deletions src/theme/DocSidebarItem/Category/index.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, {type ComponentProps, useEffect, useMemo, useState} from 'react';
import React, {type ComponentProps, useEffect, useMemo} from 'react';
import clsx from 'clsx';
import {
ThemeClassNames,
Expand Down Expand Up @@ -219,6 +219,7 @@ export default function DocSidebarItemCategory({
</Link>
{href && collapsible && (
<SecondLevelItemIcon
collapsed={collapsed}
onClick={
(e) => {
e.preventDefault();
Expand All @@ -240,20 +241,19 @@ export default function DocSidebarItemCategory({
);
}

const SecondLevelItemIcon = ({onClick}:{onClick: (e) => void}) => {
const [isRotated, setIsRotated] = useState(false);

const SecondLevelItemIcon = ({collapsed, onClick}:{collapsed: boolean; onClick: (e) => void}) => {
// Match the default caret orientation used by sibling categories:
// collapsed -> points right (90deg), expanded -> points down (180deg).
// Driven by the real `collapsed` state so it stays in sync whether the
// category is toggled via the label link, this icon, or auto-collapse.
return (
<img
style={{
transform: isRotated ? 'rotate(90deg)' : 'rotate(180deg)',
transform: collapsed ? 'rotate(90deg)' : 'rotate(180deg)',
transition: 'transform 0.3s ease',
}}
className={styles.secondLevelItemIcon}
onClick={(e) => {
setIsRotated(!isRotated)
onClick(e)
}}
onClick={onClick}
src='/img/site/GreenFiChevronUp.svg' alt='arrow icon'
/>
)
Expand Down