From 6363d9da818e094c7d2a530610a53a205212af0e Mon Sep 17 00:00:00 2001 From: Eric Bailey Date: Thu, 31 Oct 2024 14:09:13 -0500 Subject: [PATCH] Adjust spacing on mobile --- src/view/com/util/post-embeds/GithubGist.tsx | 124 +++++++++---------- 1 file changed, 57 insertions(+), 67 deletions(-) diff --git a/src/view/com/util/post-embeds/GithubGist.tsx b/src/view/com/util/post-embeds/GithubGist.tsx index e52e9880d1..7420a806b3 100644 --- a/src/view/com/util/post-embeds/GithubGist.tsx +++ b/src/view/com/util/post-embeds/GithubGist.tsx @@ -10,7 +10,7 @@ import {shareUrl} from '#/lib/sharing' import {toNiceDomain} from '#/lib/strings/url-helpers' import {isNative} from '#/platform/detection' import {ExternalLinkEmbedCard} from '#/view/com/util/post-embeds/ExternalLinkEmbed' -import {atoms as a, useTheme} from '#/alf' +import {atoms as a, useBreakpoints,useTheme} from '#/alf' import {Button, ButtonIcon, ButtonText} from '#/components/Button' import {Divider} from '#/components/Divider' import {ChevronBottom_Stroke2_Corner0_Rounded as Chevron} from '#/components/icons/Chevron' @@ -31,6 +31,7 @@ export function GithubGist({ }) { const t = useTheme() const {_} = useLingui() + const {gtMobile} = useBreakpoints() const [footerHeight, setFooterHeight] = React.useState(97) // magic # const [showMore, setShowMore] = React.useState() @@ -67,13 +68,15 @@ export function GithubGist({ const onCodeLayout = React.useCallback( (e: LayoutChangeEvent) => { - if (e.nativeEvent.layout.height < 400) { + if (showMore !== undefined) return + const height = e.nativeEvent.layout.height + if (height < 400) { setShowMore(true) } else { setShowMore(false) } }, - [setShowMore], + [showMore, setShowMore], ) const onShowMore = React.useCallback(() => { @@ -97,35 +100,32 @@ export function GithubGist({ ]}> {error ? null : !files ? ( // handled above - + ) : ( - + + onLayout={onCodeLayout} + style={[{paddingBottom: footerHeight}]}> - {files[0].content} + {files[0].content.trimRight()} @@ -162,47 +162,39 @@ export function GithubGist({ - - {showMore === false && ( - + {showMore === false && ( + + - - )} - - + ]} + onPress={onShowMore}> + Show more + + + + )} {info.title || info.uri} @@ -233,10 +224,9 @@ export function GithubGist({