Skip to content

The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.

chore: lift useBreakpoint to packages

Francesco Sansalvadore429390b86d31
diff --git a/apps/www/components/LaunchWeek/LW7BgGraphic.tsx b/apps/www/components/LaunchWeek/LW7BgGraphic.tsx
index 90d802628ad..1b824fb5be5 100644
--- a/apps/www/components/LaunchWeek/LW7BgGraphic.tsx
+++ b/apps/www/components/LaunchWeek/LW7BgGraphic.tsx
@@ -1,6 +1,6 @@
import { motion, useScroll, useTransform } from 'framer-motion'
import Image from 'next/image'
-import { useBreakpoint } from '../../hooks/useBreakpoint'
+import { useBreakpoint } from 'common/hooks/useBreakpoint'
import styles from './lw7-bg-graphic.module.css'
export default function LW7BgGraphic() {
diff --git a/apps/www/components/LaunchWeek/LaunchSection/LaunchWeekLogoHeader.tsx b/apps/www/components/LaunchWeek/LaunchSection/LaunchWeekLogoHeader.tsx
index 12167c5fd93..8817c16e1db 100644
--- a/apps/www/components/LaunchWeek/LaunchSection/LaunchWeekLogoHeader.tsx
+++ b/apps/www/components/LaunchWeek/LaunchSection/LaunchWeekLogoHeader.tsx
@@ -1,7 +1,7 @@
import classNames from 'classnames'
import Image from 'next/image'
import { motion } from 'framer-motion'
-import { useBreakpoint } from '../../../hooks/useBreakpoint'
+import { useBreakpoint } from 'common/hooks/useBreakpoint'
export function LaunchWeekLogoHeader() {
const isMobile = useBreakpoint(640)
diff --git a/apps/www/components/LaunchWeek/LaunchSection/TicketBrickWall.tsx b/apps/www/components/LaunchWeek/LaunchSection/TicketBrickWall.tsx
index c1a29e8fa73..b757f4cdeaf 100644
--- a/apps/www/components/LaunchWeek/LaunchSection/TicketBrickWall.tsx
+++ b/apps/www/components/LaunchWeek/LaunchSection/TicketBrickWall.tsx
@@ -1,7 +1,7 @@
import Link from 'next/link'
import React from 'react'
import { Button } from 'ui'
-import { useBreakpoint } from '../../../hooks/useBreakpoint'
+import { useBreakpoint } from 'common/hooks/useBreakpoint'
import { UserData } from '../Ticket/hooks/use-conf-data'
import { TicketBrickWallSlider } from './TicketBrickWallSlider'
diff --git a/apps/www/components/LaunchWeek/Releases/LW7/Day5.tsx b/apps/www/components/LaunchWeek/Releases/LW7/Day5.tsx
index 804938678a6..b36d06f1c32 100644
--- a/apps/www/components/LaunchWeek/Releases/LW7/Day5.tsx
+++ b/apps/www/components/LaunchWeek/Releases/LW7/Day5.tsx
@@ -1,7 +1,7 @@
import React from 'react'
import Image from 'next/image'
import { motion } from 'framer-motion'
-import { useBreakpoint } from '~/hooks/useBreakpoint'
+import { useBreakpoint } from 'common/hooks/useBreakpoint'
import {
ArrowTopRightSvg,
CartTitle,
diff --git a/apps/www/components/LaunchWeek/Releases/LW7/LW7Releases.tsx b/apps/www/components/LaunchWeek/Releases/LW7/LW7Releases.tsx
index 835b5ece06e..bf6cf2c54be 100644
--- a/apps/www/components/LaunchWeek/Releases/LW7/LW7Releases.tsx
+++ b/apps/www/components/LaunchWeek/Releases/LW7/LW7Releases.tsx
@@ -15,7 +15,7 @@ import {
StyledArticleBadge,
} from './components'
-import { useBreakpoint } from '../../../../hooks/useBreakpoint'
+import { useBreakpoint } from 'common/hooks/useBreakpoint'
import { motion } from 'framer-motion'
import Day5 from './Day5'
diff --git a/apps/www/components/LaunchWeek/Ticket/ActualTicket.tsx b/apps/www/components/LaunchWeek/Ticket/ActualTicket.tsx
index 7cc769d58c6..bb59bd906de 100644
--- a/apps/www/components/LaunchWeek/Ticket/ActualTicket.tsx
+++ b/apps/www/components/LaunchWeek/Ticket/ActualTicket.tsx
@@ -10,7 +10,7 @@ import { UserData } from './hooks/use-conf-data'
import ReferralIndicator from '../ReferralIndicator'
import useWinningChances from './hooks/useWinningChances'
import { SITE_URL } from '~/lib/constants'
-import { useBreakpoint } from '../../../hooks/useBreakpoint'
+import { useBreakpoint } from 'common/hooks/useBreakpoint'
type TicketGenerationState = 'default' | 'loading'
diff --git a/apps/www/components/LaunchWeek/Ticket/TicketsGrid.tsx b/apps/www/components/LaunchWeek/Ticket/TicketsGrid.tsx
index 094301a5cef..dfaaf8f54a2 100644
--- a/apps/www/components/LaunchWeek/Ticket/TicketsGrid.tsx
+++ b/apps/www/components/LaunchWeek/Ticket/TicketsGrid.tsx
@@ -1,7 +1,7 @@
import { motion } from 'framer-motion'
import Image from 'next/image'
import Link from 'next/link'
-import { useBreakpoint } from '../../../hooks/useBreakpoint'
+import { useBreakpoint } from 'common/hooks/useBreakpoint'
import { UserData } from './hooks/use-conf-data'
interface Props {
diff --git a/packages/common/hooks/index.ts b/packages/common/hooks/index.ts
index 6e0d89b50b7..7560f7ebcf5 100644
--- a/packages/common/hooks/index.ts
+++ b/packages/common/hooks/index.ts
@@ -1,3 +1,2 @@
-import React from 'react'
-
+export * from './useBreakpoint'
export * from './useParams'
diff --git a/apps/www/hooks/useBreakpoint.tsx b/packages/common/hooks/useBreakpoint.tsx
similarity index 60%
rename from apps/www/hooks/useBreakpoint.tsx
rename to packages/common/hooks/useBreakpoint.tsx
index e02f35f5c70..27e29f666d3 100644
--- a/apps/www/hooks/useBreakpoint.tsx
+++ b/packages/common/hooks/useBreakpoint.tsx
@@ -1,19 +1,20 @@
import { useEffect, useState } from 'react'
import { useWindowSize } from 'react-use'
-import { isBrowser } from '~/lib/helpers'
+
+const isBrowser = typeof window !== 'undefined'
export function useBreakpoint(breakpoint = 768) {
if (!isBrowser) return
- const [isMobile, setIsMobile] = useState(false)
+ const [isBreakpoint, setIsBreakpoint] = useState(false)
const { width } = useWindowSize()
useEffect(() => {
if (width <= breakpoint) {
- setIsMobile(true)
+ setIsBreakpoint(true)
} else {
- setIsMobile(false)
+ setIsBreakpoint(false)
}
}, [width])
- return isMobile
+ return isBreakpoint
}