feat(m0001): reuse expandable category UI for xi-cleft with yin_yang badge and full point headings

This commit is contained in:
ShivaniKhaire 2026-12-04 14:05:26 +05:30
parent ededd6f0c1
commit f8308c98ec
2 changed files with 44 additions and 22 deletions

View File

@ -1,8 +1,8 @@
import React from "react";
import { ScrollView } from "react-native";
import type { DetailRendererProps } from "../../types/renderer.types";
import { ContentLinkAttributeSections } from "../shared/ContentLinkAttributeSections";
import { asString } from "../helpers/value";
import { Hero } from "../shared/Hero";
import { DescriptionList, Images, ObjectArrayCards, ObjectArrayTable, ObjectCard, PointCodes, Strings } from "./categoryParts";
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>; }
import { YuanSourceDetailRenderer } from "./YuanSourceDetailRenderer";
/** Renders Xi-Cleft category details using the shared Overview and expandable Points accordion layout. */
export function XiCleftDetailRenderer(props: DetailRendererProps) {
return <YuanSourceDetailRenderer {...props} fallbackTitle="Xi Cleft" />;
}

View File

@ -45,8 +45,13 @@ interface PointItemProps {
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 cleanCode = (pointCode || "").trim();
// Strip meridian abbreviation codes or point codes in parentheses,
// 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, " ")
.trim();
if (cleanedMeridian && cleanChinese) {
if (cleanedMeridian.toLowerCase().includes(cleanChinese.toLowerCase())) {
return cleanedMeridian;
}
return `${cleanedMeridian} (${cleanChinese})`;
const parts: string[] = [];
if (cleanedMeridian) {
parts.push(cleanedMeridian);
}
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({
@ -77,18 +92,14 @@ function PointAccordionCard({
const meridian = asString(item.meridian).trim();
const chineseName = asString(item.chinese_name).trim();
const element = asString(item.element).trim();
const yinYang = asString(item.yin_yang).trim();
const caution = asString(item.caution).trim();
const cautionList = asStringArray(item.caution);
const actions = asStringArray(item.actions);
const indications = asStringArray(item.indications);
// Format header title: e.g. "Stomach (Chongyang)", "Lung (Taiyuan)"
const title = useMemo(() => {
return sanitizeMeridianHeading(meridian, chineseName);
}, [meridian, chineseName]);
// Resolve point reference for linkable button
// Resolve point reference for linkable button and heading label
const rawPoint = asRecord(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)"
const pointButtonLabel = useMemo(() => {
const baseCode = pointLabel || "Point Details";
@ -190,6 +206,11 @@ function PointAccordionCard({
<Text style={styles.elementBadgeText}>{element}</Text>
</View>
) : null}
{yinYang ? (
<View style={styles.elementBadge}>
<Text style={styles.elementBadgeText}>{yinYang}</Text>
</View>
) : null}
<View style={styles.chevron}>
<Ionicons
name={expanded ? "chevron-up" : "chevron-down"}
@ -266,7 +287,8 @@ export function YuanSourceDetailRenderer({
data,
definitions,
presentationAttributes,
}: DetailRendererProps) {
fallbackTitle = "Yuan Source",
}: DetailRendererProps & { fallbackTitle?: string }) {
const accordionDefaultExpanded = useSettingsStore(
(state) => state.accordionDefaultExpanded,
);
@ -298,7 +320,7 @@ export function YuanSourceDetailRenderer({
}, [pointsCatalog]);
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 descriptionParagraphs = asStringArray(data.description);
const points = asRecordArray(data.points);
@ -345,7 +367,7 @@ export function YuanSourceDetailRenderer({
data={data}
definitions={definitions}
presentationAttributes={presentationAttributes}
excludeAttributeKeys={["points", "m0001_ct0009.points"]}
excludeAttributeKeys={["points", "m0001_ct0009.points", "m0001_ct0011.points"]}
/>
</ScrollView>
);