Skip to content

Commit cfcc582

Browse files
committed
Merge branch 'master' of https://github.com/nandorojo/zeego
2 parents 16d7e1a + 0c5396e commit cfcc582

File tree

7 files changed

+93
-50
lines changed

7 files changed

+93
-50
lines changed

docs/docs/components/context-menu.md

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -112,10 +112,11 @@ See the Radix UI [docs for `ContextMenu.Content`](https://www.radix-ui.com/docs/
112112

113113
Wraps the trigger for your menu. The content will be anchored to the trigger.
114114

115-
| Prop | Required | Default | Platforms |
116-
| -------- | -------- | ----------- | ---------------- |
117-
| `style` | | | `web` |
118-
| `action` | | `longPress` | `ios`, `android` |
115+
| Prop | Required | Default | Platforms |
116+
| --------- | -------- | ----------- | ----------------------- |
117+
| `style` | | | `web` |
118+
| `action` | | `longPress` | `ios`, `android` |
119+
| `asChild` | | `false` | `web`, `ios`, `android` |
119120

120121
The `action` can be `longPress` or `press`.
121122

@@ -383,11 +384,22 @@ On iOS & Android, only one label is supported (unless it is inside a submenu). I
383384

384385
Renders an arrow on web only. This helps point the content to the trigger. The `Arrow` must be rendered inside of `Content`.
385386

386-
| Prop | Required | Default | Platforms |
387-
| -------- | -------- | ------- | --------- |
388-
| `style` | | | `web` |
389-
| `height` | | | `web` |
390-
| `width` | | | `web` |
387+
By default, Radix renders the arrow as an `<svg>` element. You can customize the SVG arrow color by passing a `fill` prop, `className`, or `style` object with a `fill` property.
388+
389+
:::caution
390+
391+
Because the arrow is an `<svg>` element, its `style` prop is not React Native compatible. Styling it with React Native libraries may not work as expected. If you would like to render a custom styled `<View>`, use the `asChild` prop instead of wrapping this component.
392+
393+
:::
394+
395+
| Prop | Required | Default | Platforms |
396+
| ----------- | -------- | ------- | --------- |
397+
| `width` | | 10 | `web` |
398+
| `height` | | 5 | `web` |
399+
| `fill` | | | `web` |
400+
| `style` | | | `web` |
401+
| `className` | | | `web` |
402+
| `asChild` | | `false` | `web` |
391403

392404
### Separator
393405

docs/docs/components/dropdown-menu.md

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -109,10 +109,11 @@ See the Radix UI [docs for `DropdownMenu.Content`](https://www.radix-ui.com/docs
109109

110110
Wraps the trigger for your menu. The content will be anchored to the trigger.
111111

112-
| Prop | Required | Default | Platforms |
113-
| -------- | -------- | ------- | ---------------- |
114-
| `style` | | | `web` |
115-
| `action` | | `press` | `ios`, `android` |
112+
| Prop | Required | Default | Platforms |
113+
| --------- | -------- | ------- | ----------------------- |
114+
| `style` | | | `web` |
115+
| `action` | | `press` | `ios`, `android` |
116+
| `asChild` | | `false` | `web`, `ios`, `android` |
116117

117118
The `action` can be `longPress` or `press`.
118119

@@ -348,11 +349,22 @@ On iOS & Android, only one label is supported (unless it is inside a submenu). I
348349

349350
Renders an arrow on web only. This helps point the content to the trigger. The `Arrow` must be rendered inside of `Content`.
350351

351-
| Prop | Required | Default | Platforms |
352-
| -------- | -------- | ------- | --------- |
353-
| `style` | | | `web` |
354-
| `height` | | | `web` |
355-
| `width` | | | `web` |
352+
By default, Radix renders the arrow as an `<svg>` element. You can customize the SVG arrow color by passing a `fill` prop, `className`, or `style` object with a `fill` property.
353+
354+
:::caution
355+
356+
Because the arrow is an `<svg>` element, its `style` prop is not React Native compatible. Styling it with React Native libraries may not work as expected. If you would like to render a custom styled `<View>`, use the `asChild` prop instead of wrapping this component.
357+
358+
:::
359+
360+
| Prop | Required | Default | Platforms |
361+
| ----------- | -------- | ------- | --------- |
362+
| `width` | | 10 | `web` |
363+
| `height` | | 5 | `web` |
364+
| `fill` | | | `web` |
365+
| `style` | | | `web` |
366+
| `className` | | | `web` |
367+
| `asChild` | | `false` | `web` |
356368

357369
### Separator
358370

docs/docs/start.md

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ yarn add zeego
1919
#### iOS
2020

2121
```sh
22-
yarn add react-native-ios-context-menu
22+
yarn add react-native-ios-context-menu react-native-ios-utilities
2323
```
2424

2525
#### Android
@@ -31,28 +31,29 @@ yarn add @react-native-menu/menu
3131
If you're using an Expo Development Client, there are some additional steps:
3232

3333
```yarn
34-
expo install expo-build-properites
34+
npx expo install expo-build-properties
3535
```
3636

3737
Next, add this to your app config's plugins array:
3838

3939
```js
4040
export default {
4141
plugins: [
42-
"expo-build-properties",
42+
[
43+
"expo-build-properties",
4344
{
44-
android: {
45-
// these values were tested with Expo SDK 48
46-
compileSdkVersion: 33,
47-
targetSdkVersion: 33,
48-
minSdkVersion: 23,
49-
buildToolsVersion: '33.0.0',
50-
kotlinVersion: '1.6.20',
45+
android: {
46+
// these values were tested with Expo SDK 48
47+
compileSdkVersion: 33,
48+
targetSdkVersion: 33,
49+
minSdkVersion: 23,
50+
buildToolsVersion: "33.0.0",
51+
kotlinVersion: "1.6.20",
52+
},
5153
},
52-
}
53-
]
54-
}
55-
54+
],
55+
],
56+
};
5657
```
5758

5859
If you know your way around these, you may be able to adjust them. But if you get an error related to `react-native-menu` when building, please reference these properties.
@@ -78,7 +79,7 @@ To install your dev client on your iPhone, make sure it's plugged in to your Mac
7879
After the development client build is complete, you can run your app in dev mode:
7980

8081
```bash
81-
expo start --dev-client
82+
npx expo start --dev-client
8283
```
8384

8485
If your app is on the App Store, you'll need to deploy a new build too:

examples/expo/src/App.tsx

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,17 @@ const DropdownMenuLabel = DropdownMenu.create(
211211
'ItemImage'
212212
)
213213

214+
const DropdownMenuArrow = DropdownMenu.create(
215+
(props: ComponentProps<typeof DropdownMenu.Arrow>) => (
216+
<DropdownMenu.Arrow {...props} style={{ fill: '#fff' }} />
217+
),
218+
'Arrow'
219+
)
220+
214221
const DropdownMenuExample = () => {
222+
const [arrowEnabled, setArrowEnabled] = useState<'on' | 'off' | 'mixed'>(
223+
'off'
224+
)
215225
const [bookmarked, setBookmarked] = useState<'on' | 'off' | 'mixed'>('on')
216226
return (
217227
<DropdownMenu.Root>
@@ -281,6 +291,19 @@ const DropdownMenuExample = () => {
281291
resizeMode="contain"
282292
/>
283293
</DropdownMenuCheckboxItem>
294+
<DropdownMenuCheckboxItem
295+
style={dropdownStyles.item}
296+
value={arrowEnabled}
297+
onValueChange={setArrowEnabled}
298+
key="fourth"
299+
>
300+
<DropdownMenuItemIndicator>
301+
<Ionicons name="checkmark" size={19} />
302+
</DropdownMenuItemIndicator>
303+
<DropdownMenuItemTitle>
304+
{arrowEnabled === 'on' ? 'Arrow enabled' : 'Arrow disabled'}
305+
</DropdownMenuItemTitle>
306+
</DropdownMenuCheckboxItem>
284307

285308
<DropdownMenu.Sub>
286309
<DropdownMenuSubTrigger style={dropdownStyles.item} key="nested">
@@ -329,6 +352,7 @@ const DropdownMenuExample = () => {
329352
</DropdownMenu.SubContent>
330353
</DropdownMenu.Sub>
331354
</DropdownMenu.Group>
355+
{arrowEnabled === 'on' ? <DropdownMenuArrow /> : null}
332356
</DropdownMenu.Content>
333357
</DropdownMenu.Root>
334358
)
@@ -443,8 +467,8 @@ const ContextMenuExample = () => {
443467
export default function App() {
444468
return (
445469
<View style={styles.container}>
470+
<DropdownMenuExample />
446471
<View style={{ height: 30 }} />
447-
{/* <DropdownMenuExample /> */}
448472
<ContextMenuExample />
449473
</View>
450474
)

packages/zeego/src/context-menu/context-menu.web.tsx

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -224,12 +224,8 @@ const ItemIcon = create(({ children, style }: MenuItemIconProps) => {
224224

225225
const Preview = create(() => <></>, 'Preview')
226226

227-
const Arrow = create(({ style, children, width, height }: MenuArrowProps) => {
228-
return (
229-
<ContextMenu.Arrow width={width} height={height}>
230-
<View style={[{ height, width }, style]}>{children}</View>
231-
</ContextMenu.Arrow>
232-
)
227+
const Arrow = create(({ children, ...restProps }: MenuArrowProps) => {
228+
return <ContextMenu.Arrow {...restProps}>{children}</ContextMenu.Arrow>
233229
}, 'Arrow')
234230

235231
const Sub = create(({ children }: MenuSubProps) => {

packages/zeego/src/dropdown-menu/dropdown-menu.web.tsx

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -230,12 +230,8 @@ const ItemIcon = ({ children, style }: MenuItemIconProps) => {
230230

231231
ItemIcon.displayName = MenuDisplayName.ItemIcon
232232

233-
const Arrow = create(({ style, children, width, height }: MenuArrowProps) => {
234-
return (
235-
<DropdownMenu.Arrow height={height} width={width}>
236-
<View style={[{ height, width }, style]}>{children}</View>
237-
</DropdownMenu.Arrow>
238-
)
233+
const Arrow = create(({ children, ...restProps }: MenuArrowProps) => {
234+
return <DropdownMenu.Arrow {...restProps}>{children}</DropdownMenu.Arrow>
239235
}, 'Arrow')
240236

241237
const Sub = create<MenuSubProps>(({ children }) => {

packages/zeego/src/menu/types.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type { Text, View, ImageProps, ViewProps } from 'react-native'
1+
import type { Text, View, ImageProps } from 'react-native'
22
import type { MenuContentProps as RadixContentProps } from '@radix-ui/react-dropdown-menu'
33
import type {
44
ContextMenuView,
@@ -9,9 +9,9 @@ import type {
99
ImageOptions,
1010
ImageSystemSymbolConfiguration,
1111
} from 'react-native-ios-context-menu/lib/typescript/types/ImageItemConfig'
12+
import type { ComponentProps, SVGAttributes } from 'react'
1213

1314
import type { SFSymbol } from 'sf-symbols-typescript'
14-
import type { ComponentProps } from 'react'
1515

1616
type ViewStyle = React.ComponentProps<typeof View>['style']
1717
type TextStyle = React.ComponentProps<typeof Text>['style']
@@ -150,12 +150,14 @@ export type MenuItemImageProps = MenuItemCommonProps & {
150150
}
151151
} & Pick<ImageProps, 'accessibilityLabel'>
152152

153+
type SVGProps = SVGAttributes<SVGSVGElement>
154+
153155
export type MenuArrowProps = {
154156
height?: number
155157
width?: number
156-
style?: ViewProps['style']
157158
children?: React.ReactNode
158-
}
159+
asChild?: boolean
160+
} & Pick<SVGProps, 'fill' | 'style' | 'className'>
159161

160162
export type MenuSubTriggerProps = Omit<
161163
MenuItemProps,

0 commit comments

Comments
 (0)