diff options
Diffstat (limited to 'src/components/moderation')
-rw-r--r-- | src/components/moderation/ContentHider.tsx | 4 | ||||
-rw-r--r-- | src/components/moderation/PostAlerts.tsx | 121 | ||||
-rw-r--r-- | src/components/moderation/ProfileHeaderAlerts.tsx | 103 |
3 files changed, 43 insertions, 185 deletions
diff --git a/src/components/moderation/ContentHider.tsx b/src/components/moderation/ContentHider.tsx index fd71ec838..45122a4ef 100644 --- a/src/components/moderation/ContentHider.tsx +++ b/src/components/moderation/ContentHider.tsx @@ -165,9 +165,7 @@ export function ContentHider({ } const styles = StyleSheet.create({ - outer: { - overflow: 'hidden', - }, + outer: {}, cover: { flexDirection: 'row', alignItems: 'center', diff --git a/src/components/moderation/PostAlerts.tsx b/src/components/moderation/PostAlerts.tsx index ec7529a4f..efbf18219 100644 --- a/src/components/moderation/PostAlerts.tsx +++ b/src/components/moderation/PostAlerts.tsx @@ -1,25 +1,17 @@ import React from 'react' -import {StyleProp, View, ViewStyle} from 'react-native' -import {BSKY_LABELER_DID, ModerationCause, ModerationUI} from '@atproto/api' +import {StyleProp, ViewStyle} from 'react-native' +import {ModerationUI} from '@atproto/api' import {getModerationCauseKey} from '#/lib/moderation' -import {useModerationCauseDescription} from '#/lib/moderation/useModerationCauseDescription' -import {UserAvatar} from '#/view/com/util/UserAvatar' -import {atoms as a, useTheme} from '#/alf' -import {Button} from '#/components/Button' -import { - ModerationDetailsDialog, - useModerationDetailsDialogControl, -} from '#/components/moderation/ModerationDetailsDialog' -import {Text} from '#/components/Typography' +import * as Pills from '#/components/Pills' export function PostAlerts({ modui, - size, + size = 'sm', style, }: { modui: ModerationUI - size?: 'medium' | 'large' + size?: Pills.CommonProps['size'] includeMute?: boolean style?: StyleProp<ViewStyle> }) { @@ -28,90 +20,23 @@ export function PostAlerts({ } return ( - <View style={[a.flex_col, a.gap_xs, style]}> - <View style={[a.flex_row, a.flex_wrap, a.gap_xs]}> - {modui.alerts.map(cause => ( - <PostLabel - key={getModerationCauseKey(cause)} - cause={cause} - size={size} - /> - ))} - {modui.informs.map(cause => ( - <PostLabel - key={getModerationCauseKey(cause)} - cause={cause} - size={size} - /> - ))} - </View> - </View> - ) -} - -function PostLabel({ - cause, - size, -}: { - cause: ModerationCause - size?: 'medium' | 'large' -}) { - const control = useModerationDetailsDialogControl() - const desc = useModerationCauseDescription(cause) - const t = useTheme() - - return ( - <> - <Button - label={desc.name} - onPress={e => { - e.preventDefault() - e.stopPropagation() - control.open() - }}> - {({hovered, pressed}) => ( - <View - style={[ - a.flex_row, - a.align_center, - a.gap_xs, - a.rounded_sm, - hovered || pressed - ? size === 'large' - ? t.atoms.bg_contrast_50 - : t.atoms.bg_contrast_25 - : size === 'large' - ? t.atoms.bg_contrast_25 - : undefined, - size === 'large' - ? {paddingLeft: 4, paddingRight: 6, paddingVertical: 2} - : {paddingRight: 4, paddingVertical: 1}, - ]}> - {desc.sourceType === 'labeler' && - desc.sourceDid !== BSKY_LABELER_DID ? ( - <UserAvatar - avatar={desc.sourceAvi} - size={size === 'large' ? 16 : 12} - type="labeler" - shape="circle" - /> - ) : ( - <desc.icon size="sm" fill={t.atoms.text_contrast_medium.color} /> - )} - <Text - style={[ - a.text_left, - a.leading_snug, - size === 'large' ? {fontSize: 13} : a.text_xs, - size === 'large' ? t.atoms.text : t.atoms.text_contrast_high, - ]}> - {desc.name} - </Text> - </View> - )} - </Button> - - <ModerationDetailsDialog control={control} modcause={cause} /> - </> + <Pills.Row size={size} style={[size === 'sm' && {marginLeft: -3}, style]}> + {modui.alerts.map(cause => ( + <Pills.Label + key={getModerationCauseKey(cause)} + cause={cause} + size={size} + noBg={size === 'sm'} + /> + ))} + {modui.informs.map(cause => ( + <Pills.Label + key={getModerationCauseKey(cause)} + cause={cause} + size={size} + noBg={size === 'sm'} + /> + ))} + </Pills.Row> ) } diff --git a/src/components/moderation/ProfileHeaderAlerts.tsx b/src/components/moderation/ProfileHeaderAlerts.tsx index 4b48b142d..94779697f 100644 --- a/src/components/moderation/ProfileHeaderAlerts.tsx +++ b/src/components/moderation/ProfileHeaderAlerts.tsx @@ -1,25 +1,12 @@ import React from 'react' -import {StyleProp, View, ViewStyle} from 'react-native' -import { - BSKY_LABELER_DID, - ModerationCause, - ModerationDecision, -} from '@atproto/api' +import {StyleProp, ViewStyle} from 'react-native' +import {ModerationDecision} from '@atproto/api' -import {useModerationCauseDescription} from '#/lib/moderation/useModerationCauseDescription' import {getModerationCauseKey} from 'lib/moderation' -import {UserAvatar} from '#/view/com/util/UserAvatar' -import {atoms as a, useTheme} from '#/alf' -import {Button} from '#/components/Button' -import { - ModerationDetailsDialog, - useModerationDetailsDialogControl, -} from '#/components/moderation/ModerationDetailsDialog' -import {Text} from '#/components/Typography' +import * as Pills from '#/components/Pills' export function ProfileHeaderAlerts({ moderation, - style, }: { moderation: ModerationDecision style?: StyleProp<ViewStyle> @@ -30,73 +17,21 @@ export function ProfileHeaderAlerts({ } return ( - <View style={[a.flex_col, a.gap_xs, style]}> - <View style={[a.flex_row, a.flex_wrap, a.gap_xs]}> - {modui.alerts.map(cause => ( - <ProfileLabel key={getModerationCauseKey(cause)} cause={cause} /> - ))} - {modui.informs.map(cause => ( - <ProfileLabel key={getModerationCauseKey(cause)} cause={cause} /> - ))} - </View> - </View> - ) -} - -export function ProfileLabel({ - cause, - disableDetailsDialog, -}: { - cause: ModerationCause - disableDetailsDialog?: boolean -}) { - const t = useTheme() - const control = useModerationDetailsDialogControl() - const desc = useModerationCauseDescription(cause) - - return ( - <> - <Button - disabled={disableDetailsDialog} - label={desc.name} - onPress={() => { - control.open() - }}> - {({hovered, pressed}) => ( - <View - style={[ - a.flex_row, - a.align_center, - {paddingLeft: 6, paddingRight: 8, paddingVertical: 4}, - a.gap_xs, - a.rounded_md, - hovered || pressed - ? t.atoms.bg_contrast_50 - : t.atoms.bg_contrast_25, - ]}> - {desc.sourceType === 'labeler' && - desc.sourceDid !== BSKY_LABELER_DID ? ( - <UserAvatar avatar={desc.sourceAvi} size={16} /> - ) : ( - <desc.icon size="sm" fill={t.atoms.text_contrast_medium.color} /> - )} - <Text - style={[ - a.text_left, - a.leading_snug, - a.text_sm, - t.atoms.text_contrast_medium, - a.font_semibold, - ]}> - {desc.name} - </Text> - </View> - )} - </Button> - - {!disableDetailsDialog && ( - <ModerationDetailsDialog control={control} modcause={cause} /> - )} - </> + <Pills.Row size="lg"> + {modui.alerts.map(cause => ( + <Pills.Label + size="lg" + key={getModerationCauseKey(cause)} + cause={cause} + /> + ))} + {modui.informs.map(cause => ( + <Pills.Label + size="lg" + key={getModerationCauseKey(cause)} + cause={cause} + /> + ))} + </Pills.Row> ) } |