From ff8d9408017d0317dea211c28bac86411fc303a4 Mon Sep 17 00:00:00 2001 From: Samuel Newman Date: Thu, 4 Apr 2024 02:23:32 +0100 Subject: [PATCH 01/17] alf the repost dropdown on web + import icons --- ...seQuote_filled_stroke2_corner0_rounded.svg | 1 + .../closeQuote_stroke2_corner0_rounded.svg | 1 + ...enQuote_filled_stroke2_corner0_rounded.svg | 1 + .../openQuote_stroke2_corner0_rounded.svg | 1 + .../icons/repost_stroke2_corner0_rounded.svg | 1 + src/components/icons/Quote.tsx | 17 ++ src/components/icons/Repost.tsx | 5 + .../com/util/post-ctrls/RepostButton.web.tsx | 172 +++++++++--------- 8 files changed, 113 insertions(+), 86 deletions(-) create mode 100644 assets/icons/closeQuote_filled_stroke2_corner0_rounded.svg create mode 100644 assets/icons/closeQuote_stroke2_corner0_rounded.svg create mode 100644 assets/icons/openQuote_filled_stroke2_corner0_rounded.svg create mode 100644 assets/icons/openQuote_stroke2_corner0_rounded.svg create mode 100644 assets/icons/repost_stroke2_corner0_rounded.svg create mode 100644 src/components/icons/Quote.tsx create mode 100644 src/components/icons/Repost.tsx diff --git a/assets/icons/closeQuote_filled_stroke2_corner0_rounded.svg b/assets/icons/closeQuote_filled_stroke2_corner0_rounded.svg new file mode 100644 index 0000000000..41e75887c0 --- /dev/null +++ b/assets/icons/closeQuote_filled_stroke2_corner0_rounded.svg @@ -0,0 +1 @@ + diff --git a/assets/icons/closeQuote_stroke2_corner0_rounded.svg b/assets/icons/closeQuote_stroke2_corner0_rounded.svg new file mode 100644 index 0000000000..3c76c73920 --- /dev/null +++ b/assets/icons/closeQuote_stroke2_corner0_rounded.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/assets/icons/openQuote_filled_stroke2_corner0_rounded.svg b/assets/icons/openQuote_filled_stroke2_corner0_rounded.svg new file mode 100644 index 0000000000..e8141a1128 --- /dev/null +++ b/assets/icons/openQuote_filled_stroke2_corner0_rounded.svg @@ -0,0 +1 @@ + diff --git a/assets/icons/openQuote_stroke2_corner0_rounded.svg b/assets/icons/openQuote_stroke2_corner0_rounded.svg new file mode 100644 index 0000000000..eee6344cee --- /dev/null +++ b/assets/icons/openQuote_stroke2_corner0_rounded.svg @@ -0,0 +1 @@ + diff --git a/assets/icons/repost_stroke2_corner0_rounded.svg b/assets/icons/repost_stroke2_corner0_rounded.svg new file mode 100644 index 0000000000..a3cff9c62d --- /dev/null +++ b/assets/icons/repost_stroke2_corner0_rounded.svg @@ -0,0 +1 @@ + diff --git a/src/components/icons/Quote.tsx b/src/components/icons/Quote.tsx new file mode 100644 index 0000000000..28a1aea65a --- /dev/null +++ b/src/components/icons/Quote.tsx @@ -0,0 +1,17 @@ +import {createSinglePathSVG} from './TEMPLATE' + +export const OpenQuote_Stroke2_Corner0_Rounded = createSinglePathSVG({ + path: 'M7.574 4.178a1 1 0 0 1 .43.822v5h2a1 1 0 0 1 1 1v8a1 1 0 0 1-1 1h-7a1 1 0 0 1-1-1v-8c0-2.585 1.162-4.335 2.316-5.417a8.163 8.163 0 0 1 1.569-1.15 7.029 7.029 0 0 1 .738-.36l.016-.005.005-.003h.003v-.001c.001 0 .002 0 .353.936l-.351-.936a1 1 0 0 1 .92.114Zm-1.57 2.588a5.99 5.99 0 0 0-.316.276C4.842 7.835 4.004 9.085 4.004 11v7h5v-6h-2a1 1 0 0 1-1-1V6.766Zm12.57-2.588a1 1 0 0 1 .43.822v5h2a1 1 0 0 1 1 1v8a1 1 0 0 1-1 1h-7a1 1 0 0 1-1-1v-8c0-2.585 1.162-4.335 2.316-5.417a8.166 8.166 0 0 1 1.569-1.15 7.038 7.038 0 0 1 .738-.36l.016-.005.005-.003h.003v-.001c.001 0 .002 0 .353.936l-.351-.936a1 1 0 0 1 .92.114Zm-1.57 2.588c-.105.085-.21.177-.316.276-.846.793-1.684 2.043-1.684 3.958v7h5v-6h-2a1 1 0 0 1-1-1V6.766Z', +}) + +export const OpenQuote_Filled_Stroke2_Corner0_Rounded = createSinglePathSVG({ + path: 'M8.004 5a1 1 0 0 0-.43-.822c-.57-.395-1.176-.031-1.685.255-.428.24-.998.614-1.569 1.15C3.166 6.665 2.004 8.415 2.004 11v8a1 1 0 0 0 1 1h7a1 1 0 0 0 1-1v-8a1 1 0 0 0-1-1h-2V5ZM19.004 5a1 1 0 0 0-.43-.822c-.57-.395-1.176-.031-1.685.255-.428.24-.998.614-1.569 1.15-1.154 1.082-2.316 2.832-2.316 5.417v8a1 1 0 0 0 1 1h7a1 1 0 0 0 1-1v-8a1 1 0 0 0-1-1h-2V5Z"', +}) + +export const CloseQuote_Stroke2_Corner0_Rounded = createSinglePathSVG({ + path: 'M2.004 5a1 1 0 0 1 1-1h7a1 1 0 0 1 1 1v8c0 2.585-1.162 4.335-2.316 5.417-.571.536-1.14.91-1.569 1.15a7.01 7.01 0 0 1-.738.36l-.016.006-.006.002h-.002l-.001.001L6.004 19l.351.936A1 1 0 0 1 5.004 19v-5h-2a1 1 0 0 1-1-1V5Zm5 12.234c.104-.085.21-.177.316-.276.846-.793 1.684-2.043 1.684-3.958V6h-5v6h2a1 1 0 0 1 1 1v4.234Zm6-12.234a1 1 0 0 1 1-1h7a1 1 0 0 1 1 1v8c0 2.585-1.162 4.335-2.316 5.417-.571.536-1.14.91-1.569 1.15a7.018 7.018 0 0 1-.738.36l-.016.006-.006.002h-.002l-.001.001-.352-.936.351.936A1 1 0 0 1 16.004 19v-5h-2a1 1 0 0 1-1-1V5Zm5 12.234V13a1 1 0 0 0-1-1h-2V6h5v7c0 1.915-.838 3.165-1.684 3.958-.106.1-.212.191-.316.276Z', +}) + +export const CloseQuote_Filled_Stroke2_Corner0_Rounded = createSinglePathSVG({ + path: 'M3.004 4a1 1 0 0 0-1 1v8a1 1 0 0 0 1 1h2v5a1 1 0 0 0 .43.822c.57.395 1.176.031 1.685-.255.428-.24.998-.614 1.569-1.15 1.154-1.082 2.316-2.832 2.316-5.417V5a1 1 0 0 0-1-1h-7ZM14.004 4a1 1 0 0 0-1 1v8a1 1 0 0 0 1 1h2v5a1 1 0 0 0 .43.822c.57.395 1.176.031 1.685-.255.428-.24.998-.614 1.569-1.15 1.154-1.082 2.316-2.832 2.316-5.417V5a1 1 0 0 0-1-1h-7Z', +}) diff --git a/src/components/icons/Repost.tsx b/src/components/icons/Repost.tsx new file mode 100644 index 0000000000..5c1843aa0b --- /dev/null +++ b/src/components/icons/Repost.tsx @@ -0,0 +1,5 @@ +import {createSinglePathSVG} from './TEMPLATE' + +export const Repost_Stroke2_Corner0_Rounded = createSinglePathSVG({ + path: 'M16.293 2.293a1 1 0 0 1 1.414 0l3 3a1 1 0 0 1 0 1.414l-3 3a1 1 0 0 1-1.414-1.414L17.586 7H5v4a1 1 0 1 1-2 0V6a1 1 0 0 1 1-1h13.586l-1.293-1.293a1 1 0 0 1 0-1.414ZM21 13v5a1 1 0 0 1-1 1H6.414l1.293 1.293a1 1 0 1 1-1.414 1.414l-3-3a1 1 0 0 1 0-1.414l3-3a1 1 0 0 1 1.414 1.414L6.414 17H19v-4a1 1 0 1 1 2 0Z', +}) diff --git a/src/view/com/util/post-ctrls/RepostButton.web.tsx b/src/view/com/util/post-ctrls/RepostButton.web.tsx index bbe5869feb..ca546be9a2 100644 --- a/src/view/com/util/post-ctrls/RepostButton.web.tsx +++ b/src/view/com/util/post-ctrls/RepostButton.web.tsx @@ -1,19 +1,16 @@ import React from 'react' -import {StyleProp, StyleSheet, View, ViewStyle, Pressable} from 'react-native' -import {RepostIcon} from 'lib/icons' -import {colors} from 'lib/styles' -import {useTheme} from 'lib/ThemeContext' -import {Text} from '../text/Text' - -import { - NativeDropdown, - DropdownItem as NativeDropdownItem, -} from '../forms/NativeDropdown' -import {EventStopper} from '../EventStopper' -import {useLingui} from '@lingui/react' +import {Pressable, StyleProp, View, ViewStyle} from 'react-native' import {msg} from '@lingui/macro' +import {useLingui} from '@lingui/react' + import {useRequireAuth} from '#/state/session' import {useSession} from '#/state/session' +import {atoms as a, useTheme} from '#/alf' +import {OpenQuote_Stroke2_Corner0_Rounded as Quote} from '#/components/icons/Quote' +import {Repost_Stroke2_Corner0_Rounded as Repost} from '#/components/icons/Repost' +import * as Menu from '#/components/Menu' +import {Text} from '#/components/Typography' +import {EventStopper} from '../EventStopper' interface Props { isReposted: boolean @@ -31,70 +28,65 @@ export const RepostButton = ({ onRepost, onQuote, }: Props) => { - const theme = useTheme() + const t = useTheme() const {_} = useLingui() const {hasSession} = useSession() const requireAuth = useRequireAuth() - const defaultControlColor = React.useMemo( + const color = React.useMemo( () => ({ - color: theme.palette.default.postCtrl, + color: isReposted ? t.palette.positive_600 : t.palette.contrast_500, }), - [theme], - ) - - const dropdownItems: NativeDropdownItem[] = [ - { - label: isReposted ? _(msg`Undo repost`) : _(msg`Repost`), - testID: 'repostDropdownRepostBtn', - icon: { - ios: {name: 'repeat'}, - android: '', - web: 'retweet', - }, - onPress: onRepost, - }, - { - label: _(msg`Quote post`), - testID: 'repostDropdownQuoteBtn', - icon: { - ios: {name: 'quote.bubble'}, - android: '', - web: 'quote-left', - }, - onPress: onQuote, - }, - ] - - const inner = ( - , - ]}> - - {typeof repostCount !== 'undefined' && repostCount > 0 ? ( - - {repostCount} - - ) : undefined} - + [t, isReposted], ) return hasSession ? ( - - {inner} - + + + {({props, state}) => { + return ( + + + + ) + }} + + + + + {isReposted ? _(msg`Undo repost`) : _(msg`Repost`)} + + + + + {_(msg`Quote post`)} + + + + ) : ( - {inner} + ) } -const styles = StyleSheet.create({ - btn: { - flexDirection: 'row', - alignItems: 'center', - gap: 4, - }, - btnPad: { - paddingTop: 5, - paddingBottom: 5, - paddingLeft: 5, - paddingRight: 5, - }, - reposted: { - color: colors.green3, - }, - repostCount: { - color: 'currentColor', - }, -}) +const RepostInner = ({ + big, + isReposted, + color, + repostCount, +}: { + big?: boolean + isReposted: boolean + color: {color: string} + repostCount?: number +}) => ( + + + {typeof repostCount !== 'undefined' && repostCount > 0 ? ( + + {repostCount} + + ) : undefined} + +) From 0f77877a82b0bc5363e3a68af9600a8230109ab8 Mon Sep 17 00:00:00 2001 From: Samuel Newman Date: Thu, 4 Apr 2024 02:47:38 +0100 Subject: [PATCH 02/17] alf like icon --- src/view/com/util/post-ctrls/PostCtrls.tsx | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/view/com/util/post-ctrls/PostCtrls.tsx b/src/view/com/util/post-ctrls/PostCtrls.tsx index b6c07d5735..43402fd8a4 100644 --- a/src/view/com/util/post-ctrls/PostCtrls.tsx +++ b/src/view/com/util/post-ctrls/PostCtrls.tsx @@ -16,7 +16,7 @@ import {msg, plural} from '@lingui/macro' import {useLingui} from '@lingui/react' import {HITSLOP_10, HITSLOP_20} from '#/lib/constants' -import {CommentBottomArrow, HeartIcon, HeartIconSolid} from '#/lib/icons' +import {CommentBottomArrow} from '#/lib/icons' import {makeProfileLink} from '#/lib/routes/links' import {shareUrl} from '#/lib/sharing' import {toShareUrl} from '#/lib/strings/url-helpers' @@ -34,6 +34,10 @@ import {useComposerControls} from '#/state/shell/composer' import {useHaptics} from 'lib/haptics' import {useDialogControl} from '#/components/Dialog' import {ArrowOutOfBox_Stroke2_Corner0_Rounded as ArrowOutOfBox} from '#/components/icons/ArrowOutOfBox' +import { + Heart2_Filled_Stroke2_Corner0_Rounded as HeartIconFilled, + Heart2_Stroke2_Corner0_Rounded as HeartIconOutline, +} from '#/components/icons/Heart2' import * as Prompt from '#/components/Prompt' import {PostDropdownBtn} from '../forms/PostDropdownBtn' import {Text} from '../text/Text' @@ -250,12 +254,11 @@ let PostCtrls = ({ accessibilityHint="" hitSlop={big ? HITSLOP_20 : HITSLOP_10}> {post.viewer?.like ? ( - + ) : ( - )} {typeof post.likeCount !== 'undefined' && post.likeCount > 0 ? ( From 52cc449ca7607b3fa25a694cfca5c2a895f4143d Mon Sep 17 00:00:00 2001 From: Samuel Newman Date: Thu, 4 Apr 2024 15:48:03 +0100 Subject: [PATCH 03/17] convert other post controls --- .../icons/repost_stroke2_corner3_rounded.svg | 1 + src/components/Button.tsx | 4 +- src/components/icons/Quote.tsx | 2 +- src/components/icons/Repost.tsx | 4 + src/view/com/util/forms/PostDropdownBtn.tsx | 8 +- src/view/com/util/post-ctrls/PostCtrls.tsx | 136 +++++--------- src/view/com/util/post-ctrls/RepostButton.tsx | 172 ++++++++++-------- .../com/util/post-ctrls/RepostButton.web.tsx | 18 +- 8 files changed, 160 insertions(+), 185 deletions(-) create mode 100644 assets/icons/repost_stroke2_corner3_rounded.svg diff --git a/assets/icons/repost_stroke2_corner3_rounded.svg b/assets/icons/repost_stroke2_corner3_rounded.svg new file mode 100644 index 0000000000..8aa7f727bd --- /dev/null +++ b/assets/icons/repost_stroke2_corner3_rounded.svg @@ -0,0 +1 @@ + diff --git a/src/components/Button.tsx b/src/components/Button.tsx index a008c8605c..4b9ed17324 100644 --- a/src/components/Button.tsx +++ b/src/components/Button.tsx @@ -533,10 +533,12 @@ export function ButtonIcon({ icon: Comp, position, size: iconSize, + color, }: { icon: React.ComponentType position?: 'left' | 'right' size?: SVGIconProps['size'] + color?: string }) { const {size, disabled} = useButtonContext() const textStyles = useSharedButtonTextStyles() @@ -555,7 +557,7 @@ export function ButtonIcon({ size={ iconSize ?? (size === 'large' ? 'md' : size === 'tiny' ? 'xs' : 'sm') } - style={[{color: textStyles.color, pointerEvents: 'none'}]} + style={[{color: color ?? textStyles.color, pointerEvents: 'none'}]} /> ) diff --git a/src/components/icons/Quote.tsx b/src/components/icons/Quote.tsx index 28a1aea65a..cfecb9b92d 100644 --- a/src/components/icons/Quote.tsx +++ b/src/components/icons/Quote.tsx @@ -5,7 +5,7 @@ export const OpenQuote_Stroke2_Corner0_Rounded = createSinglePathSVG({ }) export const OpenQuote_Filled_Stroke2_Corner0_Rounded = createSinglePathSVG({ - path: 'M8.004 5a1 1 0 0 0-.43-.822c-.57-.395-1.176-.031-1.685.255-.428.24-.998.614-1.569 1.15C3.166 6.665 2.004 8.415 2.004 11v8a1 1 0 0 0 1 1h7a1 1 0 0 0 1-1v-8a1 1 0 0 0-1-1h-2V5ZM19.004 5a1 1 0 0 0-.43-.822c-.57-.395-1.176-.031-1.685.255-.428.24-.998.614-1.569 1.15-1.154 1.082-2.316 2.832-2.316 5.417v8a1 1 0 0 0 1 1h7a1 1 0 0 0 1-1v-8a1 1 0 0 0-1-1h-2V5Z"', + path: 'M8.004 5a1 1 0 0 0-.43-.822c-.57-.395-1.176-.031-1.685.255-.428.24-.998.614-1.569 1.15C3.166 6.665 2.004 8.415 2.004 11v8a1 1 0 0 0 1 1h7a1 1 0 0 0 1-1v-8a1 1 0 0 0-1-1h-2V5ZM19.004 5a1 1 0 0 0-.43-.822c-.57-.395-1.176-.031-1.685.255-.428.24-.998.614-1.569 1.15-1.154 1.082-2.316 2.832-2.316 5.417v8a1 1 0 0 0 1 1h7a1 1 0 0 0 1-1v-8a1 1 0 0 0-1-1h-2V5Z', }) export const CloseQuote_Stroke2_Corner0_Rounded = createSinglePathSVG({ diff --git a/src/components/icons/Repost.tsx b/src/components/icons/Repost.tsx index 5c1843aa0b..c18551617c 100644 --- a/src/components/icons/Repost.tsx +++ b/src/components/icons/Repost.tsx @@ -3,3 +3,7 @@ import {createSinglePathSVG} from './TEMPLATE' export const Repost_Stroke2_Corner0_Rounded = createSinglePathSVG({ path: 'M16.293 2.293a1 1 0 0 1 1.414 0l3 3a1 1 0 0 1 0 1.414l-3 3a1 1 0 0 1-1.414-1.414L17.586 7H5v4a1 1 0 1 1-2 0V6a1 1 0 0 1 1-1h13.586l-1.293-1.293a1 1 0 0 1 0-1.414ZM21 13v5a1 1 0 0 1-1 1H6.414l1.293 1.293a1 1 0 1 1-1.414 1.414l-3-3a1 1 0 0 1 0-1.414l3-3a1 1 0 0 1 1.414 1.414L6.414 17H19v-4a1 1 0 1 1 2 0Z', }) + +export const Repost_Stroke2_Corner3_Rounded = createSinglePathSVG({ + path: 'M16.793 2.293a1 1 0 0 1 1.414 0L20.5 4.586a2 2 0 0 1 0 2.828l-2.293 2.293a1 1 0 0 1-1.414-1.414L18.086 7H7a2 2 0 0 0-2 2v2a1 1 0 1 1-2 0V9a4 4 0 0 1 4-4h11.086l-1.293-1.293a1 1 0 0 1 0-1.414ZM20 12a1 1 0 0 1 1 1v2a4 4 0 0 1-4 4H5.914l1.293 1.293a1 1 0 1 1-1.414 1.414L3.5 19.414a2 2 0 0 1 0-2.828l2.293-2.293a1 1 0 0 1 1.414 1.414L5.914 17H17a2 2 0 0 0 2-2v-2a1 1 0 0 1 1-1Z', +}) diff --git a/src/view/com/util/forms/PostDropdownBtn.tsx b/src/view/com/util/forms/PostDropdownBtn.tsx index 50677ee8a6..249e667ed1 100644 --- a/src/view/com/util/forms/PostDropdownBtn.tsx +++ b/src/view/com/util/forms/PostDropdownBtn.tsx @@ -7,7 +7,6 @@ import { AtUri, RichText as RichTextAPI, } from '@atproto/api' -import {FontAwesomeIcon} from '@fortawesome/react-native-fontawesome' import {msg} from '@lingui/macro' import {useLingui} from '@lingui/react' import {useNavigation} from '@react-navigation/native' @@ -37,6 +36,7 @@ import {ArrowOutOfBox_Stroke2_Corner0_Rounded as Share} from '#/components/icons import {BubbleQuestion_Stroke2_Corner0_Rounded as Translate} from '#/components/icons/Bubble' import {Clipboard_Stroke2_Corner2_Rounded as ClipboardIcon} from '#/components/icons/Clipboard' import {CodeBrackets_Stroke2_Corner0_Rounded as CodeBrackets} from '#/components/icons/CodeBrackets' +import {DotGrid_Stroke2_Corner0_Rounded as DotsHorizontal} from '#/components/icons/DotGrid' import { EmojiSad_Stroke2_Corner0_Rounded as EmojiSad, EmojiSmile_Stroke2_Corner0_Rounded as EmojiSmile, @@ -241,10 +241,8 @@ let PostDropdownBtn = ({ alf.atoms.bg_contrast_50, ], ]}> - diff --git a/src/view/com/util/post-ctrls/PostCtrls.tsx b/src/view/com/util/post-ctrls/PostCtrls.tsx index 43402fd8a4..02eb5bcb82 100644 --- a/src/view/com/util/post-ctrls/PostCtrls.tsx +++ b/src/view/com/util/post-ctrls/PostCtrls.tsx @@ -1,11 +1,5 @@ import React, {memo, useCallback} from 'react' -import { - StyleProp, - StyleSheet, - TouchableOpacity, - View, - ViewStyle, -} from 'react-native' +import {StyleProp, View, ViewStyle} from 'react-native' import { AppBskyFeedDefs, AppBskyFeedPost, @@ -16,7 +10,7 @@ import {msg, plural} from '@lingui/macro' import {useLingui} from '@lingui/react' import {HITSLOP_10, HITSLOP_20} from '#/lib/constants' -import {CommentBottomArrow} from '#/lib/icons' +import {useHaptics} from '#/lib/haptics' import {makeProfileLink} from '#/lib/routes/links' import {shareUrl} from '#/lib/sharing' import {toShareUrl} from '#/lib/strings/url-helpers' @@ -31,9 +25,11 @@ import { } from '#/state/queries/post' import {useRequireAuth} from '#/state/session' import {useComposerControls} from '#/state/shell/composer' -import {useHaptics} from 'lib/haptics' +import {atoms as a} from '#/alf' +import {Button} from '#/components/Button' import {useDialogControl} from '#/components/Dialog' import {ArrowOutOfBox_Stroke2_Corner0_Rounded as ArrowOutOfBox} from '#/components/icons/ArrowOutOfBox' +import {Bubble_Stroke2_Corner3_Rounded as Bubble} from '#/components/icons/Bubble' import { Heart2_Filled_Stroke2_Corner0_Rounded as HeartIconFilled, Heart2_Stroke2_Corner0_Rounded as HeartIconOutline, @@ -190,40 +186,39 @@ let PostCtrls = ({ }, [post.uri, post.author, sendInteraction, feedContext]) return ( - + - { if (!post.viewer?.replyDisabled) { requireAuth(() => onPressReply()) } }} - accessibilityRole="button" - accessibilityLabel={plural(post.replyCount || 0, { + label={plural(post.replyCount || 0, { one: 'Reply (# reply)', other: 'Reply (# replies)', })} - accessibilityHint="" - hitSlop={big ? HITSLOP_20 : HITSLOP_10}> - + {typeof post.replyCount !== 'undefined' && post.replyCount > 0 ? ( {post.replyCount} ) : undefined} - + - + - - + {big && ( <> - - + )} - + @@ -327,31 +317,3 @@ let PostCtrls = ({ } PostCtrls = memo(PostCtrls) export {PostCtrls} - -const styles = StyleSheet.create({ - ctrls: { - flexDirection: 'row', - justifyContent: 'space-between', - alignItems: 'center', - }, - ctrl: { - flex: 1, - alignItems: 'flex-start', - }, - ctrlBig: { - alignItems: 'center', - }, - btn: { - flexDirection: 'row', - alignItems: 'center', - }, - btnPad: { - paddingTop: 5, - paddingBottom: 5, - paddingLeft: 5, - paddingRight: 5, - }, - mt1: { - marginTop: 1, - }, -}) diff --git a/src/view/com/util/post-ctrls/RepostButton.tsx b/src/view/com/util/post-ctrls/RepostButton.tsx index f584178874..139dd34d97 100644 --- a/src/view/com/util/post-ctrls/RepostButton.tsx +++ b/src/view/com/util/post-ctrls/RepostButton.tsx @@ -1,20 +1,19 @@ -import React, {memo, useCallback} from 'react' -import {StyleProp, StyleSheet, TouchableOpacity, ViewStyle} from 'react-native' +import React, {memo} from 'react' +import {View} from 'react-native' import {msg, plural} from '@lingui/macro' import {useLingui} from '@lingui/react' -import {useModalControls} from '#/state/modals' import {useRequireAuth} from '#/state/session' -import {HITSLOP_10, HITSLOP_20} from 'lib/constants' -import {RepostIcon} from 'lib/icons' -import {colors, s} from 'lib/styles' -import {useTheme} from 'lib/ThemeContext' -import {Text} from '../text/Text' +import {atoms as a, useTheme} from '#/alf' +import {Button, ButtonIcon, ButtonText} from '#/components/Button' +import * as Dialog from '#/components/Dialog' +import {OpenQuote_Filled_Stroke2_Corner0_Rounded as Quote} from '#/components/icons/Quote' +import {Repost_Stroke2_Corner3_Rounded as Repost} from '#/components/icons/Repost' +import {Text} from '#/components/Typography' interface Props { isReposted: boolean repostCount?: number - big?: boolean onRepost: () => void onQuote: () => void } @@ -22,87 +21,106 @@ interface Props { let RepostButton = ({ isReposted, repostCount, - big, onRepost, onQuote, }: Props): React.ReactNode => { - const theme = useTheme() + const t = useTheme() const {_} = useLingui() - const {openModal} = useModalControls() const requireAuth = useRequireAuth() + const dialogControl = Dialog.useDialogControl() - const defaultControlColor = React.useMemo( + const color = React.useMemo( () => ({ - color: theme.palette.default.postCtrl, + color: isReposted ? t.palette.positive_600 : t.palette.contrast_500, }), - [theme], + [t, isReposted], ) - const onPressToggleRepostWrapper = useCallback(() => { - openModal({ - name: 'repost', - onRepost: onRepost, - onQuote: onQuote, - isReposted, - }) - }, [onRepost, onQuote, isReposted, openModal]) - return ( - { - requireAuth(() => onPressToggleRepostWrapper()) - }} - style={[styles.btn, !big && styles.btnPad]} - accessibilityRole="button" - accessibilityLabel={`${ - isReposted - ? _(msg`Undo repost`) - : _(msg({message: 'Repost', context: 'action'})) - } (${plural(repostCount || 0, {one: '# repost', other: '# reposts'})})`} - accessibilityHint="" - hitSlop={big ? HITSLOP_20 : HITSLOP_10}> - + + + + + + + + + + + + + + ) } RepostButton = memo(RepostButton) export {RepostButton} - -const styles = StyleSheet.create({ - btn: { - flexDirection: 'row', - alignItems: 'center', - }, - btnPad: { - paddingTop: 5, - paddingBottom: 5, - paddingLeft: 5, - paddingRight: 5, - }, - reposted: { - color: colors.green3, - }, - repostCount: { - color: 'currentColor', - }, -}) diff --git a/src/view/com/util/post-ctrls/RepostButton.web.tsx b/src/view/com/util/post-ctrls/RepostButton.web.tsx index ca546be9a2..85022f1b0e 100644 --- a/src/view/com/util/post-ctrls/RepostButton.web.tsx +++ b/src/view/com/util/post-ctrls/RepostButton.web.tsx @@ -7,7 +7,7 @@ import {useRequireAuth} from '#/state/session' import {useSession} from '#/state/session' import {atoms as a, useTheme} from '#/alf' import {OpenQuote_Stroke2_Corner0_Rounded as Quote} from '#/components/icons/Quote' -import {Repost_Stroke2_Corner0_Rounded as Repost} from '#/components/icons/Repost' +import {Repost_Stroke2_Corner3_Rounded as Repost} from '#/components/icons/Repost' import * as Menu from '#/components/Menu' import {Text} from '#/components/Typography' import {EventStopper} from '../EventStopper' @@ -15,7 +15,6 @@ import {EventStopper} from '../EventStopper' interface Props { isReposted: boolean repostCount?: number - big?: boolean onRepost: () => void onQuote: () => void style?: StyleProp @@ -24,7 +23,6 @@ interface Props { export const RepostButton = ({ isReposted, repostCount, - big, onRepost, onQuote, }: Props) => { @@ -51,17 +49,12 @@ export const RepostButton = ({ style={[ a.rounded_full, (state.hovered || state.pressed) && { - backgroundColor: t.palette.positive_100, + backgroundColor: t.palette.contrast_50, }, ]}> @@ -97,7 +90,6 @@ export const RepostButton = ({ accessibilityLabel={_(msg`Repost or quote post`)} accessibilityHint=""> ( - + {typeof repostCount !== 'undefined' && repostCount > 0 ? ( Date: Thu, 4 Apr 2024 15:53:40 +0100 Subject: [PATCH 04/17] add missing padding to share button --- src/view/com/util/post-ctrls/PostCtrls.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/view/com/util/post-ctrls/PostCtrls.tsx b/src/view/com/util/post-ctrls/PostCtrls.tsx index 02eb5bcb82..21f12c030a 100644 --- a/src/view/com/util/post-ctrls/PostCtrls.tsx +++ b/src/view/com/util/post-ctrls/PostCtrls.tsx @@ -220,7 +220,6 @@ let PostCtrls = ({ + - + {big && ( <> - + accessibilityLabel={_(msg`Share`)} + accessibilityHint="" + hitSlop={big ? HITSLOP_20 : HITSLOP_10}> + + void onQuote: () => void + size?: 'lg' | 'md' | 'sm' } let RepostButton = ({ @@ -23,6 +24,7 @@ let RepostButton = ({ repostCount, onRepost, onQuote, + size, }: Props): React.ReactNode => { const t = useTheme() const {_} = useLingui() @@ -52,7 +54,7 @@ let RepostButton = ({ shape="round" variant="ghost" color="secondary"> - + {typeof repostCount !== 'undefined' && repostCount > 0 ? ( void onQuote: () => void - style?: StyleProp + size?: 'lg' | 'md' | 'sm' } export const RepostButton = ({ @@ -25,6 +25,7 @@ export const RepostButton = ({ repostCount, onRepost, onQuote, + size, }: Props) => { const t = useTheme() const {_} = useLingui() @@ -56,6 +57,7 @@ export const RepostButton = ({ isReposted={isReposted} color={color} repostCount={repostCount} + size={size} /> ) @@ -93,6 +95,7 @@ export const RepostButton = ({ isReposted={isReposted} color={color} repostCount={repostCount} + size={size} /> ) @@ -102,13 +105,15 @@ const RepostInner = ({ isReposted, color, repostCount, + size, }: { isReposted: boolean color: {color: string} repostCount?: number + size?: 'lg' | 'md' | 'sm' }) => ( - + {typeof repostCount !== 'undefined' && repostCount > 0 ? ( Date: Thu, 4 Apr 2024 21:46:31 +0100 Subject: [PATCH 06/17] revert buttonicon changes --- src/components/Button.tsx | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/components/Button.tsx b/src/components/Button.tsx index 4b9ed17324..a008c8605c 100644 --- a/src/components/Button.tsx +++ b/src/components/Button.tsx @@ -533,12 +533,10 @@ export function ButtonIcon({ icon: Comp, position, size: iconSize, - color, }: { icon: React.ComponentType position?: 'left' | 'right' size?: SVGIconProps['size'] - color?: string }) { const {size, disabled} = useButtonContext() const textStyles = useSharedButtonTextStyles() @@ -557,7 +555,7 @@ export function ButtonIcon({ size={ iconSize ?? (size === 'large' ? 'md' : size === 'tiny' ? 'xs' : 'sm') } - style={[{color: color ?? textStyles.color, pointerEvents: 'none'}]} + style={[{color: textStyles.color, pointerEvents: 'none'}]} /> ) From 732218bafeae651788920228a374c00c39417806 Mon Sep 17 00:00:00 2001 From: Samuel Newman Date: Thu, 4 Apr 2024 21:49:40 +0100 Subject: [PATCH 07/17] remove ButtonIcon and ButtonText from repost dialog --- src/view/com/util/post-ctrls/RepostButton.tsx | 22 +++++++------------ 1 file changed, 8 insertions(+), 14 deletions(-) diff --git a/src/view/com/util/post-ctrls/RepostButton.tsx b/src/view/com/util/post-ctrls/RepostButton.tsx index 5eb262038e..411a08fa93 100644 --- a/src/view/com/util/post-ctrls/RepostButton.tsx +++ b/src/view/com/util/post-ctrls/RepostButton.tsx @@ -5,7 +5,7 @@ import {useLingui} from '@lingui/react' import {useRequireAuth} from '#/state/session' import {atoms as a, useTheme} from '#/alf' -import {Button, ButtonIcon, ButtonText} from '#/components/Button' +import {Button, ButtonText} from '#/components/Button' import * as Dialog from '#/components/Dialog' import {CloseQuote_Stroke2_Corner1_Rounded as Quote} from '#/components/icons/Quote' import {Repost_Stroke2_Corner2_Rounded as Repost} from '#/components/icons/Repost' @@ -81,16 +81,12 @@ let RepostButton = ({ }} size="large" variant="outline"> - - + + {isReposted ? _(msg`Remove repost`) : _(msg({message: `Repost`, context: 'action'}))} - + ) } From 6bbe713423985eefc356407c7a1908e553852ba3 Mon Sep 17 00:00:00 2001 From: Samuel Newman Date: Tue, 23 Apr 2024 18:24:09 +0100 Subject: [PATCH 11/17] add `userSelect: 'none'` to buttons --- src/alf/atoms.ts | 11 ++++++++++- src/view/com/util/post-ctrls/PostCtrls.tsx | 8 +++++++- src/view/com/util/post-ctrls/RepostButton.web.tsx | 1 + 3 files changed, 18 insertions(+), 2 deletions(-) diff --git a/src/alf/atoms.ts b/src/alf/atoms.ts index 3e5ddf049b..158bb6ec5b 100644 --- a/src/alf/atoms.ts +++ b/src/alf/atoms.ts @@ -841,7 +841,7 @@ export const atoms = { marginRight: 'auto', }, /* - * Pointer events + * Pointer events & user select */ pointer_events_none: { pointerEvents: 'none', @@ -849,6 +849,15 @@ export const atoms = { pointer_events_auto: { pointerEvents: 'auto', }, + user_select_none: { + userSelect: 'none', + }, + user_select_text: { + userSelect: 'text', + }, + user_select_all: { + userSelect: 'all', + }, /* * Text decoration */ diff --git a/src/view/com/util/post-ctrls/PostCtrls.tsx b/src/view/com/util/post-ctrls/PostCtrls.tsx index 256511f1ea..6aab2a9a04 100644 --- a/src/view/com/util/post-ctrls/PostCtrls.tsx +++ b/src/view/com/util/post-ctrls/PostCtrls.tsx @@ -228,7 +228,12 @@ let PostCtrls = ({ height={big ? 22 : 18} /> {typeof post.replyCount !== 'undefined' && post.replyCount > 0 ? ( - + {post.replyCount} ) : undefined} @@ -273,6 +278,7 @@ let PostCtrls = ({ style={[ [ big ? a.text_md : {fontSize: 15}, + a.user_select_none, post.viewer?.like ? [a.font_bold, s.likeColor] : defaultCtrlColor, diff --git a/src/view/com/util/post-ctrls/RepostButton.web.tsx b/src/view/com/util/post-ctrls/RepostButton.web.tsx index 430739fb73..17cb1217a0 100644 --- a/src/view/com/util/post-ctrls/RepostButton.web.tsx +++ b/src/view/com/util/post-ctrls/RepostButton.web.tsx @@ -125,6 +125,7 @@ const RepostInner = ({ color, size === 'lg' ? a.text_md : {fontSize: 15}, isReposted && [a.font_bold], + a.user_select_none, ]}> {repostCount} From 8a754f9af3f64d65478f35f88fec177956753a4e Mon Sep 17 00:00:00 2001 From: Samuel Newman Date: Tue, 23 Apr 2024 18:54:01 +0100 Subject: [PATCH 12/17] use width rather than height --- src/view/com/util/post-ctrls/PostCtrls.tsx | 8 ++++---- src/view/com/util/post-ctrls/RepostButton.tsx | 2 +- .../com/util/post-ctrls/RepostButton.web.tsx | 16 ++++++++-------- 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/src/view/com/util/post-ctrls/PostCtrls.tsx b/src/view/com/util/post-ctrls/PostCtrls.tsx index 6aab2a9a04..c81e41c0f6 100644 --- a/src/view/com/util/post-ctrls/PostCtrls.tsx +++ b/src/view/com/util/post-ctrls/PostCtrls.tsx @@ -225,7 +225,7 @@ let PostCtrls = ({ hitSlop={big ? HITSLOP_20 : HITSLOP_10}> {typeof post.replyCount !== 'undefined' && post.replyCount > 0 ? ( {post.viewer?.like ? ( - + ) : ( )} {typeof post.likeCount !== 'undefined' && post.likeCount > 0 ? ( @@ -307,7 +307,7 @@ let PostCtrls = ({ hitSlop={big ? HITSLOP_20 : HITSLOP_10}> diff --git a/src/view/com/util/post-ctrls/RepostButton.tsx b/src/view/com/util/post-ctrls/RepostButton.tsx index 1efa0eb451..49ce6e52df 100644 --- a/src/view/com/util/post-ctrls/RepostButton.tsx +++ b/src/view/com/util/post-ctrls/RepostButton.tsx @@ -55,7 +55,7 @@ let RepostButton = ({ shape="round" variant="ghost" color="secondary"> - + {typeof repostCount !== 'undefined' && repostCount > 0 ? ( void onQuote: () => void - size?: 'lg' | 'md' | 'sm' + big?: boolean } export const RepostButton = ({ @@ -26,7 +26,7 @@ export const RepostButton = ({ repostCount, onRepost, onQuote, - size, + big, }: Props) => { const t = useTheme() const {_} = useLingui() @@ -58,7 +58,7 @@ export const RepostButton = ({ isReposted={isReposted} color={color} repostCount={repostCount} - size={size} + big={big} /> ) @@ -99,7 +99,7 @@ export const RepostButton = ({ isReposted={isReposted} color={color} repostCount={repostCount} - size={size} + big={big} /> ) @@ -109,21 +109,21 @@ const RepostInner = ({ isReposted, color, repostCount, - size, + big, }: { isReposted: boolean color: {color: string} repostCount?: number - size?: 'lg' | 'md' | 'sm' + big?: boolean }) => ( - + {typeof repostCount !== 'undefined' && repostCount > 0 ? ( From 7db7320fbe12b2a3474fa165f141662f1c58984c Mon Sep 17 00:00:00 2001 From: Samuel Newman Date: Wed, 29 May 2024 15:09:17 +0300 Subject: [PATCH 13/17] fix quote close behaviour --- src/view/com/util/post-ctrls/RepostButton.tsx | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/view/com/util/post-ctrls/RepostButton.tsx b/src/view/com/util/post-ctrls/RepostButton.tsx index 49ce6e52df..1124cb4059 100644 --- a/src/view/com/util/post-ctrls/RepostButton.tsx +++ b/src/view/com/util/post-ctrls/RepostButton.tsx @@ -1,4 +1,4 @@ -import React, {memo} from 'react' +import React, {memo, useCallback} from 'react' import {View} from 'react-native' import {msg, plural} from '@lingui/macro' import {useLingui} from '@lingui/react' @@ -38,6 +38,8 @@ let RepostButton = ({ [t, isReposted], ) + const close = useCallback(() => dialogControl.close(), [dialogControl]) + return ( <>