11import React , { useRef , useState , useEffect } from 'react' ;
22import { Link , useLocation } from 'react-router-dom' ;
3- import { Download , BookOpen , Image as ImageIcon , List , MessageSquare , Box , ChevronDown , ExternalLink , Link as LinkIcon } from 'lucide-react' ;
3+ import { Download , BookOpen , Image as ImageIcon , List , MessageSquare , ChevronDown , ExternalLink , Link as LinkIcon } from 'lucide-react' ;
44import { theme } from '@/styles/theme' ;
5- import { OptimizedImage } from '@/components/ui/OptimizedImage' ;
6- import { SiteRoutes } from '@/utils/routes' ;
7- import { BACKEND_URL } from '@/utils/api' ;
8- import type { Project , ProjectDependency } from '@/types' ;
5+ import type { Project } from '@/types' ;
96
107interface ActionBarProps {
118 project : Project ;
129 projectUrl : string ;
13- latestDependencies : ProjectDependency [ ] ;
14- depMeta : Record < string , { icon : string , title : string } > ;
1510 links : { type : string , url : string , icon : any , label : string , colorClass : string } [ ] ;
16- isMobile : boolean ;
1711 commentsRef : React . RefObject < HTMLDivElement | null > ;
1812}
1913
20- export const ActionBar : React . FC < ActionBarProps > = ( { project, projectUrl, latestDependencies , depMeta , links, isMobile , commentsRef } ) => {
14+ export const ActionBar : React . FC < ActionBarProps > = ( { project, projectUrl, links, commentsRef } ) => {
2115 const [ showMobileLinks , setShowMobileLinks ] = useState ( false ) ;
22- const [ showMobileDeps , setShowMobileDeps ] = useState ( false ) ;
2316 const dropdownRef = useRef < HTMLDivElement > ( null ) ;
24- const depsDropdownRef = useRef < HTMLDivElement > ( null ) ;
2517 const location = useLocation ( ) ;
2618
2719 useEffect ( ( ) => {
2820 const handleClick = ( e : MouseEvent ) => {
2921 if ( dropdownRef . current && ! dropdownRef . current . contains ( e . target as Node ) ) setShowMobileLinks ( false ) ;
30- if ( depsDropdownRef . current && ! depsDropdownRef . current . contains ( e . target as Node ) ) setShowMobileDeps ( false ) ;
3122 } ;
3223 document . addEventListener ( 'mousedown' , handleClick ) ;
3324 return ( ) => document . removeEventListener ( 'mousedown' , handleClick ) ;
3425 } , [ ] ) ;
3526
36- const resolveUrl = ( url : string ) => url . startsWith ( '/api' ) ? `${ BACKEND_URL } ${ url } ` : url ;
3727 const hasWiki = Boolean ( project . hmWikiEnabled && project . hmWikiSlug ) ;
3828 const hasGallery = Boolean ( project . galleryImages && project . galleryImages . length > 0 ) ;
3929 const mediaButtonClass = hasWiki && hasGallery ? 'col-span-1 md:col-span-1' : 'col-span-2 md:col-span-1' ;
@@ -74,36 +64,6 @@ export const ActionBar: React.FC<ActionBarProps> = ({ project, projectUrl, lates
7464 </ div >
7565
7666 < div className = "w-full 2xl:w-auto flex flex-col md:flex-row justify-start 2xl:justify-end gap-2 mt-1 2xl:mt-0" >
77- { isMobile && project . classification === 'MODPACK' && latestDependencies . length > 0 && (
78- < div className = "relative w-full" ref = { depsDropdownRef } >
79- < button onClick = { ( ) => { setShowMobileDeps ( ! showMobileDeps ) ; setShowMobileLinks ( false ) ; } } className = { `w-full flex items-center justify-center gap-2 p-3 rounded-xl ${ theme . colors . bgSurfaceAlt } border ${ theme . colors . border } font-bold text-slate-700 dark:text-slate-300` } >
80- < Box className = "w-4 h-4" aria-hidden = "true" /> Included Projects < ChevronDown className = { `w-4 h-4 transition-transform ${ showMobileDeps ? 'rotate-180' : '' } ` } aria-hidden = "true" />
81- </ button >
82- { showMobileDeps && (
83- < div className = { `absolute top-full left-0 right-0 mt-1.5 ${ theme . colors . bgBase } border ${ theme . colors . border } rounded-xl shadow-xl z-50 overflow-hidden animate-in fade-in slide-in-from-top-2 p-1 max-h-[300px] overflow-y-auto` } >
84- { latestDependencies . map ( ( dep , idx ) => {
85- const meta = depMeta [ dep . projectId ] ;
86- const title = meta ?. title || dep . projectTitle || dep . projectId ;
87- const path = SiteRoutes . project ( { id : dep . projectId , title : title } ) ;
88-
89- return (
90- < Link key = { idx } to = { path } onClick = { ( ) => setShowMobileDeps ( false ) } className = { `w-full flex items-center gap-3 p-2.5 ${ theme . colors . bgSurfaceHover } transition-colors ${ theme . colors . textSecondary } hover:${ theme . colors . textPrimary } text-left` } >
91- < div className = { `w-8 h-8 rounded-lg ${ theme . colors . bgSurfaceAlt } flex items-center justify-center border ${ theme . colors . border } shrink-0 overflow-hidden` } >
92- { meta ?. icon ? < OptimizedImage src = { resolveUrl ( meta . icon ) } alt = { `${ title } Icon` } baseWidth = { 32 } className = "w-full h-full" /> : < Box className = "w-4 h-4 text-slate-500" aria-hidden = "true" /> }
93- </ div >
94- < div className = "min-w-0 flex-1" >
95- < div className = "text-sm font-bold truncate" > { title } </ div >
96- < div className = "text-[10px] text-slate-500 dark:text-slate-400 font-mono" > v{ dep . versionNumber } </ div >
97- </ div >
98- < ExternalLink className = "w-3 h-3 opacity-50 shrink-0" aria-hidden = "true" />
99- </ Link >
100- ) ;
101- } ) }
102- </ div >
103- ) }
104- </ div >
105- ) }
106-
10767 < div className = "hidden md:flex gap-2 flex-wrap justify-start 2xl:justify-end" >
10868 { links . map ( ( link , idx ) => (
10969 < a key = { idx } href = { link . url . startsWith ( 'http' ) ? link . url : `https://${ link . url } ` } target = "_blank" rel = "noreferrer" className = { `rounded-xl border transition-all flex items-center justify-center px-4 py-2.5 2xl:p-0 2xl:w-[42px] 2xl:h-[42px] gap-2 2xl:gap-0 ${ link . colorClass } ` } title = { link . label } aria-label = { link . label } >
@@ -115,7 +75,7 @@ export const ActionBar: React.FC<ActionBarProps> = ({ project, projectUrl, lates
11575
11676 { links . length > 0 && (
11777 < div className = "md:hidden relative w-full" ref = { dropdownRef } >
118- < button onClick = { ( ) => { setShowMobileLinks ( ! showMobileLinks ) ; setShowMobileDeps ( false ) ; } } className = { `w-full flex items-center justify-center gap-2 p-3 rounded-xl ${ theme . colors . bgSurfaceAlt } border ${ theme . colors . border } font-bold text-slate-700 dark:text-slate-300` } >
78+ < button onClick = { ( ) => { setShowMobileLinks ( ! showMobileLinks ) ; } } className = { `w-full flex items-center justify-center gap-2 p-3 rounded-xl ${ theme . colors . bgSurfaceAlt } border ${ theme . colors . border } font-bold text-slate-700 dark:text-slate-300` } >
11979 < LinkIcon className = "w-4 h-4" aria-hidden = "true" /> External Links < ChevronDown className = { `w-4 h-4 transition-transform ${ showMobileLinks ? 'rotate-180' : '' } ` } aria-hidden = "true" />
12080 </ button >
12181 { showMobileLinks && (
0 commit comments