Skip to content

Commit e618ace

Browse files
committed
feat(metabar): subtle indicators
1 parent 23ffbb1 commit e618ace

2 files changed

Lines changed: 33 additions & 23 deletions

File tree

src/generators/web/ui/components/MetaBar/index.jsx

Lines changed: 8 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import { CodeBracketIcon, DocumentIcon } from '@heroicons/react/24/outline';
2-
import Badge from '@node-core/ui-components/Common/Badge';
32
import MetaBar from '@node-core/ui-components/Containers/MetaBar';
43
import GitHubIcon from '@node-core/ui-components/Icons/Social/GitHub';
54

@@ -12,16 +11,19 @@ const iconMap = {
1211

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

22-
const STABILITY_KINDS = ['error', 'warning', null, 'info'];
23-
const STABILITY_LABELS = ['D', 'E', null, 'L'];
24-
21+
const STABILITY_CLASS_MAP = [
22+
styles.deprecated,
23+
styles.experimental,
24+
undefined,
25+
styles.legacy,
26+
];
2527
/**
2628
* MetaBar component that displays table of contents and page metadata
2729
* @param {MetaBarProps} props - Component props
@@ -38,21 +40,7 @@ export default ({
3840
headings={{
3941
items: headings.map(({ slug, value, stability, ...heading }) => ({
4042
...heading,
41-
value:
42-
stability !== 2 ? (
43-
<>
44-
{value}
45-
<Badge
46-
size="small"
47-
className={styles.badge}
48-
kind={STABILITY_KINDS[stability]}
49-
>
50-
{STABILITY_LABELS[stability]}
51-
</Badge>
52-
</>
53-
) : (
54-
value
55-
),
43+
value: <span className={STABILITY_CLASS_MAP[stability]}>{value}</span>,
5644
data: { id: slug },
5745
})),
5846
}}

src/generators/web/ui/components/MetaBar/index.module.css

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,29 @@
55
margin-right: 0.25rem;
66
}
77

8-
.badge {
9-
display: inline-block;
10-
margin-left: 0.25rem;
8+
:has(> .deprecated),
9+
:has(> .legacy) {
10+
text-decoration-line: line-through !important;
11+
text-decoration-style: dashed;
12+
text-decoration-thickness: 2px;
13+
14+
> span {
15+
opacity: 0.7;
16+
}
17+
}
18+
19+
:has(> .deprecated) {
20+
text-decoration-color: var(--color-danger-600);
21+
}
22+
23+
:has(> .legacy) {
24+
text-decoration-color: var(--color-info-600);
25+
}
26+
27+
:has(> .experimental) {
28+
text-decoration-line: underline !important;
29+
text-decoration-style: dashed;
30+
text-decoration-color: var(--color-warning-600);
31+
text-underline-offset: 3px;
32+
font-style: italic;
1133
}

0 commit comments

Comments
 (0)