hd-garden 0.13.0 → 0.13.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -8,10 +8,11 @@ import {
|
|
|
8
8
|
groupHandbookDocs,
|
|
9
9
|
HANDBOOK_SECTIONS,
|
|
10
10
|
HANDBOOK_UI,
|
|
11
|
-
NAV_SHORT_TITLE,
|
|
12
11
|
REFERENCE_SECTION,
|
|
12
|
+
handbookNavLabel,
|
|
13
13
|
isReferencePath,
|
|
14
14
|
handbookPath,
|
|
15
|
+
referenceBadgeSuffix,
|
|
15
16
|
sectionTitle,
|
|
16
17
|
type GardenDocNavItem,
|
|
17
18
|
type HandbookLang,
|
|
@@ -103,7 +104,7 @@ export function GardenDocsNav({
|
|
|
103
104
|
<div className="gdoc-mobile-crumb" aria-hidden="true">
|
|
104
105
|
<span>{sectionTitle(currentSection, lang) ?? t.name}</span>
|
|
105
106
|
<CaretRight size={12} />
|
|
106
|
-
<strong>{currentDoc ? (
|
|
107
|
+
<strong>{currentDoc ? handbookNavLabel(currentDoc, lang) : t.overviewHint}</strong>
|
|
107
108
|
</div>
|
|
108
109
|
</div>
|
|
109
110
|
|
|
@@ -161,7 +162,10 @@ export function GardenDocsNav({
|
|
|
161
162
|
{group.items.map((item) => {
|
|
162
163
|
const active = item.path === currentPath;
|
|
163
164
|
const badge = COMPONENT_BADGE[item.path];
|
|
164
|
-
const label =
|
|
165
|
+
const label = handbookNavLabel(item, lang);
|
|
166
|
+
const referenceSuffix = group.id === REFERENCE_SECTION && badge
|
|
167
|
+
? referenceBadgeSuffix(badge, label)
|
|
168
|
+
: null;
|
|
165
169
|
return (
|
|
166
170
|
<li key={item.path} className={active ? "is-active" : undefined}>
|
|
167
171
|
<Link
|
|
@@ -172,7 +176,11 @@ export function GardenDocsNav({
|
|
|
172
176
|
{badge ? (
|
|
173
177
|
<>
|
|
174
178
|
<code className="gdoc-comp-pill">{badge}</code>
|
|
175
|
-
{group.id === REFERENCE_SECTION ?
|
|
179
|
+
{group.id === REFERENCE_SECTION ? (
|
|
180
|
+
referenceSuffix ? <span className="gdoc-comp-label">{referenceSuffix}</span> : null
|
|
181
|
+
) : (
|
|
182
|
+
<span className="gdoc-comp-label">{label}</span>
|
|
183
|
+
)}
|
|
176
184
|
</>
|
|
177
185
|
) : (
|
|
178
186
|
<span>{label}</span>
|
|
@@ -133,6 +133,31 @@ export const NAV_SHORT_TITLE: Record<string, string> = {
|
|
|
133
133
|
reference: "总览",
|
|
134
134
|
};
|
|
135
135
|
|
|
136
|
+
|
|
137
|
+
/**
|
|
138
|
+
* Reference sidebar shows COMPONENT_BADGE inside <code>. When two pages share a
|
|
139
|
+
* badge (compose + compose-icons), keep the code pill and append the remainder
|
|
140
|
+
* of navTitle / short label after a separator (space / · / dash).
|
|
141
|
+
* Returns the suffix including its leading separator, or null.
|
|
142
|
+
*/
|
|
143
|
+
export function referenceBadgeSuffix(badge: string, label: string): string | null {
|
|
144
|
+
if (!badge || !label || label === badge) return null;
|
|
145
|
+
if (!label.startsWith(badge)) return null;
|
|
146
|
+
const rest = label.slice(badge.length);
|
|
147
|
+
if (!rest || !/^[\s·\-—]/.test(rest)) return null;
|
|
148
|
+
return rest;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
/** Sidebar text label: prefer authored navTitle; ZH may fall back to NAV_SHORT_TITLE. */
|
|
152
|
+
export function handbookNavLabel(item: GardenDocNavItem, lang: HandbookLang): string {
|
|
153
|
+
if (item.navTitle) return item.navTitle;
|
|
154
|
+
if (lang !== "en") {
|
|
155
|
+
const short = NAV_SHORT_TITLE[item.path];
|
|
156
|
+
if (short) return short;
|
|
157
|
+
}
|
|
158
|
+
return item.title;
|
|
159
|
+
}
|
|
160
|
+
|
|
136
161
|
export function groupHandbookDocs<T extends GardenDocNavItem>(docs: T[]) {
|
|
137
162
|
const bySection = new Map<string, T[]>();
|
|
138
163
|
for (const section of HANDBOOK_SECTIONS) {
|
|
@@ -173,7 +173,7 @@ One mini sample per group, then a one-line table for every tag. No per-tag essay
|
|
|
173
173
|
|
|
174
174
|
## Chart examples
|
|
175
175
|
|
|
176
|
-
Play-level chart samples (static eight bars, fusion weight slider) live on [Diagrams · compose](/garden/en/components/compose#compose-chart-active-hours).
|
|
176
|
+
Play-level chart samples (static eight bars, fusion weight slider) live on [Diagrams · compose](/garden/en/components/compose#ui-compose-chart-active-hours).
|
|
177
177
|
|
|
178
178
|
## Limits
|
|
179
179
|
|
|
Binary file
|
package/package.json
CHANGED