Skip to content

Commit

Permalink
Link cards (bluesky-social#5677)
Browse files Browse the repository at this point in the history
* New link card styles

* Cleanup of consituent parts, add hover state

* Fix gif alt text view

* Fix alt text view more

* Remove dupe

* Update remove button

* Remove added margin on gif
  • Loading branch information
estrattonbailey authored Oct 14, 2024
1 parent 2d88463 commit 4c3c10d
Show file tree
Hide file tree
Showing 6 changed files with 153 additions and 231 deletions.
38 changes: 15 additions & 23 deletions src/view/com/composer/ExternalEmbedRemoveBtn.tsx
Original file line number Diff line number Diff line change
@@ -1,34 +1,26 @@
import React from 'react'
import {TouchableOpacity} from 'react-native'
import {FontAwesomeIcon} from '@fortawesome/react-native-fontawesome'
import {View} from 'react-native'
import {msg} from '@lingui/macro'
import {useLingui} from '@lingui/react'

import {s} from 'lib/styles'
import {atoms as a} from '#/alf'
import {Button, ButtonIcon} from '#/components/Button'
import {TimesLarge_Stroke2_Corner0_Rounded as X} from '#/components/icons/Times'

export function ExternalEmbedRemoveBtn({onRemove}: {onRemove: () => void}) {
const {_} = useLingui()

return (
<TouchableOpacity
style={{
position: 'absolute',
top: 10,
right: 10,
height: 36,
width: 36,
backgroundColor: 'rgba(0, 0, 0, 0.75)',
borderRadius: 18,
alignItems: 'center',
justifyContent: 'center',
zIndex: 1,
}}
onPress={onRemove}
accessibilityRole="button"
accessibilityLabel={_(msg`Remove attachment`)}
accessibilityHint={_(msg`Removes the attachment`)}
onAccessibilityEscape={onRemove}>
<FontAwesomeIcon size={18} icon="xmark" style={s.white} />
</TouchableOpacity>
<View style={[a.absolute, a.pt_sm, a.pr_sm, {top: 0, right: 0}]}>
<Button
label={_(msg`Remove attachment`)}
onPress={onRemove}
size="small"
variant="solid"
color="secondary"
shape="round">
<ButtonIcon icon={X} size="sm" />
</Button>
</View>
)
}
4 changes: 2 additions & 2 deletions src/view/com/composer/GifAltText.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import {isAndroid} from '#/platform/detection'
import {useResolveGifQuery} from '#/state/queries/resolve-link'
import {Gif} from '#/state/queries/tenor'
import {AltTextCounterWrapper} from '#/view/com/composer/AltTextCounterWrapper'
import {atoms as a, native, useTheme} from '#/alf'
import {atoms as a, useTheme} from '#/alf'
import {Button, ButtonText} from '#/components/Button'
import * as Dialog from '#/components/Dialog'
import {DialogControlProps} from '#/components/Dialog'
Expand Down Expand Up @@ -213,7 +213,7 @@ function AltTextInner({
isPreferredAltText={true}
params={params}
hideAlt
style={[native({maxHeight: 225})]}
style={[{height: 225}]}
/>
</View>
</View>
Expand Down
40 changes: 1 addition & 39 deletions src/view/com/util/post-embeds/ExternalGifEmbed.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import {
GestureResponderEvent,
LayoutChangeEvent,
Pressable,
StyleSheet,
} from 'react-native'
import {Image, ImageLoadEventData} from 'expo-image'
import {AppBskyEmbedExternal} from '@atproto/api'
Expand All @@ -18,7 +17,6 @@ import {atoms as a, useTheme} from '#/alf'
import {useDialogControl} from '#/components/Dialog'
import {EmbedConsentDialog} from '#/components/dialogs/EmbedConsent'
import {Fill} from '#/components/Fill'
import {MediaInsetBorder} from '#/components/MediaInsetBorder'
import {PlayButtonIcon} from '#/components/video/PlayButtonIcon'

export function ExternalGifEmbed({
Expand Down Expand Up @@ -116,8 +114,7 @@ export function ExternalGifEmbed({
<Pressable
style={[
{height: imageDims.height},
styles.gifContainer,
a.rounded_md,
a.w_full,
a.overflow_hidden,
{
borderBottomLeftRadius: 0,
Expand Down Expand Up @@ -166,42 +163,7 @@ export function ExternalGifEmbed({
)}
</Fill>
)}
<MediaInsetBorder
opaque
style={[
{
borderBottomLeftRadius: 0,
borderBottomRightRadius: 0,
},
]}
/>
</Pressable>
</>
)
}

const styles = StyleSheet.create({
topRadius: {
borderTopLeftRadius: 6,
borderTopRightRadius: 6,
},
layer: {
position: 'absolute',
top: 0,
left: 0,
right: 0,
bottom: 0,
},
overlayContainer: {
flex: 1,
justifyContent: 'center',
alignItems: 'center',
},
overlayLayer: {
zIndex: 2,
},
gifContainer: {
width: '100%',
overflow: 'hidden',
},
})
Loading

0 comments on commit 4c3c10d

Please sign in to comment.