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
81 changes: 45 additions & 36 deletions src-docs/src/components/guide_page/guide_page_chrome.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export class GuidePageChrome extends Component {
});
};

renderSideNavBadge = ({ isBeta, isNew }) => {
renderSideNavBadge = ({ isBeta, isNew, isDeprecated }) => {
if (isBeta) {
return (
<EuiBadge color="warning" className="guideSideNav__itemBadge">
Expand All @@ -56,6 +56,13 @@ export class GuidePageChrome extends Component {
</EuiBadge>
);
}
if (isDeprecated) {
return (
<EuiBadge color="danger" className="guideSideNav__itemBadge">
Deprecated
</EuiBadge>
);
}
return undefined;
};

Expand Down Expand Up @@ -98,44 +105,46 @@ export class GuidePageChrome extends Component {
return;
}

return subSectionsWithTitles.map(({ title, isBeta, isNew, sections }) => {
const id = slugify(title);
return subSectionsWithTitles.map(
({ title, isBeta, isNew, isDeprecated, sections }) => {
const id = slugify(title);

const subSectionHref = `${href}/${id}`;
const subSectionHashIdHref = `${href}#${id}`;
const subSectionHref = `${href}/${id}`;
const subSectionHashIdHref = `${href}#${id}`;

const sectionHref = sections ? subSectionHref : subSectionHashIdHref;
const subItems = sections
? this.renderSubSections(sectionHref, sections, searchTerm)
: undefined;
const sectionHref = sections ? subSectionHref : subSectionHashIdHref;
const subItems = sections
? this.renderSubSections(sectionHref, sections, searchTerm)
: undefined;

const isCurrentlyOpenSubSection =
window.location.hash.includes(subSectionHref);
const isCurrentlyOpenSubSection =
window.location.hash.includes(subSectionHref);

let name = title;
if (searchTerm) {
name = (
<EuiHighlight
className="guideSideNav__item--inSearch"
search={searchTerm}
>
{title}
</EuiHighlight>
);
}
let name = title;
if (searchTerm) {
name = (
<EuiHighlight
className="guideSideNav__item--inSearch"
search={searchTerm}
>
{title}
</EuiHighlight>
);
}

return {
id: sectionHref,
name: isCurrentlyOpenSubSection ? <strong>{name}</strong> : name,
href: sectionHref,
className: isCurrentlyOpenSubSection
? 'guideSideNav__item--openSubTitle'
: '',
items: subItems,
forceOpen: !!searchTerm || isCurrentlyOpenSubSection,
icon: this.renderSideNavBadge({ isBeta, isNew }),
};
});
return {
id: sectionHref,
name: isCurrentlyOpenSubSection ? <strong>{name}</strong> : name,
href: sectionHref,
className: isCurrentlyOpenSubSection
? 'guideSideNav__item--openSubTitle'
: '',
items: subItems,
forceOpen: !!searchTerm || isCurrentlyOpenSubSection,
icon: this.renderSideNavBadge({ isBeta, isNew, isDeprecated }),
};
}
);
};

renderSideNav = (sideNav) => {
Expand All @@ -161,7 +170,7 @@ export class GuidePageChrome extends Component {
});

const items = matchingItems.map((item) => {
const { name, path, sections, isBeta, isNew } = item;
const { name, path, sections, isBeta, isNew, isDeprecated } = item;

const href = `#/${path}`;

Expand All @@ -185,7 +194,7 @@ export class GuidePageChrome extends Component {
isSelected: item.path === this.props.currentRoute.path,
forceOpen: !!(searchTerm && hasMatchingSubItem),
className: 'guideSideNav__item',
icon: this.renderSideNavBadge({ isBeta, isNew }),
icon: this.renderSideNavBadge({ isBeta, isNew, isDeprecated }),
};
});

Expand Down
2 changes: 2 additions & 0 deletions src-docs/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ root.render(
sections,
isBeta,
isNew,
isDeprecated,
component,
from,
to,
Expand Down Expand Up @@ -88,6 +89,7 @@ root.render(
sections,
isBeta,
isNew,
isDeprecated,
}}
>
{({ theme }) => (
Expand Down
24 changes: 21 additions & 3 deletions src-docs/src/routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -296,8 +296,16 @@ const createExample = (example, customTitle) => {
);
}

const { title, sections, isBeta, isNew, playground, guidelines, ...rest } =
example;
const {
title,
sections,
isBeta,
isNew,
isDeprecated,
playground,
guidelines,
...rest
} = example;
const filteredSections = sections.filter((section) => section !== undefined);

filteredSections.forEach((section) => {
Expand Down Expand Up @@ -327,6 +335,7 @@ const createExample = (example, customTitle) => {
title={title}
isBeta={isBeta}
isNew={isNew}
isDeprecated={isDeprecated}
playground={playgroundComponent}
guidelines={guidelines}
{...rest}
Expand All @@ -342,11 +351,19 @@ const createExample = (example, customTitle) => {
sections: filteredSections,
isBeta,
isNew,
isDeprecated,
hasGuidelines: typeof guidelines !== 'undefined',
};
};

const createTabbedPage = ({ title, pages, isBeta, isNew, ...rest }) => {
const createTabbedPage = ({
title,
pages,
isBeta,
isNew,
isDeprecated,
...rest
}) => {
const component = () => (
<GuideTabbedPage title={title} pages={pages} {...rest} />
);
Expand All @@ -365,6 +382,7 @@ const createTabbedPage = ({ title, pages, isBeta, isNew, ...rest }) => {
sections: pagesSections,
isBeta,
isNew,
isDeprecated,
};
};

Expand Down
Loading