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
17 changes: 17 additions & 0 deletions src/components/TocItem/TocItem.scss
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ $visibleStartPadding: 12px;
font-size: inherit;
font-weight: inherit;

position: relative;
padding: 7px 12px 7px 18px;
box-sizing: border-box;
word-break: break-word;
background-color: transparent;
Expand All @@ -77,6 +79,21 @@ $visibleStartPadding: 12px;
@include mixins.text-size(body-1);
}

&_deprecated {
span {
width: 90%;
display: block;
}

svg {
position: absolute;
top: 50%;
right: 6px;
transform: translateY(-50%);
opacity: 0.6;
}
}

&_clicable {
cursor: pointer;

Expand Down
12 changes: 10 additions & 2 deletions src/components/TocItem/TocItem.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React from 'react';
import block from 'bem-cn-lite';
import {Button} from '@gravity-ui/uikit';
import {Ban} from '@gravity-ui/icons';

import {useTranslation} from '../../hooks';
import {TocItem as ITocItem} from '../../models';
Expand All @@ -19,12 +20,13 @@ export interface TocItemProps extends ITocItem {
active: boolean;
expandable: boolean;
expanded: boolean;
deprecated?: boolean;
toggleItem: (id: string, opened: boolean) => void;
}

export const TocItem: React.FC<TocItemProps> = React.forwardRef(
(
{id, name, href, active, expandable, expanded, toggleItem, labeled},
{id, name, href, active, expandable, expanded, toggleItem, labeled, deprecated},
ref: React.ForwardedRef<HTMLButtonElement>,
) => {
const handleClick = () => {
Expand All @@ -33,7 +35,12 @@ export const TocItem: React.FC<TocItemProps> = React.forwardRef(

const {t} = useTranslation('toc-nav-panel');

const text = <span>{name}</span>;
const deprecatedIcon = deprecated ? <Ban /> : null;
const text = (
<span>
{name} {deprecatedIcon}
</span>
);
const icon = expandable ? (
<ToggleArrow className={b('icon')} open={expanded} thin={true} />
) : null;
Expand All @@ -46,6 +53,7 @@ export const TocItem: React.FC<TocItemProps> = React.forwardRef(
clicable: Boolean(expandable || href),
active,
labeled,
deprecated,
};

const content = React.createElement(
Expand Down
Loading