feat(components): add tabs component#17
Conversation
Greptile SummaryThis PR adds a
Confidence Score: 3/5Safe to merge the UI components and styling; hold on cleanup-headings.ts until the two parsing bugs are addressed The Tabs/Tab components and CSS changes are straightforward and low-risk. The concern is in cleanup-headings.ts: a multi-line Tabs tag breaks depth tracking entirely, and code blocks containing markdown-style headings shift the positional index so a real heading can be incorrectly flagged as insideTabs and removed from the TOC — which is a silent, hard-to-notice regression compared to the previous wrong-text behaviour. src/lib/cleanup-headings.ts — both the multi-line tag detection and the code-block index drift need fixes before this is reliable in production docs Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
A["MDX page rendered by Astro"] --> B["Astro headings array\n(all depths, JSX-evaluated)"]
A --> C["Raw body string\npassed to cleanupHeadings"]
C --> D["parseHeadings()\nline-by-line scan"]
D --> E{"Line matches\n<Tabs …> ?"}
E -->|"single-line tag"| F["tabsDepth++"]
E -->|"multi-line tag ⚠️"| G["tabsDepth unchanged\n(bug: tag not detected)"]
D --> H{"Line in fenced\ncode block?"}
H -->|"No guard ⚠️"| I["## heading counted\nin parsed array"]
D --> J["ParsedHeading[]\nwith insideTabs flag"]
B --> K["filter depth 2-3"]
K --> L["map(h, index) →\nparsed[index] lookup"]
J --> L
L --> M{"Index aligned?\n(code-block headings\ncause drift ⚠️)"}
M -->|"Aligned"| N["insideTabs set correctly"]
M -->|"Drifted"| O["Wrong insideTabs flag\non real heading"]
N --> P["filter !insideTabs"]
O --> P
P --> Q["Final TOC headings"]
subgraph Browser ["Browser – Tab Component"]
R["Tabs.astro\nrenders empty tablist + panels"] --> S["initRoot() runs on\nastro:page-load"]
S --> T["Builds li role=tab\nwith UID-based IDs"]
T --> U["render() sets\naria-selected / data-active"]
U --> V["CSS shows active panel\nhides rest"]
end
Reviews (1): Last reviewed commit: "add barrel for tabs" | Re-trigger Greptile |
Adds a tab component. Needed to start migrating content.