diff --git a/components/FeaturesSection.tsx b/components/FeaturesSection.tsx index 121fa9f..918ee18 100644 --- a/components/FeaturesSection.tsx +++ b/components/FeaturesSection.tsx @@ -1,4 +1,5 @@ -import React from 'react'; +import React, { useState } from 'react'; +import useIsMobile from '../hooks/useIsMobile'; import { Monitor, Bell, @@ -10,7 +11,13 @@ import { } from 'lucide-react'; import FeatureCard from './FeatureCard'; +const MOBILE_VISIBLE_COUNT = 4; + const FeaturesSection: React.FC = () => { + const isMobile = useIsMobile(); + + const [isExpanded, setIsExpanded] = useState(false); + const features = [ { icon: Monitor, @@ -54,10 +61,20 @@ const FeaturesSection: React.FC = () => { } ]; + const featuresToDisplay = + (isMobile && !isExpanded) + ? features.slice(0, MOBILE_VISIBLE_COUNT) + : features; + + const handleToggle = () => { + setIsExpanded(!isExpanded); + }; + + const requiresToggle = isMobile && (features.length > MOBILE_VISIBLE_COUNT); + return (
- {/* Section Header */}

Everything You Need to{' '} @@ -69,9 +86,8 @@ const FeaturesSection: React.FC = () => {

- {/* Features Grid */} -
- {features.map((feature, index) => ( +
+ {featuresToDisplay.map((feature, index) => ( { ))}
+ {requiresToggle && ( +
+ +
+ )}
); }; -export default FeaturesSection; +export default FeaturesSection; \ No newline at end of file diff --git a/hooks/useIsMobile.ts b/hooks/useIsMobile.ts new file mode 100644 index 0000000..a272039 --- /dev/null +++ b/hooks/useIsMobile.ts @@ -0,0 +1,22 @@ +import { useState, useEffect } from 'react'; + +const useIsMobile = (breakpoint = 768) => { + const [isMobile, setIsMobile] = useState( + typeof window !== 'undefined' ? window.innerWidth < breakpoint : false + ); + + useEffect(() => { + const checkMobile = () => { + setIsMobile(window.innerWidth < breakpoint); + }; + + window.addEventListener('resize', checkMobile); + checkMobile(); + + return () => window.removeEventListener('resize', checkMobile); + }, [breakpoint]); + + return isMobile; +}; + +export default useIsMobile; \ No newline at end of file