diff --git a/src/features/content/renderers/details/YuanSourceDetailRenderer.tsx b/src/features/content/renderers/details/YuanSourceDetailRenderer.tsx index ee3f846..cde6065 100644 --- a/src/features/content/renderers/details/YuanSourceDetailRenderer.tsx +++ b/src/features/content/renderers/details/YuanSourceDetailRenderer.tsx @@ -343,6 +343,7 @@ export function YuanSourceDetailRenderer({ {descriptionParagraphs.length > 0 ? ( ) : null} diff --git a/src/features/content/renderers/shared/BulletList.tsx b/src/features/content/renderers/shared/BulletList.tsx index f8b35a9..4233d75 100644 --- a/src/features/content/renderers/shared/BulletList.tsx +++ b/src/features/content/renderers/shared/BulletList.tsx @@ -1,16 +1,60 @@ import React from "react"; -import { StyleSheet, Text, View } from "react-native"; +import { + StyleProp, + StyleSheet, + Text, + TextStyle, + View, + ViewStyle, +} from "react-native"; import { Colors } from "@/theme"; -export function BulletList({ items }: { items: string[] }) { +export interface BulletListProps { + items: string[]; + listStyle?: StyleProp; + dotStyle?: StyleProp; + textStyle?: StyleProp; + boldColonPrefix?: boolean; +} + +const COLON_PREFIX_RE = /^([A-Za-z][A-Za-z0-9 &/().-]{1,32}:)([\s\S]*)$/; + +function renderBulletText( + item: string, + textStyle?: StyleProp, + boldColonPrefix?: boolean, +) { + if (!boldColonPrefix) { + return {item}; + } + const match = COLON_PREFIX_RE.exec(item); + if (!match) { + return {item}; + } + return ( + + {match[1]} + {match[2]} + + ); +} + +/** Renders a bulleted list with optional custom typography and bold label prefixes. */ +export function BulletList({ + items, + listStyle, + dotStyle, + textStyle, + boldColonPrefix = false, +}: BulletListProps) { if (!items.length) return null; return ( - + {items.map((item, index) => ( - - {item} + + {renderBulletText(item, textStyle, boldColonPrefix)} ))} @@ -28,4 +72,5 @@ const styles = StyleSheet.create({ backgroundColor: Colors.primary, }, text: { flex: 1, fontSize: 16, lineHeight: 25, color: "#334155" }, + prefix: { fontWeight: "700", color: Colors.textPrimary }, }); diff --git a/src/features/content/renderers/shared/OverviewCard.tsx b/src/features/content/renderers/shared/OverviewCard.tsx index 8b89cfb..2fcc474 100644 --- a/src/features/content/renderers/shared/OverviewCard.tsx +++ b/src/features/content/renderers/shared/OverviewCard.tsx @@ -11,6 +11,7 @@ import { Ionicons } from "@expo/vector-icons"; import { moderateScale, verticalScale } from "react-native-size-matters"; import { Colors } from "@/theme"; +import { BulletList } from "./BulletList"; export interface OverviewCardProps { title?: string; @@ -19,6 +20,8 @@ export interface OverviewCardProps { iconSize?: number; text?: string | null; paragraphs?: Array; + variant?: "paragraphs" | "bullets"; + boldBulletPrefix?: boolean; children?: React.ReactNode; style?: StyleProp; titleStyle?: StyleProp; @@ -32,14 +35,16 @@ export function OverviewCard({ iconSize = moderateScale(20), text, paragraphs, + variant = "paragraphs", + boldBulletPrefix = true, children, style, titleStyle, textStyle, }: OverviewCardProps) { - const filteredParagraphs = paragraphs?.filter( - (p): p is string => typeof p === "string" && p.trim().length > 0, - ); + const filteredParagraphs = paragraphs + ?.filter((p): p is string => typeof p === "string" && p.trim().length > 0) + .map((p) => p.replace(/\n[ \t]+/g, "\n").trim()); const hasText = typeof text === "string" && text.trim().length > 0; const hasParagraphs = @@ -62,19 +67,27 @@ export function OverviewCard({ {text} ) : null} - {hasParagraphs - ? filteredParagraphs.map((para, index) => ( - - {para} - - )) - : null} + {hasParagraphs && variant === "bullets" ? ( + + ) : hasParagraphs ? ( + filteredParagraphs.map((para, index) => ( + + {para} + + )) + ) : null} {children} @@ -111,5 +124,17 @@ const styles = StyleSheet.create({ color: Colors.textSecondary, marginTop: verticalScale(8), }, + paragraphSpacing: { + marginTop: verticalScale(8), + }, + bulletList: { + gap: verticalScale(7), + }, + bulletDot: { + width: moderateScale(5), + height: moderateScale(5), + borderRadius: moderateScale(2.5), + marginTop: moderateScale(7.5), + }, });