Skip to content

Commit bdd9147

Browse files
committed
immediately display the contributors modal button to reduce lcp
1 parent 079fd66 commit bdd9147

File tree

2 files changed

+47
-41
lines changed

2 files changed

+47
-41
lines changed

src/components/FileContributors.tsx

Lines changed: 46 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import {
1111
Skeleton as ChakraSkeleton,
1212
SkeletonCircle as ChakraSkeletonCircle,
1313
UnorderedList,
14+
useBreakpointValue,
1415
VStack,
1516
} from "@chakra-ui/react"
1617

@@ -87,6 +88,8 @@ const FileContributors = ({
8788
const [isModalOpen, setModalOpen] = useState(false)
8889
const { locale } = useRouter()
8990

91+
const isDesktop = useBreakpointValue({ base: false, md: true })
92+
9093
if (error) return null
9194
const lastContributor: Author = contributors.length
9295
? contributors[0]
@@ -133,49 +136,52 @@ const FileContributors = ({
133136
{...props}
134137
>
135138
<Flex me={4} alignItems="center" flex="1">
136-
<SkeletonCircle size="10" me={4} isLoaded={!loading}>
137-
<Avatar
138-
height="40px"
139-
width="40px"
140-
src={lastContributor.avatarUrl}
141-
name={lastContributor.name}
142-
me={2}
143-
/>
144-
</SkeletonCircle>
145-
146-
<Skeleton isLoaded={!loading}>
147-
<Text m={0} color="text200">
148-
<Translation id="last-edit" />:{" "}
149-
{lastContributor.user?.url && (
150-
<InlineLink href={lastContributor.user.url}>
151-
@{lastContributor.user.login}
152-
</InlineLink>
153-
)}
154-
{!lastContributor.user && <span>{lastContributor.name}</span>},{" "}
155-
{getLocaleTimestamp(locale as Lang, lastEdit)}
156-
</Text>
157-
</Skeleton>
139+
{isDesktop && (
140+
<>
141+
<SkeletonCircle size="10" me={4} isLoaded={!loading}>
142+
<Avatar
143+
height="40px"
144+
width="40px"
145+
src={lastContributor.avatarUrl}
146+
name={lastContributor.name}
147+
me={2}
148+
/>
149+
</SkeletonCircle>
150+
151+
<Skeleton isLoaded={!loading}>
152+
<Text m={0} color="text200">
153+
<Translation id="last-edit" />:{" "}
154+
{lastContributor.user?.url && (
155+
<InlineLink href={lastContributor.user.url}>
156+
@{lastContributor.user.login}
157+
</InlineLink>
158+
)}
159+
{!lastContributor.user && <span>{lastContributor.name}</span>}
160+
, {getLocaleTimestamp(locale as Lang, lastEdit)}
161+
</Text>
162+
</Skeleton>
163+
</>
164+
)}
158165
</Flex>
159166

160167
<VStack align="stretch" justifyContent="space-between" spacing={2}>
161-
<Skeleton isLoaded={!loading} mt={{ base: 4, md: 0 }}>
162-
<Button
163-
variant="outline"
164-
bg="background.base"
165-
border={0}
166-
onClick={() => {
167-
setModalOpen(true)
168-
trackCustomEvent({
169-
eventCategory: "see contributors",
170-
eventAction: "click",
171-
eventName: "click",
172-
})
173-
}}
174-
w={{ base: "full", md: "inherit" }}
175-
>
176-
<Translation id="see-contributors" />
177-
</Button>
178-
</Skeleton>
168+
<Button
169+
variant="outline"
170+
bg="background.base"
171+
border={0}
172+
mb={{ base: 4, md: 0 }}
173+
onClick={() => {
174+
setModalOpen(true)
175+
trackCustomEvent({
176+
eventCategory: "see contributors",
177+
eventAction: "click",
178+
eventName: "click",
179+
})
180+
}}
181+
w={{ base: "full", md: "inherit" }}
182+
>
183+
<Translation id="see-contributors" />
184+
</Button>
179185
</VStack>
180186
</Flex>
181187
</>

src/layouts/Docs.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ const Content = (props: ChildOnlyProp) => {
145145
as={MainArticle}
146146
flex={`1 1 ${mdBreakpoint}`}
147147
w={{ base: "full", lg: "0" }}
148-
pt={{ base: 32, md: 12 }}
148+
pt={{ base: 8, md: 12 }}
149149
pb={{ base: 8, md: 16 }}
150150
px={{ base: 8, md: 16 }}
151151
m="0 auto"

0 commit comments

Comments
 (0)