Skip to content

Commit 871dda7

Browse files
committed
Add root utils
1 parent 271fcff commit 871dda7

File tree

2 files changed

+14
-8
lines changed

2 files changed

+14
-8
lines changed

apps/landing/src/components/Header/HeaderWrap.tsx

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,16 @@ import { Box, Flex } from '@devup-ui/react'
44
import { usePathname, useSearchParams } from 'next/navigation'
55
import { Suspense } from 'react'
66

7+
import { isRoot } from '../../utils/is-root'
8+
79
export function HeaderWrap({ children }: { children: React.ReactNode }) {
810
const path = usePathname()
9-
const isRoot = path === '/'
11+
const root = isRoot(path)
1012
return (
1113
<Box
12-
pos={isRoot ? 'fixed' : 'sticky'}
13-
pt={isRoot ? [null, null, 5] : undefined}
14-
px={isRoot ? [null, null, 4] : undefined}
14+
pos={root ? 'fixed' : 'sticky'}
15+
pt={root ? [null, null, 5] : undefined}
16+
px={root ? [null, null, 4] : undefined}
1517
top="0"
1618
transition="all, 0.2s"
1719
w="100%"
@@ -26,18 +28,17 @@ export function HeaderWrap({ children }: { children: React.ReactNode }) {
2628

2729
function HeaderWrapInner({ children }: { children: React.ReactNode }) {
2830
const path = usePathname()
29-
const isRoot = path === '/'
30-
console.info('isRoot', isRoot, path)
31+
const root = isRoot(path)
3132
const menu = useSearchParams().get('menu') === '1'
3233
return (
3334
<Flex
3435
alignItems="center"
3536
bg="$containerBackground"
36-
borderRadius={isRoot ? [null, null, '16px'] : undefined}
37+
borderRadius={root ? [null, null, '16px'] : undefined}
3738
boxShadow="0px 2px 8px 0px var(--shadow, rgba(135, 135, 135, 0.25))"
3839
h={['50px', null, '70px']}
3940
justifyContent="space-between"
40-
maxW={isRoot ? '1440px' : '100%'}
41+
maxW={root ? '1440px' : '100%'}
4142
mx="auto"
4243
pl={[menu ? null : 4, 5, '40px']}
4344
pr={[null, 5, '40px']}

apps/landing/src/utils/is-root.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import { URL_PREFIX } from '../constants'
2+
3+
export function isRoot(path: string) {
4+
return URL_PREFIX + '/' === path
5+
}

0 commit comments

Comments
 (0)