Skip to content

feat(minerals): add mineral family and expression system with UI components#5

Merged
Bissbert merged 3 commits intomainfrom
feature/family-expressions-ui
Feb 2, 2026
Merged

feat(minerals): add mineral family and expression system with UI components#5
Bissbert merged 3 commits intomainfrom
feature/family-expressions-ui

Conversation

@Bissbert
Copy link
Contributor

@Bissbert Bissbert commented Feb 2, 2026

Summary

  • Add TypeScript interfaces for MineralFamily and MineralExpression to represent mineral group relationships
  • Implement database query functions: getAllFamilies, getFamilyById, findFamiliesByRI, findFamiliesBySG
  • Create new UI components: FamilyCard, ExpressionSelector, FamilyDetail for browsing mineral families
  • Fix calculator duplicate results by using family-based queries instead of flat mineral lists

Changes

Database Layer (src/lib/db.ts)

  • MineralFamily interface: groups minerals by family with RI/SG ranges, crystal system, hardness
  • MineralExpression interface: represents individual mineral expressions within a family
  • Query functions for retrieving and searching families by optical/physical properties

UI Components

  • FamilyCard: displays a mineral family with its expressions and key properties
  • ExpressionSelector: dropdown for selecting specific expressions within a family
  • FamilyDetail: detailed view of a mineral family with all expressions and properties

Calculator Integration

  • Updated useCalculatorData hook to use family-based queries
  • Eliminates duplicate entries when multiple expressions of the same family match

Test plan

  • Verify getAllFamilies() returns grouped mineral data
  • Check RI/SG searches return families with matching expressions highlighted
  • Confirm calculator results no longer show duplicate family entries
  • Test FamilyCard and FamilyDetail components render correctly

- Add MineralFamily interface for normalized mineral data
- Add MineralExpression interface for CDL variants
- Add MineralFamilyWithExpressions combined type
- Add family-based query functions:
  - getAllFamilies(), getFamilyById(), getFamilyWithExpressions()
  - getExpressionsForFamily(), getExpressionById()
  - getFamiliesBySystem(), searchFamilies()
  - findFamiliesByRI(), findFamiliesBySG() (eliminates duplicates)
  - getFamiliesWithSG(), getFamiliesWithDispersion()
  - getFamilyStats()
- FamilyCard: Gallery card for mineral families with expression count badges
- ExpressionSelector: Horizontal scrollable selector for crystal forms
- FamilyDetail: Full page layout for family detail with expression switching
- Update exports in gallery and minerals index files
Switch RI and SG lookup functions from findMineralsByRI/findMineralsBySG
to findFamiliesByRI/findFamiliesBySG. This prevents duplicate entries
appearing in calculator results (e.g., fluorite, fluorite-octahedron,
fluorite-twin now consolidate into single "Fluorite" entry).

Add familyToGemRef converter to transform MineralFamily to GemReference.
@cloudflare-workers-and-pages
Copy link

Deploying gemmology-dev with  Cloudflare Pages  Cloudflare Pages

Latest commit: 87f7c3e
Status:🚫  Build failed.

View logs

@github-actions
Copy link

github-actions bot commented Feb 2, 2026

🚀 Preview deployed to: https://379a2fd1.gemmology-dev.pages.dev

@Bissbert Bissbert merged commit 4653b42 into main Feb 2, 2026
3 of 4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant