Skip to content

Commit 0777db0

Browse files
committed
refactor: extract level config to shared module
1 parent dee3d57 commit 0777db0

File tree

3 files changed

+15
-28
lines changed

3 files changed

+15
-28
lines changed

src/features/sidebar/view/internal/diffbar/components/DiffDialog.tsx

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -12,20 +12,7 @@ import {
1212
} from "@mui/material"
1313
import { softPaperSx } from "@/common/theme/theme"
1414
import MonoQuotedText from "./MonoQuotedText"
15-
16-
type Level = 1 | 2 | 3
17-
18-
const getLevelConfig = (level: Level) => {
19-
switch (level) {
20-
case 3:
21-
return { label: "breaking", color: "#e88388" }
22-
case 2:
23-
return { label: "warn", color: "#dbab79" }
24-
case 1:
25-
default:
26-
return { label: "info", color: "#66c2cd" }
27-
}
28-
}
15+
import { getLevelConfig, Level } from "./levelConfig"
2916

3017
interface ChangeDetails {
3118
path?: string

src/features/sidebar/view/internal/diffbar/components/DiffListItem.tsx

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,7 @@
33
import { Box, Typography, ListItem, ListItemButton, Stack } from "@mui/material"
44
import MenuItemHover from "@/common/ui/MenuItemHover"
55
import MonoQuotedText from "./MonoQuotedText"
6-
7-
type Level = 1 | 2 | 3
8-
9-
const getLevelConfig = (level: Level) => {
10-
switch (level) {
11-
case 3:
12-
return { label: "breaking", color: "#e88388" }
13-
case 2:
14-
return { label: "warn", color: "#dbab79" }
15-
case 1:
16-
default:
17-
return { label: "info", color: "#66c2cd" }
18-
}
19-
}
6+
import { getLevelConfig, Level } from "./levelConfig"
207

218
const DiffListItem = ({
229
path,
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
export type Level = 1 | 2 | 3
2+
3+
export const getLevelConfig = (level: Level) => {
4+
switch (level) {
5+
case 3:
6+
return { label: "breaking", color: "#e88388" }
7+
case 2:
8+
return { label: "warn", color: "#dbab79" }
9+
case 1:
10+
default:
11+
return { label: "info", color: "#66c2cd" }
12+
}
13+
}

0 commit comments

Comments
 (0)