Replace "Note about sharing" prompt with an inline hint (#8452)
* add pwi warning to share menu, remove prompt * add pwi label to web, remove prompt * add an option to the PWI menu * conditionally reorder items on web
This commit is contained in:
@@ -1,5 +1,11 @@
|
||||
import React from 'react'
|
||||
import {Pressable, StyleProp, View, ViewStyle} from 'react-native'
|
||||
import {cloneElement, Fragment, isValidElement, useMemo} from 'react'
|
||||
import {
|
||||
Pressable,
|
||||
type StyleProp,
|
||||
type TextStyle,
|
||||
View,
|
||||
type ViewStyle,
|
||||
} from 'react-native'
|
||||
import {msg, Trans} from '@lingui/macro'
|
||||
import {useLingui} from '@lingui/react'
|
||||
import flattenReactChildren from 'react-keyed-flatten-children'
|
||||
@@ -16,12 +22,12 @@ import {
|
||||
useMenuItemContext,
|
||||
} from '#/components/Menu/context'
|
||||
import {
|
||||
ContextType,
|
||||
GroupProps,
|
||||
ItemIconProps,
|
||||
ItemProps,
|
||||
ItemTextProps,
|
||||
TriggerProps,
|
||||
type ContextType,
|
||||
type GroupProps,
|
||||
type ItemIconProps,
|
||||
type ItemProps,
|
||||
type ItemTextProps,
|
||||
type TriggerProps,
|
||||
} from '#/components/Menu/types'
|
||||
import {Text} from '#/components/Typography'
|
||||
|
||||
@@ -39,7 +45,7 @@ export function Root({
|
||||
control?: Dialog.DialogControlProps
|
||||
}>) {
|
||||
const defaultControl = Dialog.useDialogControl()
|
||||
const context = React.useMemo<ContextType>(
|
||||
const context = useMemo<ContextType>(
|
||||
() => ({
|
||||
control: control || defaultControl,
|
||||
}),
|
||||
@@ -276,16 +282,21 @@ export function ContainerItem({
|
||||
)
|
||||
}
|
||||
|
||||
export function LabelText({children}: {children: React.ReactNode}) {
|
||||
export function LabelText({
|
||||
children,
|
||||
style,
|
||||
}: {
|
||||
children: React.ReactNode
|
||||
style?: StyleProp<TextStyle>
|
||||
}) {
|
||||
const t = useTheme()
|
||||
return (
|
||||
<Text
|
||||
style={[
|
||||
a.font_bold,
|
||||
t.atoms.text_contrast_medium,
|
||||
{
|
||||
marginBottom: -8,
|
||||
},
|
||||
{marginBottom: -8},
|
||||
style,
|
||||
]}>
|
||||
{children}
|
||||
</Text>
|
||||
@@ -304,20 +315,20 @@ export function Group({children, style}: GroupProps) {
|
||||
style,
|
||||
]}>
|
||||
{flattenReactChildren(children).map((child, i) => {
|
||||
return React.isValidElement(child) &&
|
||||
return isValidElement(child) &&
|
||||
(child.type === Item || child.type === ContainerItem) ? (
|
||||
<React.Fragment key={i}>
|
||||
<Fragment key={i}>
|
||||
{i > 0 ? (
|
||||
<View style={[a.border_b, t.atoms.border_contrast_low]} />
|
||||
) : null}
|
||||
{React.cloneElement(child, {
|
||||
{cloneElement(child, {
|
||||
// @ts-expect-error cloneElement is not aware of the types
|
||||
style: {
|
||||
borderRadius: 0,
|
||||
borderWidth: 0,
|
||||
},
|
||||
})}
|
||||
</React.Fragment>
|
||||
</Fragment>
|
||||
) : null
|
||||
})}
|
||||
</View>
|
||||
|
||||
@@ -1,5 +1,11 @@
|
||||
import React from 'react'
|
||||
import {Pressable, type StyleProp, View, type ViewStyle} from 'react-native'
|
||||
import {forwardRef, useCallback, useId, useMemo, useState} from 'react'
|
||||
import {
|
||||
Pressable,
|
||||
type StyleProp,
|
||||
type TextStyle,
|
||||
View,
|
||||
type ViewStyle,
|
||||
} from 'react-native'
|
||||
import {msg} from '@lingui/macro'
|
||||
import {useLingui} from '@lingui/react'
|
||||
import {DropdownMenu} from 'radix-ui'
|
||||
@@ -29,10 +35,10 @@ import {Text} from '#/components/Typography'
|
||||
export {useMenuContext}
|
||||
|
||||
export function useMenuControl(): Dialog.DialogControlProps {
|
||||
const id = React.useId()
|
||||
const [isOpen, setIsOpen] = React.useState(false)
|
||||
const id = useId()
|
||||
const [isOpen, setIsOpen] = useState(false)
|
||||
|
||||
return React.useMemo(
|
||||
return useMemo(
|
||||
() => ({
|
||||
id,
|
||||
ref: {current: null},
|
||||
@@ -56,13 +62,13 @@ export function Root({
|
||||
}>) {
|
||||
const {_} = useLingui()
|
||||
const defaultControl = useMenuControl()
|
||||
const context = React.useMemo<ContextType>(
|
||||
const context = useMemo<ContextType>(
|
||||
() => ({
|
||||
control: control || defaultControl,
|
||||
}),
|
||||
[control, defaultControl],
|
||||
)
|
||||
const onOpenChange = React.useCallback(
|
||||
const onOpenChange = useCallback(
|
||||
(open: boolean) => {
|
||||
if (context.control.isOpen && !open) {
|
||||
context.control.close()
|
||||
@@ -96,7 +102,7 @@ export function Root({
|
||||
)
|
||||
}
|
||||
|
||||
const RadixTriggerPassThrough = React.forwardRef(
|
||||
const RadixTriggerPassThrough = forwardRef(
|
||||
(
|
||||
props: {
|
||||
children: (
|
||||
@@ -355,18 +361,23 @@ export function ItemRadio({selected}: {selected: boolean}) {
|
||||
)
|
||||
}
|
||||
|
||||
export function LabelText({children}: {children: React.ReactNode}) {
|
||||
export function LabelText({
|
||||
children,
|
||||
style,
|
||||
}: {
|
||||
children: React.ReactNode
|
||||
style?: StyleProp<TextStyle>
|
||||
}) {
|
||||
const t = useTheme()
|
||||
return (
|
||||
<Text
|
||||
style={[
|
||||
a.font_bold,
|
||||
a.pt_md,
|
||||
a.pb_sm,
|
||||
a.p_sm,
|
||||
t.atoms.text_contrast_low,
|
||||
{
|
||||
paddingHorizontal: 10,
|
||||
},
|
||||
a.leading_snug,
|
||||
{paddingHorizontal: 10},
|
||||
style,
|
||||
]}>
|
||||
{children}
|
||||
</Text>
|
||||
|
||||
Reference in New Issue
Block a user