22import type { Data , Edge , Options } from ' vis-network'
33import { Network } from ' vis-network'
44import type { Package } from ' ~/types/packages'
5+ import { _cyan , _pink , _violet , _yellow } from ' #tailwind-config/theme/colors'
6+ import type { Settings } from ' ~/types/settings'
57
68const props = defineProps <{
79 packages: Package []
810 selection: string []
9- showDependencies: boolean
10- showDevDependencies: boolean
11- showChildren: boolean
11+ settings: Settings
1212}>()
1313
1414const emits = defineEmits <{
@@ -35,12 +35,12 @@ const data = computed<Data>(() => {
3535 // Use a condition to avoid unnecessary computation
3636 const selectionChildrenPackages: Package [] = []
3737 const selectionChildrenPackagesName: string [] = []
38- if (props .showChildren ) {
38+ if (props .settings . children ) {
3939 /** Children */
4040 selectionChildrenPackages .push (... props .packages
4141 // Filter out packages that have not selected packages as dependencies or devDependencies
4242 .filter ((pkg ) => {
43- if (props .showDependencies ) {
43+ if (props .settings . dependencies ) {
4444 // Check if current package use any of the selected packages
4545 const hasUsedBy = pkg .dependencies .some ((dep ) => {
4646 return props .selection .includes (dep )
@@ -50,7 +50,7 @@ const data = computed<Data>(() => {
5050 return true
5151 }
5252
53- if (props .showDevDependencies ) {
53+ if (props .settings . devDependencies ) {
5454 // Check if current package use any of the selected packages
5555 const hasUsedBy = pkg .devDependencies .some ((dep ) => {
5656 return props .selection .includes (dep )
@@ -87,10 +87,10 @@ const data = computed<Data>(() => {
8787 // Add current package for selection children packages
8888 deps .push (pkg .name )
8989
90- if (props .showDependencies )
90+ if (props .settings . dependencies )
9191 deps .push (... pkg .dependencies )
9292
93- if (props .showDevDependencies )
93+ if (props .settings . devDependencies )
9494 deps .push (... pkg .devDependencies )
9595
9696 return deps
@@ -134,29 +134,29 @@ const data = computed<Data>(() => {
134134 ... dedupePackages .flatMap ((pkg ) => {
135135 const data: Edge [] = []
136136
137- if (props .showDependencies ) {
137+ if (props .settings . dependencies ) {
138138 data .push (... pkg .dependencies .map ((dep ) => {
139139 return {
140140 from: pkg .name ,
141141 to: dep ,
142142 color: {
143- color: ' #f9a8d4 ' , // pink- 300
144- highlight: ' #ec4899 ' , // pink- 500
143+ color: _pink [ 300 ],
144+ highlight: _pink [ 500 ],
145145 },
146146 relation: ' dependencies' ,
147147 arrows: ' to' ,
148148 }
149149 }))
150150 }
151151
152- if (props .showDevDependencies ) {
152+ if (props .settings . devDependencies ) {
153153 data .push (... pkg .devDependencies .map ((dep ) => {
154154 return {
155155 from: pkg .name ,
156156 to: dep ,
157157 color: {
158- color: ' #d8b4fe ' , // pink- 300
159- highlight: ' #a855f7 ' , // pink- 500
158+ color: _violet [ 300 ],
159+ highlight: _violet [ 500 ],
160160 },
161161 relation: ' devDependencies' ,
162162 arrows: ' to' ,
@@ -205,21 +205,21 @@ onMounted(() => {
205205 groups: {
206206 selection: {
207207 color: {
208- background: ' #F7F1BD ' , // yellow- 300
209- border: ' #ECDC5A ' , // yellow- 500
208+ background: _yellow [ 300 ],
209+ border: _yellow [ 500 ],
210210 highlight: {
211- background: ' #F2E78C ' , // yellow- 400
212- border: ' #D4C651 ' , // yellow- 600
211+ background: _yellow [ 400 ],
212+ border: _yellow [ 600 ],
213213 },
214214 },
215215 },
216216 dependencies: {
217217 color: {
218- background: ' #ecfeff ' , // cyan-50
219- border: ' #67e8f9 ' , // cyan- 300
218+ background: _cyan [ 50 ],
219+ border: _cyan [ 300 ],
220220 highlight: {
221- background: ' #cffafe ' , // cyan- 100
222- border: ' #06b6d4 ' , // cyan- 500
221+ background: _cyan [ 100 ],
222+ border: _cyan [ 500 ],
223223 },
224224 },
225225 },
@@ -239,12 +239,5 @@ onMounted(() => {
239239 </script >
240240
241241<template >
242- <div id = " container " ref =" container" />
242+ <div ref =" container" />
243243</template >
244-
245- <style scoped>
246- #container {
247- width : 100% ;
248- height : 100vh ;
249- }
250- </style >
0 commit comments