Skip to content

Commit 4fd6f11

Browse files
authored
fix: inline icons from @mui/icons-material (#147)
* Remove @mui/icons-material * Merge all icons to Icons file
1 parent 16e0903 commit 4fd6f11

File tree

7 files changed

+55
-38
lines changed

7 files changed

+55
-38
lines changed

package.json

-1
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,6 @@
6161
"dependencies": {
6262
"@emotion/react": "^11.10.5",
6363
"@emotion/styled": "^11.10.5",
64-
"@mui/icons-material": "^5.11.0",
6564
"@mui/material": "^5.11.4",
6665
"copy-to-clipboard": "^3.3.3",
6766
"group-items": "^2.2.0",

rollup.config.ts

-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ const external = [
2626
'@emotion/styled',
2727
'@emotion/react/jsx-runtime',
2828
'@emotion/react/jsx-dev-runtime',
29-
'@mui/icons-material',
3029
'@mui/material',
3130
'@mui/material/styles',
3231
'copy-to-clipboard',

src/components/DataKeyPair.tsx

+8-8
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,3 @@
1-
import {
2-
Check as CheckIcon,
3-
ChevronRight as ChevronRightIcon,
4-
Close as CloseIcon,
5-
ContentCopy as ContentCopyIcon,
6-
Edit as EditIcon,
7-
ExpandMore as ExpandMoreIcon
8-
} from '@mui/icons-material'
91
import { Box, styled } from '@mui/material'
102
import type React from 'react'
113
import { useCallback, useMemo, useState } from 'react'
@@ -17,6 +9,14 @@ import { useJsonViewerStore } from '../stores/JsonViewerStore'
179
import { useTypeComponents } from '../stores/typeRegistry'
1810
import type { DataItemProps } from '../type'
1911
import { getValueSize } from '../utils'
12+
import {
13+
CheckIcon,
14+
ChevronRightIcon,
15+
CloseIcon,
16+
ContentCopyIcon,
17+
EditIcon,
18+
ExpandMoreIcon
19+
} from './Icons'
2020
import { DataBox } from './mui/DataBox'
2121

2222
export type DataKeyPairProps = {

src/components/DataTypes/Object.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import { useJsonViewerStore } from '../../stores/JsonViewerStore'
88
import type { DataItemProps } from '../../type'
99
import { getValueSize } from '../../utils'
1010
import { DataKeyPair } from '../DataKeyPair'
11-
import { CircularArrowsIcon } from '../icons/CircularArrowsIcon'
11+
import { CircularArrowsIcon } from '../Icons'
1212
import { DataBox } from '../mui/DataBox'
1313

1414
const objectLb = '{'

src/components/Icons.tsx

+46
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
import { SvgIcon, SvgIconProps } from '@mui/material'
2+
import type React from 'react'
3+
4+
const BaseIcon: React.FC<SvgIconProps> = ({ d, ...props }) => {
5+
return (
6+
<SvgIcon {...props}>
7+
<path d={d}/>
8+
</SvgIcon>
9+
)
10+
}
11+
12+
const Check = 'M9 16.17 4.83 12l-1.42 1.41L9 19 21 7l-1.41-1.41z'
13+
const ChevronRight = 'M10 6 8.59 7.41 13.17 12l-4.58 4.59L10 18l6-6z'
14+
const CircularArrows = 'M 12 2 C 10.615 1.998 9.214625 2.2867656 7.890625 2.8847656 L 8.9003906 4.6328125 C 9.9043906 4.2098125 10.957 3.998 12 4 C 15.080783 4 17.738521 5.7633175 19.074219 8.3222656 L 17.125 9 L 21.25 11 L 22.875 7 L 20.998047 7.6523438 C 19.377701 4.3110398 15.95585 2 12 2 z M 6.5097656 4.4882812 L 2.2324219 5.0820312 L 3.734375 6.3808594 C 1.6515335 9.4550558 1.3615962 13.574578 3.3398438 17 C 4.0308437 18.201 4.9801562 19.268234 6.1601562 20.115234 L 7.1699219 18.367188 C 6.3019219 17.710187 5.5922656 16.904 5.0722656 16 C 3.5320014 13.332354 3.729203 10.148679 5.2773438 7.7128906 L 6.8398438 9.0625 L 6.5097656 4.4882812 z M 19.929688 13 C 19.794687 14.08 19.450734 15.098 18.927734 16 C 17.386985 18.668487 14.531361 20.090637 11.646484 19.966797 L 12.035156 17.9375 L 8.2402344 20.511719 L 10.892578 23.917969 L 11.265625 21.966797 C 14.968963 22.233766 18.681899 20.426323 20.660156 17 C 21.355156 15.801 21.805219 14.445 21.949219 13 L 19.929688 13 z'
15+
const Close = 'M19 6.41 17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z'
16+
const ContentCopy = 'M16 1H4c-1.1 0-2 .9-2 2v14h2V3h12V1zm3 4H8c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h11c1.1 0 2-.9 2-2V7c0-1.1-.9-2-2-2zm0 16H8V7h11v14z'
17+
const Edit = 'M3 17.25V21h3.75L17.81 9.94l-3.75-3.75L3 17.25zM20.71 7.04c.39-.39.39-1.02 0-1.41l-2.34-2.34a.9959.9959 0 0 0-1.41 0l-1.83 1.83 3.75 3.75 1.83-1.83z'
18+
const ExpandMore = 'M16.59 8.59 12 13.17 7.41 8.59 6 10l6 6 6-6z'
19+
20+
export const CheckIcon: React.FC<SvgIconProps> = (props) => {
21+
return <BaseIcon d={Check} {...props} />
22+
}
23+
24+
export const ChevronRightIcon: React.FC<SvgIconProps> = (props) => {
25+
return <BaseIcon d={ChevronRight} {...props} />
26+
}
27+
28+
export const CircularArrowsIcon: React.FC<SvgIconProps> = (props) => {
29+
return <BaseIcon d={CircularArrows} {...props} />
30+
}
31+
32+
export const CloseIcon: React.FC<SvgIconProps> = (props) => {
33+
return <BaseIcon d={Close} {...props} />
34+
}
35+
36+
export const ContentCopyIcon: React.FC<SvgIconProps> = (props) => {
37+
return <BaseIcon d={ContentCopy} {...props} />
38+
}
39+
40+
export const EditIcon: React.FC<SvgIconProps> = (props) => {
41+
return <BaseIcon d={Edit} {...props} />
42+
}
43+
44+
export const ExpandMoreIcon: React.FC<SvgIconProps> = (props) => {
45+
return <BaseIcon d={ExpandMore} {...props} />
46+
}

src/components/icons/CircularArrowsIcon.tsx

-10
This file was deleted.

yarn.lock

-17
Original file line numberDiff line numberDiff line change
@@ -1132,22 +1132,6 @@ __metadata:
11321132
languageName: node
11331133
linkType: hard
11341134

1135-
"@mui/icons-material@npm:^5.11.0":
1136-
version: 5.11.0
1137-
resolution: "@mui/icons-material@npm:5.11.0"
1138-
dependencies:
1139-
"@babel/runtime": ^7.20.6
1140-
peerDependencies:
1141-
"@mui/material": ^5.0.0
1142-
"@types/react": ^17.0.0 || ^18.0.0
1143-
react: ^17.0.0 || ^18.0.0
1144-
peerDependenciesMeta:
1145-
"@types/react":
1146-
optional: true
1147-
checksum: 764c1185b3432f0228f3c5217b0e218b10f106fa96d305dfc62c0ef5afd2a7a087b0d664fd0a8171282e195c18d3ee073d5f037901a2bed1a1519a70fbb0501c
1148-
languageName: node
1149-
linkType: hard
1150-
11511135
"@mui/material@npm:^5.11.4":
11521136
version: 5.11.4
11531137
resolution: "@mui/material@npm:5.11.4"
@@ -1820,7 +1804,6 @@ __metadata:
18201804
"@commitlint/config-angular": ^17.4.2
18211805
"@emotion/react": ^11.10.5
18221806
"@emotion/styled": ^11.10.5
1823-
"@mui/icons-material": ^5.11.0
18241807
"@mui/material": ^5.11.4
18251808
"@rollup/plugin-alias": ^4.0.2
18261809
"@rollup/plugin-commonjs": ^24.0.0

0 commit comments

Comments
 (0)