feat(m0001): reuse expandable category UI for xi-cleft with yin_yang badge and full point headings
This commit is contained in:
parent
ededd6f0c1
commit
f8308c98ec
|
|
@ -1,8 +1,8 @@
|
||||||
import React from "react";
|
import React from "react";
|
||||||
import { ScrollView } from "react-native";
|
|
||||||
import type { DetailRendererProps } from "../../types/renderer.types";
|
import type { DetailRendererProps } from "../../types/renderer.types";
|
||||||
import { ContentLinkAttributeSections } from "../shared/ContentLinkAttributeSections";
|
import { YuanSourceDetailRenderer } from "./YuanSourceDetailRenderer";
|
||||||
import { asString } from "../helpers/value";
|
|
||||||
import { Hero } from "../shared/Hero";
|
/** Renders Xi-Cleft category details using the shared Overview and expandable Points accordion layout. */
|
||||||
import { DescriptionList, Images, ObjectArrayCards, ObjectArrayTable, ObjectCard, PointCodes, Strings } from "./categoryParts";
|
export function XiCleftDetailRenderer(props: DetailRendererProps) {
|
||||||
export function XiCleftDetailRenderer({content,data,definitions,presentationAttributes}:DetailRendererProps){ return <ScrollView contentContainerStyle={{paddingHorizontal:18,paddingTop:16,paddingBottom:40,gap:14}}><Hero title={asString(data.title)||asString(data.name)||content.title}/><Images data={data}/><PointCodes data={data}/><ObjectArrayTable title="Xi-Cleft Points of the Twelve Channels" value={data.xi_cleft_points_of_the_twelve_channels}/><ObjectArrayTable title="Xi-Cleft Points of Extraordinary Channels" value={data.xi_cleft_points_of_extraordinary_channels}/><ObjectCard title="Clinical Application" value={data.clinical_application}/><ContentLinkAttributeSections data={data} definitions={definitions} presentationAttributes={presentationAttributes}/></ScrollView>; }
|
return <YuanSourceDetailRenderer {...props} fallbackTitle="Xi Cleft" />;
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -45,8 +45,13 @@ interface PointItemProps {
|
||||||
pointsCatalogMap?: Map<string, { contentId: string; title: string }>;
|
pointsCatalogMap?: Map<string, { contentId: string; title: string }>;
|
||||||
}
|
}
|
||||||
|
|
||||||
function sanitizeMeridianHeading(meridian: string, chineseName: string): string {
|
function formatPointHeading(
|
||||||
|
meridian: string,
|
||||||
|
chineseName: string,
|
||||||
|
pointCode?: string,
|
||||||
|
): string {
|
||||||
const cleanChinese = chineseName.replace(/^\((.*)\)$/, "$1").trim();
|
const cleanChinese = chineseName.replace(/^\((.*)\)$/, "$1").trim();
|
||||||
|
const cleanCode = (pointCode || "").trim();
|
||||||
|
|
||||||
// Strip meridian abbreviation codes or point codes in parentheses,
|
// Strip meridian abbreviation codes or point codes in parentheses,
|
||||||
// e.g. (ST), (LU-9), (LI), (LV), (LR), (PC), (GB), (HT), etc.
|
// e.g. (ST), (LU-9), (LI), (LV), (LR), (PC), (GB), (HT), etc.
|
||||||
|
|
@ -55,14 +60,24 @@ function sanitizeMeridianHeading(meridian: string, chineseName: string): string
|
||||||
.replace(/\s+/g, " ")
|
.replace(/\s+/g, " ")
|
||||||
.trim();
|
.trim();
|
||||||
|
|
||||||
if (cleanedMeridian && cleanChinese) {
|
const parts: string[] = [];
|
||||||
if (cleanedMeridian.toLowerCase().includes(cleanChinese.toLowerCase())) {
|
if (cleanedMeridian) {
|
||||||
return cleanedMeridian;
|
parts.push(cleanedMeridian);
|
||||||
}
|
}
|
||||||
return `${cleanedMeridian} (${cleanChinese})`;
|
if (
|
||||||
|
cleanCode &&
|
||||||
|
!cleanedMeridian.toLowerCase().includes(cleanCode.toLowerCase())
|
||||||
|
) {
|
||||||
|
parts.push(cleanCode);
|
||||||
|
}
|
||||||
|
if (
|
||||||
|
cleanChinese &&
|
||||||
|
!cleanedMeridian.toLowerCase().includes(cleanChinese.toLowerCase())
|
||||||
|
) {
|
||||||
|
parts.push(`(${cleanChinese})`);
|
||||||
}
|
}
|
||||||
|
|
||||||
return cleanedMeridian || cleanChinese || "Point";
|
return parts.join(" ") || "Point";
|
||||||
}
|
}
|
||||||
|
|
||||||
function PointAccordionCard({
|
function PointAccordionCard({
|
||||||
|
|
@ -77,18 +92,14 @@ function PointAccordionCard({
|
||||||
const meridian = asString(item.meridian).trim();
|
const meridian = asString(item.meridian).trim();
|
||||||
const chineseName = asString(item.chinese_name).trim();
|
const chineseName = asString(item.chinese_name).trim();
|
||||||
const element = asString(item.element).trim();
|
const element = asString(item.element).trim();
|
||||||
|
const yinYang = asString(item.yin_yang).trim();
|
||||||
const caution = asString(item.caution).trim();
|
const caution = asString(item.caution).trim();
|
||||||
const cautionList = asStringArray(item.caution);
|
const cautionList = asStringArray(item.caution);
|
||||||
|
|
||||||
const actions = asStringArray(item.actions);
|
const actions = asStringArray(item.actions);
|
||||||
const indications = asStringArray(item.indications);
|
const indications = asStringArray(item.indications);
|
||||||
|
|
||||||
// Format header title: e.g. "Stomach (Chongyang)", "Lung (Taiyuan)"
|
// Resolve point reference for linkable button and heading label
|
||||||
const title = useMemo(() => {
|
|
||||||
return sanitizeMeridianHeading(meridian, chineseName);
|
|
||||||
}, [meridian, chineseName]);
|
|
||||||
|
|
||||||
// Resolve point reference for linkable button
|
|
||||||
const rawPoint = asRecord(item.point);
|
const rawPoint = asRecord(item.point);
|
||||||
const directRef = parseNavigableContentReference(item.point);
|
const directRef = parseNavigableContentReference(item.point);
|
||||||
|
|
||||||
|
|
@ -101,6 +112,11 @@ function PointAccordionCard({
|
||||||
: "") ||
|
: "") ||
|
||||||
"";
|
"";
|
||||||
|
|
||||||
|
// Format header title: e.g. "Lung LU 9 (Taiyuan)"
|
||||||
|
const title = useMemo(() => {
|
||||||
|
return formatPointHeading(meridian, chineseName, pointLabel);
|
||||||
|
}, [meridian, chineseName, pointLabel]);
|
||||||
|
|
||||||
// Construct button display label: e.g. "LU-9 (Taiyuan)" or "LU 9 (Taiyuan)"
|
// Construct button display label: e.g. "LU-9 (Taiyuan)" or "LU 9 (Taiyuan)"
|
||||||
const pointButtonLabel = useMemo(() => {
|
const pointButtonLabel = useMemo(() => {
|
||||||
const baseCode = pointLabel || "Point Details";
|
const baseCode = pointLabel || "Point Details";
|
||||||
|
|
@ -190,6 +206,11 @@ function PointAccordionCard({
|
||||||
<Text style={styles.elementBadgeText}>{element}</Text>
|
<Text style={styles.elementBadgeText}>{element}</Text>
|
||||||
</View>
|
</View>
|
||||||
) : null}
|
) : null}
|
||||||
|
{yinYang ? (
|
||||||
|
<View style={styles.elementBadge}>
|
||||||
|
<Text style={styles.elementBadgeText}>{yinYang}</Text>
|
||||||
|
</View>
|
||||||
|
) : null}
|
||||||
<View style={styles.chevron}>
|
<View style={styles.chevron}>
|
||||||
<Ionicons
|
<Ionicons
|
||||||
name={expanded ? "chevron-up" : "chevron-down"}
|
name={expanded ? "chevron-up" : "chevron-down"}
|
||||||
|
|
@ -266,7 +287,8 @@ export function YuanSourceDetailRenderer({
|
||||||
data,
|
data,
|
||||||
definitions,
|
definitions,
|
||||||
presentationAttributes,
|
presentationAttributes,
|
||||||
}: DetailRendererProps) {
|
fallbackTitle = "Yuan Source",
|
||||||
|
}: DetailRendererProps & { fallbackTitle?: string }) {
|
||||||
const accordionDefaultExpanded = useSettingsStore(
|
const accordionDefaultExpanded = useSettingsStore(
|
||||||
(state) => state.accordionDefaultExpanded,
|
(state) => state.accordionDefaultExpanded,
|
||||||
);
|
);
|
||||||
|
|
@ -298,7 +320,7 @@ export function YuanSourceDetailRenderer({
|
||||||
}, [pointsCatalog]);
|
}, [pointsCatalog]);
|
||||||
|
|
||||||
const rawTitle =
|
const rawTitle =
|
||||||
asString(data.title) || asString(data.name) || content.title || "Yuan Source";
|
asString(data.title) || asString(data.name) || content.title || fallbackTitle;
|
||||||
const altNames = asStringArray(data.alt_name);
|
const altNames = asStringArray(data.alt_name);
|
||||||
const descriptionParagraphs = asStringArray(data.description);
|
const descriptionParagraphs = asStringArray(data.description);
|
||||||
const points = asRecordArray(data.points);
|
const points = asRecordArray(data.points);
|
||||||
|
|
@ -345,7 +367,7 @@ export function YuanSourceDetailRenderer({
|
||||||
data={data}
|
data={data}
|
||||||
definitions={definitions}
|
definitions={definitions}
|
||||||
presentationAttributes={presentationAttributes}
|
presentationAttributes={presentationAttributes}
|
||||||
excludeAttributeKeys={["points", "m0001_ct0009.points"]}
|
excludeAttributeKeys={["points", "m0001_ct0009.points", "m0001_ct0011.points"]}
|
||||||
/>
|
/>
|
||||||
</ScrollView>
|
</ScrollView>
|
||||||
);
|
);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue