Skip to content
Closed
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
33 changes: 17 additions & 16 deletions src/generators/web/ui/components/MetaBar/index.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { CodeBracketIcon, DocumentIcon } from '@heroicons/react/24/outline';
import Badge from '@node-core/ui-components/Common/Badge';
import MetaBar from '@node-core/ui-components/Containers/MetaBar';
import GitHubIcon from '@node-core/ui-components/Icons/Social/GitHub';

Expand All @@ -12,15 +11,21 @@ const iconMap = {

/**
* @typedef MetaBarProps
* @property {Array<import('@vcarl/remark-headings').Heading & { stability: string }>} headings - Array of page headings for table of contents
* @property {Array<import('@vcarl/remark-headings').Heading & { stability: number }>} headings - Array of page headings for table of contents
* @property {string} addedIn - Version or date when feature was added
* @property {string} readingTime - Estimated reading time for the page
* @property {Array<[string, string]>} viewAs - Array of [title, path] tuples for view options
* @property {string} editThisPage - URL for editing the current page
*/

const STABILITY_KINDS = ['error', 'warning', null, 'info'];
const STABILITY_LABELS = ['D', 'E', null, 'L'];
const STABILITY_CLASS_MAP = [
styles.deprecated,
styles.experimental,
undefined,
styles.legacy,
];

const STABILITY_TITLE_MAP = ['Deprecated', 'Experimental', undefined, 'Legacy'];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need an explicit hard-coded map? I'm not sure how I feel about this.


/**
* MetaBar component that displays table of contents and page metadata
Expand All @@ -39,19 +44,15 @@ export default ({
items: headings.map(({ slug, value, stability, ...heading }) => ({
...heading,
value:
stability !== 2 ? (
<>
{value}
<Badge
size="small"
className={styles.badge}
kind={STABILITY_KINDS[stability]}
>
{STABILITY_LABELS[stability]}
</Badge>
</>
) : (
stability === 2 ? (
value
) : (
<span
className={STABILITY_CLASS_MAP[stability]}
title={STABILITY_TITLE_MAP[stability]}
>
{value}
</span>
),
data: { id: slug },
})),
Expand Down
28 changes: 25 additions & 3 deletions src/generators/web/ui/components/MetaBar/index.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,29 @@
margin-right: 0.25rem;
}

.badge {
display: inline-block;
margin-left: 0.25rem;
:has(> .deprecated),
:has(> .legacy) {
text-decoration-line: line-through !important;
text-decoration-style: dashed;
text-decoration-thickness: 2px;

> span {
opacity: 0.7;
}
}

:has(> .deprecated) {
text-decoration-color: var(--color-danger-600);
}

:has(> .legacy) {
text-decoration-color: var(--color-info-600);
}

:has(> .experimental) {
text-decoration-line: underline !important;
text-decoration-style: dashed;
text-decoration-color: var(--color-warning-600);
text-underline-offset: 3px;
font-style: italic;
}
Loading