mirror of
https://github.com/LibreChat-AI/librechat.ai.git
synced 2026-03-27 10:48:32 +07:00
* ✨ feat: update home page layout and add usage statistics components * 🔃 chore: clean up eslint-module-utils dependency entries in pnpm-lock.yaml * ✨ feat: a lot of things * ✨ feat: UI adjustements * ✨ feat: improve author card links, update background colors, and enhance layout responsiveness * chore: update bun * ✨ feat: update GitHub stars and Docker pulls statistics * ✨ feat: update demo link to new preview URL * ✨ feat: update features section with new Code Interpreter and adjust layout * ✨ feat: add emoji to Quick Start title for enhanced visibility * refactor: move user guides to features section * ✨ feat: add emojis to installation and user guides for improved clarity * ✨ feat: update Hero component title and description for clarity and enhance demo link * feat: agents page * ✨ feat: update agents documentation to clarify built-in tools and mention future integrations * ✨ feat: add Code Interpreter API documentation and update agents metadata * ✨ feat: add Code Interpreter page metadata and integrate sparkles effect in Hero component * chore: comment out NewsletterForm component in Home page * style: code interpreter gif for features box * fix: update Agents link to point to the correct features documentation * fix: pnpm lockfile * docs: API key notes for code interpreter api * refactor: improve MobileSwitch component with TypeScript types and null check * chore: types, packages * chore: update ESLint configuration and add linting step to CI workflow fix: update rotate prop type in Card component to accept number or string * docs: add section on intellectual property protection for Code Interpreter * docs: refine agents customization features in documentation * style: hero page --------- Co-authored-by: Marco Beretta <81851188+berry-13@users.noreply.github.com>
34 lines
903 B
TypeScript
34 lines
903 B
TypeScript
import React, { useState, useEffect, useRef } from 'react'
|
|
|
|
// Define the breakpoint
|
|
const MOBILE_BREAKPOINT = 650
|
|
|
|
interface MobileSwitchProps {
|
|
mobile: React.ComponentType
|
|
desktop: React.ComponentType
|
|
}
|
|
|
|
export default function MobileSwitch({ mobile: Mobile, desktop: Desktop }: MobileSwitchProps) {
|
|
const [isMobile, setIsMobile] = useState<boolean | null>(null)
|
|
const objectRef = useRef<HTMLDivElement>(null)
|
|
|
|
useEffect(() => {
|
|
const handleResize = () => {
|
|
if (objectRef.current) {
|
|
setIsMobile(objectRef.current.offsetWidth <= MOBILE_BREAKPOINT)
|
|
}
|
|
}
|
|
handleResize()
|
|
|
|
// Attach event listener
|
|
window.addEventListener('resize', handleResize)
|
|
|
|
// Cleanup
|
|
return () => {
|
|
window.removeEventListener('resize', handleResize)
|
|
}
|
|
}, [])
|
|
|
|
return <div ref={objectRef}>{isMobile === null ? null : isMobile ? <Mobile /> : <Desktop />}</div>
|
|
}
|