@@ -25,14 +25,8 @@ function getDeviceIcon(width) {
2525 return ComputerDesktopIcon ;
2626}
2727
28- /**
29- * Get device label for viewport
30- */
31- function _getDeviceLabel ( viewportStr ) {
32- let width = parseInt ( viewportStr . split ( '×' ) [ 0 ] , 10 ) ;
33- if ( width <= 480 ) return 'Mobile' ;
34- if ( width <= 1024 ) return 'Tablet' ;
35- return 'Desktop' ;
28+ function getViewportWidth ( viewport ) {
29+ return Number ( viewport . split ( '×' ) [ 0 ] ) ;
3630}
3731
3832/**
@@ -299,7 +293,7 @@ export default function DashboardFilters({
299293
300294 // Render viewport option with device icon
301295 let renderViewportOption = useCallback ( viewport => {
302- let DeviceIcon = getDeviceIcon ( parseInt ( viewport . split ( '×' ) [ 0 ] , 10 ) ) ;
296+ let DeviceIcon = getDeviceIcon ( getViewportWidth ( viewport ) ) ;
303297 return (
304298 < >
305299 < DeviceIcon className = "w-4 h-4 text-slate-400" />
@@ -313,7 +307,7 @@ export default function DashboardFilters({
313307 if ( value === 'all' ) {
314308 return < span className = "text-slate-400" > All viewports</ span > ;
315309 }
316- let DeviceIcon = getDeviceIcon ( parseInt ( value . split ( '×' ) [ 0 ] , 10 ) ) ;
310+ let DeviceIcon = getDeviceIcon ( getViewportWidth ( value ) ) ;
317311 return (
318312 < span className = "flex items-center gap-2" >
319313 < DeviceIcon className = "w-4 h-4 text-slate-400" />
@@ -553,7 +547,7 @@ export default function DashboardFilters({
553547 { selectedViewport !== 'all' && (
554548 < ActiveFilter
555549 label = { selectedViewport }
556- icon = { getDeviceIcon ( parseInt ( selectedViewport . split ( '×' ) [ 0 ] , 10 ) ) }
550+ icon = { getDeviceIcon ( getViewportWidth ( selectedViewport ) ) }
557551 onRemove = { ( ) => setSelectedViewport ( 'all' ) }
558552 />
559553 ) }
0 commit comments