mirror of
https://github.com/reactjs/react.dev.git
synced 2026-02-25 23:05:23 +00:00
Co-authored-by: Dan Abramov <dan.abramov@me.com> Co-authored-by: Sylwia Vargas <sylwia.vargas@gmail.com> Co-authored-by: Dan Lebowitz <dan.lebo@me.com> Co-authored-by: Razvan Gradinar <grazvan@fb.com> Co-authored-by: Jared Palmer <jared@palmer.net> Co-authored-by: Dane Grant <danecando@gmail.com> Co-authored-by: Dustin Goodman <dustin.s.goodman@gmail.com> Co-authored-by: Rick Hanlon <rickhanlonii@gmail.com> Co-authored-by: Maggie Appleton <maggie.fm.appleton@gmail.com> Co-authored-by: Alex Moldovan <alex.n.moldovan@gmail.com> Co-authored-by: Ives van Hoorne <ives.v.h@gmail.com> Co-authored-by: Brian Vaughn <bvaughn@fb.com> Co-authored-by: Dmitri Pavlutin <dpavlutin@gmail.com>
58 lines
1.8 KiB
TypeScript
58 lines
1.8 KiB
TypeScript
/*
|
|
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
*/
|
|
|
|
import * as React from 'react';
|
|
import cn from 'classnames';
|
|
import {IconNavArrow} from 'components/Icon/IconNavArrow';
|
|
|
|
interface SidebarButtonProps {
|
|
title: string;
|
|
heading: boolean;
|
|
level: number;
|
|
onClick: (event: React.MouseEvent<HTMLButtonElement, MouseEvent>) => void;
|
|
isExpanded?: boolean;
|
|
isBreadcrumb?: boolean;
|
|
}
|
|
|
|
export function SidebarButton({
|
|
title,
|
|
heading,
|
|
level,
|
|
onClick,
|
|
isExpanded,
|
|
isBreadcrumb,
|
|
}: SidebarButtonProps) {
|
|
return (
|
|
<div
|
|
className={cn({
|
|
'my-1': heading || level === 1,
|
|
'my-3': level > 1,
|
|
})}>
|
|
<button
|
|
className={cn(
|
|
'p-2 pr-2 pl-5 w-full rounded-r-lg text-left hover:bg-gray-5 dark:hover:bg-gray-80 relative flex items-center justify-between',
|
|
{
|
|
'p-2 text-base': level > 1,
|
|
'text-link bg-highlight dark:bg-highlight-dark text-base font-bold hover:bg-highlight dark:hover:bg-highlight-dark hover:text-link dark:hover:text-link-dark':
|
|
!heading && isBreadcrumb && !isExpanded,
|
|
'p-4 my-6 text-2xl lg:my-auto lg:text-sm font-bold': heading,
|
|
'p-2 hover:text-gray-70 text-base font-bold text-primary dark:text-primary-dark':
|
|
!heading && !isBreadcrumb,
|
|
'text-primary dark:text-primary-dark': heading && !isBreadcrumb,
|
|
'text-primary dark:text-primary-dark text-base font-bold bg-card dark:bg-card-dark':
|
|
!heading && isExpanded,
|
|
}
|
|
)}
|
|
onClick={onClick}>
|
|
{title}
|
|
{typeof isExpanded && !heading && (
|
|
<span className="pr-2 text-gray-30">
|
|
<IconNavArrow displayDirection={isExpanded ? 'down' : 'right'} />
|
|
</span>
|
|
)}
|
|
</button>
|
|
</div>
|
|
);
|
|
}
|