|
1 | 1 |
|
2 | 2 |
|
3 | | -# `react-odontogram` |
| 3 | +# 🦷 `react-odontogram` |
4 | 4 |
|
5 | | -[](https://www.npmjs.com/package/react-odontogram) |
6 | | -[](https://www.npmjs.com/package/react-odontogram) |
| 5 | +[](https://www.npmjs.com/package/react-odontogram) |
| 6 | +[](https://www.npmjs.com/package/react-odontogram) |
7 | 7 | [](https://biomathcode.github.io/react-odontogram) |
8 | 8 |
|
| 9 | +A modern, interactive **React Odontogram** component for dental chart visualization and data collection. |
| 10 | +Built with SVG and React hooks — fully customizable, accessible, and designed for clinical or academic applications. |
9 | 11 |
|
10 | 12 | --- |
11 | | -## Demo |
12 | 13 |
|
13 | | -Check out the live Storybook demo: |
14 | | -[https://biomathcode.github.io/react-odontogram](https://biomathcode.github.io/react-odontogram) |
| 14 | +## 🧩 Demo |
15 | 15 |
|
| 16 | +👉 **Live Preview:** [https://biomathcode.github.io/react-odontogram](https://biomathcode.github.io/react-odontogram) |
16 | 17 |
|
17 | 18 | --- |
18 | 19 |
|
19 | | -## Installation |
| 20 | +## 📦 Installation |
20 | 21 |
|
21 | 22 | ```bash |
22 | 23 | # Using npm |
23 | | -npm install react-odontogram |
| 24 | +npm install react-odontogram |
24 | 25 |
|
25 | 26 | # Using pnpm |
26 | | -pnpm add react-odontogram |
| 27 | +pnpm add react-odontogram |
27 | 28 |
|
28 | 29 | # Using yarn |
29 | | -yarn add react-odontogram |
| 30 | +yarn add react-odontogram |
30 | 31 | ``` |
31 | 32 |
|
32 | 33 | > Make sure you have `react` and `react-dom` installed as peer dependencies. |
33 | 34 |
|
| 35 | +--- |
| 36 | + |
| 37 | +## 🚀 Quick Start |
| 38 | + |
| 39 | +```tsx |
| 40 | +import { Odontogram } from "react-odontogram"; |
| 41 | + |
| 42 | +export default function App() { |
| 43 | + const handleChange = (selectedTeeth) => { |
| 44 | + console.log(selectedTeeth); |
| 45 | + /* |
| 46 | + Example output: |
| 47 | + [ |
| 48 | + { |
| 49 | + "id": "teeth-21", |
| 50 | + "notations": { |
| 51 | + "fdi": "21", |
| 52 | + "universal": "9", |
| 53 | + "palmer": "1UL" |
| 54 | + }, |
| 55 | + "type": "Central Incisor" |
| 56 | + }, |
| 57 | + { |
| 58 | + "id": "teeth-12", |
| 59 | + "notations": { |
| 60 | + "fdi": "12", |
| 61 | + "universal": "7", |
| 62 | + "palmer": "2UR" |
| 63 | + }, |
| 64 | + "type": "Lateral Incisor" |
| 65 | + } |
| 66 | + ] |
| 67 | + */ |
| 68 | + }; |
| 69 | + |
| 70 | + return <Odontogram onChange={handleChange} />; |
| 71 | +} |
| 72 | +``` |
| 73 | + |
| 74 | +--- |
| 75 | + |
| 76 | +## 🧠 onChange Return Type |
| 77 | + |
| 78 | +The `onChange` callback returns an **array of selected teeth objects**: |
| 79 | + |
| 80 | +```ts |
| 81 | +type ToothSelection = { |
| 82 | + id: string; |
| 83 | + notations: { |
| 84 | + fdi: string; |
| 85 | + universal: string; |
| 86 | + palmer: string; |
| 87 | + }; |
| 88 | + type: string; |
| 89 | +}; |
| 90 | +``` |
34 | 91 |
|
| 92 | +Example JSON output: |
| 93 | + |
| 94 | +```json |
| 95 | +[ |
| 96 | + { |
| 97 | + "id": "teeth-21", |
| 98 | + "notations": { |
| 99 | + "fdi": "21", |
| 100 | + "universal": "9", |
| 101 | + "palmer": "1UL" |
| 102 | + }, |
| 103 | + "type": "Central Incisor" |
| 104 | + }, |
| 105 | + { |
| 106 | + "id": "teeth-12", |
| 107 | + "notations": { |
| 108 | + "fdi": "12", |
| 109 | + "universal": "7", |
| 110 | + "palmer": "2UR" |
| 111 | + }, |
| 112 | + "type": "Lateral Incisor" |
| 113 | + } |
| 114 | +] |
| 115 | +``` |
| 116 | + |
| 117 | +--- |
| 118 | + |
| 119 | +## ⚙️ Props |
| 120 | + |
| 121 | +| Prop | Type | Default | Description | |
| 122 | +| ----------------- | ------------------------------------------- | ------- | ------------------------------------------------------- | |
| 123 | +| `onChange` | `(selectedTeeth: ToothSelection[]) => void` | — | Triggered whenever the user selects or deselects teeth. | |
| 124 | +| `initialSelected` | `string[]` | `[]` | Array of tooth IDs to preselect. | |
| 125 | +| `readOnly` | `boolean` | `false` | Makes the odontogram non-interactive (view-only). | |
| 126 | +| `className` | `string` | — | Optional class for custom styling. | |
| 127 | + |
| 128 | +--- |
| 129 | + |
| 130 | +## 🦷 Tooth Data Model |
| 131 | + |
| 132 | +Each tooth is internally defined in a structured format: |
| 133 | + |
| 134 | +```ts |
| 135 | +{ |
| 136 | + id: "teeth-21", |
| 137 | + name: "21", |
| 138 | + type: "Central Incisor", |
| 139 | + notations: { |
| 140 | + fdi: "21", |
| 141 | + universal: "9", |
| 142 | + palmer: "1UL" |
| 143 | + }, |
| 144 | + outlinePath: "...", |
| 145 | + shadowPath: "...", |
| 146 | + lineHighlightPath: "..." |
| 147 | +} |
| 148 | +``` |
35 | 149 |
|
| 150 | +This makes it easy to extend or customize if you fork the library. |
| 151 | + |
| 152 | +--- |
| 153 | + |
| 154 | +## 🧪 Development |
| 155 | + |
| 156 | +Run locally: |
| 157 | + |
| 158 | +```bash |
| 159 | +git clone https://github.com/biomathcode/react-odontogram.git |
| 160 | +cd react-odontogram |
| 161 | +pnpm install |
| 162 | +pnpm dev |
| 163 | +``` |
| 164 | + |
| 165 | +To preview Storybook: |
| 166 | + |
| 167 | +```bash |
| 168 | +pnpm storybook |
| 169 | +``` |
| 170 | + |
| 171 | +--- |
| 172 | + |
| 173 | +## 🪶 License |
| 174 | + |
| 175 | +MIT © [biomathcode](https://github.com/biomathcode) |
| 176 | + |
| 177 | +--- |
36 | 178 |
|
| 179 | +## 💬 Feedback |
37 | 180 |
|
| 181 | +If this library helps your dental project, please ⭐ the repo or open issues/PRs for enhancements! |
38 | 182 |
|
39 | 183 |
|
0 commit comments