Skip to content

Commit 6b74d94

Browse files
committed
lint issues solved
1 parent ef60849 commit 6b74d94

8 files changed

Lines changed: 170 additions & 147 deletions

File tree

.storybook/main.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ const config: StorybookConfig = {
66
"@storybook/addon-essentials",
77
"@storybook/addon-interactions",
88
"@storybook/addon-webpack5-compiler-swc",
9-
'@storybook/addon-themes',
9+
"@storybook/addon-themes",
1010
],
1111
framework: {
1212
name: "@storybook/react-webpack5",

.storybook/preview.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
1+
import { withThemeByClassName } from "@storybook/addon-themes";
12
import type { Preview } from "@storybook/react";
2-
import { withThemeByClassName } from '@storybook/addon-themes';
3-
43

54
export const decorators = [
65
withThemeByClassName({
76
themes: {
8-
light: 'light-theme',
9-
dark: 'dark-theme',
7+
light: "light-theme",
8+
dark: "dark-theme",
109
},
11-
defaultTheme: 'light',
10+
defaultTheme: "light",
1211
}),
1312
];
1413

package.json

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,7 @@
44
"version": "0.1.0",
55
"author": "Pratik Sharma <sharma.pratik2016@gmail.com>",
66
"license": "MIT",
7-
"keywords": [
8-
"odontogram",
9-
"react",
10-
"dental-chart"
11-
],
7+
"keywords": ["odontogram", "react", "dental-chart"],
128
"publishConfig": {
139
"access": "public"
1410
},
@@ -38,9 +34,7 @@
3834
"import": "./dist/index.mjs"
3935
}
4036
},
41-
"files": [
42-
"dist"
43-
],
37+
"files": ["dist"],
4438
"config": {
4539
"commitizen": {
4640
"path": "./node_modules/@ryansonshine/cz-conventional-changelog"

src/Odontogram.tsx

Lines changed: 62 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import "./styles.css";
2-
import { useCallback, useEffect, useState } from "react";
2+
import { useCallback, useState } from "react";
33
import { teethPaths } from "./data";
44

55
interface TeethProps {
@@ -29,23 +29,55 @@ export interface OdontogramProps {
2929
className?: string;
3030
selectedColor?: string;
3131
hoverColor?: string;
32-
theme: "light" | "dark",
33-
colors: Record<string, string>,
32+
theme: "light" | "dark";
33+
colors: Record<string, string>;
3434
notation?: "FDI" | "Universal" | "Palmer";
3535
}
3636

37-
38-
function convertFDIToNotation(fdi: string, notation: "FDI" | "Universal" | "Palmer") {
37+
function convertFDIToNotation(
38+
fdi: string,
39+
notation: "FDI" | "Universal" | "Palmer",
40+
) {
3941
const num = fdi.replace("teeth-", "");
4042

4143
const fdiToUniversal: Record<string, number> = {
42-
"11": 8, "12": 7, "13": 6, "14": 5, "15": 4, "16": 3, "17": 2, "18": 1,
43-
"21": 9, "22": 10, "23": 11, "24": 12, "25": 13, "26": 14, "27": 15, "28": 16,
44-
"31": 24, "32": 23, "33": 22, "34": 21, "35": 20, "36": 19, "37": 18, "38": 17,
45-
"41": 25, "42": 26, "43": 27, "44": 28, "45": 29, "46": 30, "47": 31, "48": 32,
44+
"11": 8,
45+
"12": 7,
46+
"13": 6,
47+
"14": 5,
48+
"15": 4,
49+
"16": 3,
50+
"17": 2,
51+
"18": 1,
52+
"21": 9,
53+
"22": 10,
54+
"23": 11,
55+
"24": 12,
56+
"25": 13,
57+
"26": 14,
58+
"27": 15,
59+
"28": 16,
60+
"31": 24,
61+
"32": 23,
62+
"33": 22,
63+
"34": 21,
64+
"35": 20,
65+
"36": 19,
66+
"37": 18,
67+
"38": 17,
68+
"41": 25,
69+
"42": 26,
70+
"43": 27,
71+
"44": 28,
72+
"45": 29,
73+
"46": 30,
74+
"47": 31,
75+
"48": 32,
4676
};
4777

48-
if (notation === "Universal") return String(fdiToUniversal[num] ?? num);
78+
if (notation === "Universal") {
79+
return String(fdiToUniversal[num] ?? num);
80+
}
4981

5082
if (notation === "Palmer") {
5183
const quadrant = num[0];
@@ -62,7 +94,6 @@ function convertFDIToNotation(fdi: string, notation: "FDI" | "Universal" | "Palm
6294
return num;
6395
}
6496

65-
6697
function getToothNotations(fdi: string) {
6798
const num = fdi.replace("teeth-", "");
6899
const universal = convertFDIToNotation(fdi, "Universal");
@@ -74,7 +105,6 @@ function getToothNotations(fdi: string) {
74105
};
75106
}
76107

77-
78108
const Teeth = ({
79109
name,
80110
outlinePath,
@@ -83,8 +113,7 @@ const Teeth = ({
83113
selected,
84114
onClick,
85115
onKeyDown,
86-
children
87-
116+
children,
88117
}: TeethProps) => (
89118
<g
90119
className={`${name} ${selected ? "selected" : ""}`}
@@ -130,30 +159,26 @@ const Teeth = ({
130159
</g>
131160
);
132161

133-
134162
const Odontogram: React.FC<OdontogramProps> = ({
135163
defaultSelected = [],
136164
onChange,
137165
className = "",
138166
theme = "light",
139167
colors = {},
140168
notation,
141-
142169
}) => {
143-
144170
const themeColors =
145171
theme === "dark"
146172
? {
147-
"--dark-blue": "#aab6ff",
148-
"--base-blue": "#d0d5f6",
149-
"--light-blue": "#5361e6",
150-
}
173+
"--dark-blue": "#aab6ff",
174+
"--base-blue": "#d0d5f6",
175+
"--light-blue": "#5361e6",
176+
}
151177
: {
152-
"--dark-blue": "#3e5edc",
153-
"--base-blue": "#8a98be",
154-
"--light-blue": "#c6ccf8",
155-
};
156-
178+
"--dark-blue": "#3e5edc",
179+
"--base-blue": "#8a98be",
180+
"--light-blue": "#c6ccf8",
181+
};
157182

158183
const [selected, setSelected] = useState<Set<string>>(
159184
new Set(defaultSelected),
@@ -181,7 +206,7 @@ const Odontogram: React.FC<OdontogramProps> = ({
181206
return updated;
182207
});
183208
},
184-
[onChange]
209+
[onChange],
185210
);
186211
const handleKeyDown = useCallback(
187212
(e: React.KeyboardEvent<SVGGElement>, name: string) => {
@@ -225,7 +250,7 @@ const Odontogram: React.FC<OdontogramProps> = ({
225250
<div
226251
className={`Odontogram ${theme === "dark" ? "dark-theme" : ""}`}
227252
style={{
228-
...finalColors as React.CSSProperties,
253+
...(finalColors as React.CSSProperties),
229254
width: "100%",
230255
maxWidth: 300,
231256
margin: "0 auto",
@@ -266,12 +291,17 @@ const Odontogram: React.FC<OdontogramProps> = ({
266291
);
267292
};
268293

269-
270294
function mapToCssVars(colors: Record<string, string | undefined>) {
271295
const cssVars: Record<string, string> = {};
272-
if (colors.darkBlue) cssVars["--dark-blue"] = colors.darkBlue;
273-
if (colors.baseBlue) cssVars["--base-blue"] = colors.baseBlue;
274-
if (colors.lightBlue) cssVars["--light-blue"] = colors.lightBlue;
296+
if (colors.darkBlue) {
297+
cssVars["--dark-blue"] = colors.darkBlue;
298+
}
299+
if (colors.baseBlue) {
300+
cssVars["--base-blue"] = colors.baseBlue;
301+
}
302+
if (colors.lightBlue) {
303+
cssVars["--light-blue"] = colors.lightBlue;
304+
}
275305
return cssVars;
276306
}
277307

0 commit comments

Comments
 (0)